Skip to content
Permalink
Browse files

Issue #12: Support "find text on server" tool with compatible queries…

… in SQLite
  • Loading branch information
ansgarbecker committed Jan 19, 2020
1 parent 3b84ccc commit fdb5a61024b49e9e0fc97503762b8ab5ed6ac739
Showing with 23 additions and 0 deletions.
  1. +23 −0 source/tabletools.pas
@@ -868,6 +868,13 @@ procedure TfrmTableTools.DoFind(DBObj: TDBObject);
FindText := LowerCase(FindText);
FindTextJokers := LowerCase(FindTextJokers);
RoutineDefinitionColumn := 'LOWER('+RoutineDefinitionColumn+')';
if DBObj.Connection.Parameters.IsSQLite then begin
DBObj.Connection.Query('PRAGMA case_sensitive_like=FALSE');
end;
end else begin
if DBObj.Connection.Parameters.IsSQLite then begin
DBObj.Connection.Query('PRAGMA case_sensitive_like=TRUE');
end;
end;
RoutineSchemaColumn := 'routine_schema';
if DBObj.Connection.Parameters.IsMSSQL then
@@ -910,6 +917,12 @@ procedure TfrmTableTools.DoFind(DBObj: TDBObject);
else
SQL := SQL + 'CAST(' + Column + ' AS TEXT) LIKE ' + esc(FindTextJokers) + ' OR ';
end;
ngSQLite: begin
if IsRegExp then
SQL := SQL + Column + ' REGEXP ' + esc(FindText) + ' OR '
else
SQL := SQL + Column + ' LIKE ' + esc(FindTextJokers) + ' OR ';
end;
end;

end else begin
@@ -930,6 +943,12 @@ procedure TfrmTableTools.DoFind(DBObj: TDBObject);
else
SQL := SQL + 'LOWER(CAST('+Column+' AS TEXT)) LIKE ' + esc(FindTextJokers) + ' OR ';
end;
ngSQLite: begin
if IsRegExp then
SQL := SQL + Column + ' REGEXP ' + esc(FindText) + ' OR '
else
SQL := SQL + Column + ' LIKE ' + esc(FindTextJokers) + ' OR ';
end;
end;
end;

@@ -948,6 +967,10 @@ procedure TfrmTableTools.DoFind(DBObj: TDBObject);
SQL := 'SELECT '''+DBObj.Database+''' AS '+DBObj.Connection.QuoteIdent('Database')+', '''+DBObj.Name+''' AS '+DBObj.Connection.QuoteIdent('Table')+', COUNT(*) AS '+DBObj.Connection.QuoteIdent('Found rows')+', '
+ 'CONVERT(VARCHAR(10), ROUND(100 / '+IntToStr(Max(DBObj.Rows,1))+' * COUNT(*), 1)) + ''%'' AS '+DBObj.Connection.QuoteIdent('Relevance')+' FROM '+DBObj.QuotedDatabase+'.'+DBObj.QuotedName+' WHERE '
+ SQL;
ngSQLite:
SQL := 'SELECT '''+DBObj.Database+''' AS '+DBObj.Connection.QuoteIdent('Database')+', '''+DBObj.Name+''' AS '+DBObj.Connection.QuoteIdent('Table')+', COUNT(*) AS '+DBObj.Connection.QuoteIdent('Found rows')+', '
+ '(ROUND(100 / '+IntToStr(Max(DBObj.Rows,1))+' * COUNT(*), 1) || ''%'') AS '+DBObj.Connection.QuoteIdent('Relevance')+' FROM '+DBObj.QuotedDatabase+'.'+DBObj.QuotedName+' WHERE '
+ SQL;
end;
AddResults(SQL, DBObj.Connection);
end else

0 comments on commit fdb5a61

Please sign in to comment.
You can’t perform that action at this time.