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

Missing binds in ORDER BY #1194

Closed
jamisonhyatt opened this issue Sep 18, 2021 · 1 comment
Closed

Missing binds in ORDER BY #1194

jamisonhyatt opened this issue Sep 18, 2021 · 1 comment
Labels
📚 mysql bug Something isn't working 🔧 golang

Comments

@jamisonhyatt
Copy link

Version

1.10.0

What happened?

👋 Experimenting with sqlc and conditional order by's aren't generating the code for mysql as I'd expect. Didn't see any matching issues - hopefully I didn't miss one.

As you can see by the example below, the mysql generated code skips the sqlc.arg(sort_column) bind.

As an alternate example, here's postgres working as expected

Relevant log output

No response

Database schema

-- Example queries for sqlc
CREATE TABLE authors (
  id   BIGINT PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: ListAuthors :many
SELECT * FROM authors
WHERE id > sqlc.arg(min_id) 
ORDER BY CASE WHEN sqlc.arg(sort_column) = 'name' THEN name END;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "mysql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/4d6a51438a52ec0067279884c6327f14e1c2e50d3057591178c44e438f926385

What operating system are you using?

No response

What database engines are you using?

MySQL

What type of code are you generating?

Go

@jamisonhyatt jamisonhyatt added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 18, 2021
@kyleconroy kyleconroy changed the title Mysql: missing binds in ORDER BY Missing binds in ORDER BY Sep 20, 2021
@kyleconroy kyleconroy added 🔧 golang 📚 mysql and removed triage New issues that hasn't been reviewed labels Sep 20, 2021
@kyleconroy
Copy link
Collaborator

Thanks for the bug report. I believe this and #1195 are caused by the same issue, but I'll keep both open until they're fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 mysql bug Something isn't working 🔧 golang
Projects
None yet
Development

No branches or pull requests

2 participants