shared: sqlitesearch: Avoid joining content table more than once
This commit is contained in:
		@@ -133,12 +133,17 @@ QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
 | 
				
			|||||||
		throw LooqsGeneralException("Nothing to search for supplied");
 | 
							throw LooqsGeneralException("Nothing to search for supplied");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool ftsAlreadyJoined = false;
 | 
				
			||||||
	auto tokens = query.getTokens();
 | 
						auto tokens = query.getTokens();
 | 
				
			||||||
	for(const Token &token : tokens)
 | 
						for(const Token &token : tokens)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if(token.type == FILTER_CONTENT_CONTAINS)
 | 
							if(token.type == FILTER_CONTENT_CONTAINS)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if(!ftsAlreadyJoined)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				joinSql += " INNER JOIN content_fts ON content.id = content_fts.ROWID ";
 | 
									joinSql += " INNER JOIN content_fts ON content.id = content_fts.ROWID ";
 | 
				
			||||||
 | 
									ftsAlreadyJoined = true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			whereSql += " content_fts.content MATCH ? ";
 | 
								whereSql += " content_fts.content MATCH ? ";
 | 
				
			||||||
			bindValues.append(token.value);
 | 
								bindValues.append(token.value);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user