-
Notifications
You must be signed in to change notification settings - Fork 889
fix(sqlite): allow using fts5 table name in the where clause #3498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@kyleconroy Thank you for Could you look at this PR, please? I have to use my fork as a workaround. Would love to get this in the official package. |
@@ -168,6 +168,12 @@ func (c *cc) convertCreate_virtual_table_fts5(n *parser.Create_virtual_table_stm | |||
} | |||
} | |||
|
|||
stmt.Cols = append(stmt.Cols, &ast.ColumnDef{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine to include the fts5 table name in the column list, as SQLite supports this as well
sqlite> SELECT key, emails_fts FROM emails_fts limit 1;
┌───────────────────────────────────────────────────┬────────────┐
│ key │ emails_fts │
├───────────────────────────────────────────────────┼────────────┤
│ 1708522984.M224116P268.c18ac5293f65,S=3578,W=3701 │ 5 │
└───────────────────────────────────────────────────┴────────────┘
Could you please rebase this on the latest main? The tests didn't run when it was originally opened. |
d2e447d
to
a4bbafc
Compare
@kyleconroy Done 🟢! |
is this going to be merged anytime soon? |
@naspeh I am joining the FTS5 table in a query and use it in WHERE. This does not seem to work on your branch. Expected behavior? |
@awgaan it should work, I think. I can't check, I lost context for this branch as I stopped using sqlc on the project. |
Turns out sqlc treats |
stmt.Cols = append(stmt.Cols, &ast.ColumnDef{ | ||
Colname: identifier(stmt.Name.Name), | ||
IsNotNull: true, | ||
TypeName: &ast.TypeName{Name: "text"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a problem with doing it like this: if you SELECT <table_name> FROM <table_name>
, you get an integer
, but when you use MATCH
, you are expected to provide a string
.
Does this fix this? -- WORKING
-- name: GetProductsBySearchQuery :many
SELECT * FROM tbl_products_fts
WHERE
serial MATCH ? OR
name MATCH ?
LIMIT ?;
-- Not working " column "tbl_products_fts" does not exist"
SELECT * FROM tbl_products_fts
WHERE tbl_products_fts MATCH ?
LIMIT ?; |
Yep, it should fix this.
…On Mon, Jun 23, 2025, 08:04 flamendless ***@***.***> wrote:
*flamendless* left a comment (sqlc-dev/sqlc#3498)
<#3498 (comment)>
Does this fix this?
-- WORKING-- name: GetProductsBySearchQuery :manySELECT * FROM tbl_products_ftsWHERE
serial MATCH ? OR
name MATCH ?LIMIT ?;
-- Not working " column "tbl_products_fts" does not exist"SELECT * FROM tbl_products_ftsWHERE tbl_products_fts MATCH ?LIMIT ?;
—
Reply to this email directly, view it on GitHub
<#3498 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABHMCI3HJTL35HYTPED4TT3E6DGJAVCNFSM6AAAAABLIAM2QOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOJUHEZTKNZRG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Awesome! I cant wait for this to get merged and released |
Fixes: #3204
Allow using table name to the left of MATCH or equality operator.
Related: