-
Notifications
You must be signed in to change notification settings - Fork 886
sqlc ignore paramter in LIKE #895
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
Comments
I'm going to need more information before I reproduce your issue. Can you please answer the following questions:
Can you also try to reproduce the issue in the sqlc playground? |
While this compiles fine: -- name: SearchAuthor :many
SELECT * from authors WHERE name LIKE '%$1%'; It does not produce a parametrized method: func (q *Queries) SearchAuthor(ctx context.Context) ([]Author, error) |
One workaround is to define it as: -- name: SearchAuthor :many
SELECT * from authors WHERE name LIKE $1; And specify the |
Hi. I have had the same problem but it seems occur only when MySQL engine is used.
Playground: https://play.sqlc.dev/p/1f74d1fa215e49a51bedd8bab968826d5f772e1ffdd4c938ec78694823c033da MySQL engine seems to ignore argument(s). -- Example queries for sqlc
CREATE TABLE authors (
id SERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
-- name: SearchAuthor :many
SELECT * from authors WHERE name = $1; // Code generated by sqlc. DO NOT EDIT.
// source: query.sql
package db
import (
"context"
)
const searchAuthor = `-- name: SearchAuthor :many
SELECT id, name, bio from authors WHERE name = $1
`
func (q *Queries) SearchAuthor(ctx context.Context) ([]Author, error) {
rows, err := q.db.QueryContext(ctx, searchAuthor)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Author
for rows.Next() {
var i Author
if err := rows.Scan(&i.ID, &i.Name, &i.Bio); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
} |
Has this been fixed? The playground link still generates the wrong code. |
I have the same problem. LIKE is ignored |
I have the same problem. LIKE is ignored |
Is there any possibility to add this feature for MySQL in near future? |
sqlc version : 1.8 |
this problem occured on me too, just when using MySQL
|
It seems that sqlc does not recognize a parameter inside a LIKE string, is there a special syntax for that or is it just not supported?
The text was updated successfully, but these errors were encountered: