-
Hello! query.driftsong_fulltext_search(:match_string AS TEXT, :match_arguments AS TEXT):
SELECT
bm25(songs_fts, 0.0, 0.0, 10.0, 0.5, 5.0, 5.0, 2.0, 0.0, 0.0) AS rank
,uuid
,source_bank_id
,pitch_field
,snippet(songs_fts, 2, '<?', '?>', '...', 30) AS match_title
,snippet(songs_fts, 3, '<?', '?>', '...', 40) AS match_lyrics
,snippet(songs_fts, 4, '<?', '?>', '...', 15) AS match_composer
,snippet(songs_fts, 5, '<?', '?>', '...', 15) AS match_poet
,snippet(songs_fts, 6, '<?', '?>', '...', 15) AS match_translator
FROM songs_fts
WHERE songs_fts MATCH :match_string
AND :match_arguments
ORDER BY rank; I've added an SELECT * FROM songs_fts
WHERE
songs_fts MATCH 'hello'
AND (
content_map->>'content_tags' LIKE '%great%'
OR
content_map->>'content_tags' LIKE '%stuff%'
); The part of the query after the I can of course string-interpolate my way to hell and make a custom query after all with no safety. So TLDR:
Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This sounds like a perfect fit for Dart components in SQL. Drift re-interprets the custom_filter: SELECT * FROM songs_fts
WHERE
songs_fts MATCH 'hello'
AND $filter; Drift should generate a method like this: Selectable<Song> customFilter({required Expression<bool> Function(SongsFts songsFts) filter}) Which you can then use like this (or use custom expressions for this part only if you need await customFilter(filter: (songsFts) {
final contentTags = songsFts.contentMap.jsonExtract<String>(r'$.content_tag');
return (contentTags.like('%great%')) | (contentTags.like('%stuff%'));
}).get(); |
Beta Was this translation helpful? Give feedback.
-
For any future traveller here - This is what I came up with in the end: |
Beta Was this translation helpful? Give feedback.
This sounds like a perfect fit for Dart components in SQL. Drift re-interprets the
$
variable syntax as a point where expressions generated by the query builder at runtime can be injected. So if you define a query like this:Drift should generate a method like this:
Which you can then use like this (or use custom expressions for this part only if you need
->>
, that operator is not available through the query API yet):