Skip to content
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

Using function on column in WHERE clause does not generate parameter #3463

Open
mlucic opened this issue Jun 24, 2024 · 0 comments
Open

Using function on column in WHERE clause does not generate parameter #3463

mlucic opened this issue Jun 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mlucic
Copy link

mlucic commented Jun 24, 2024

Version

1.26.0

What happened?

This issue appears to be the same found in #103

Given a table with string column a and number column b, the following query will not generate a parameter for column a.

Removing the LOWER() invocation results in the parameter being created

Relevant log output

unknown field A in struct literal of type sqlc.GetThingsParams

Database schema

CREATE TABLE `myTable` (
  `a` varchar(255) NOT NULL,
  `b` int NOT NULL,
  PRIMARY KEY (`a`,`b`)
);

SQL queries

-- name: GetThings :many
SELECT
  a,
  count(b) as cnt
FROM myTable
WHERE LOWER(a) IN (sqlc.slice('a'))
  AND b IN (sqlc.slice('b'))
GROUP BY a
ORDER BY cnt DESC
LIMIT ?;

Configuration

version: "2"
sql:
  - engine: "mysql"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "sqlc"
        out: "sqlc"

Playground URL

https://play.sqlc.dev/p/c59b57d2349c28a5ec9dee78a1a5ffbb64bea2853bb289e5b4aa19990980a9ca

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

@mlucic mlucic added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 24, 2024
@mlucic mlucic changed the title Using LOWER on column in WHERE clause does not generate parameter Using function on column in WHERE clause does not generate parameter Jun 24, 2024
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants