Open rob2244 opened 1 month ago
The issue is that your query has a named parameter "term_embedding" and a sequence parameter "$1" inferred as "term_embedding". To resolve this, you just need to change the name of the parameter "term_embedding".
example:
-- name: foo :many
SELECT
id,
term,
definition,
tags
FROM glossary
WHERE 1 - (term_embedding <=> sqlc.arg(term_embedding_p)) >= $1
AND org_id = $2
ORDER BY 1 - (term_embedding <=> sqlc.arg(term_embedding_p)) DESC
LIMIT $3;
@felipesdias Same issue, I get TermEmbedding and Embedding in generated struct
https://play.sqlc.dev/p/c62075bad2d8348587ff871fda37f694911eab79225a8592050d31459e2aaca0
@felipesdias Same issue, I get TermEmbedding and Embedding in generated struct
https://play.sqlc.dev/p/c62075bad2d8348587ff871fda37f694911eab79225a8592050d31459e2aaca0
Ah nvm I see the problem I have to cast $1 as a float, it's thinking it's another vector, ty!
I think I'm gonna make a docs pr in case this naming thing trips anybosy else up
Version
1.26.0
What happened?
When using the same numbered parameter multiple times in the same statement, or when using sqlc.arg or sqlc.narg with the same parameter name with a PgVector Vector type, the parameter is output in the generated struct multiple times.
The expectation is that the parameter is generated in the struct only once and used multiple times in the SQL. It seems to only be a problem with PgVector and is working correctly with other data types.
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/ef4803670b12447e6b7b3bb4330920573dd2e1f32fbf0262657355baec04dd84
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go