Title: Args in sqlite ORDER BY not respected · Issue #3788 · sqlc-dev/sqlc · GitHub
Open Graph Title: Args in sqlite ORDER BY not respected · Issue #3788 · sqlc-dev/sqlc
X Title: Args in sqlite ORDER BY not respected · Issue #3788 · sqlc-dev/sqlc
Description: Version 1.27.0 What happened? Similarly to #3113 The postgres generator supports variables in the ORDER BY, but sqlite does not. CREATE TABLE authors ( id int PRIMARY KEY ); -- name: GetAuthor :one SELECT * FROM authors WHERE id = @id OR...
Open Graph Description: Version 1.27.0 What happened? Similarly to #3113 The postgres generator supports variables in the ORDER BY, but sqlite does not. CREATE TABLE authors ( id int PRIMARY KEY ); -- name: GetAuthor :one...
X Description: Version 1.27.0 What happened? Similarly to #3113 The postgres generator supports variables in the ORDER BY, but sqlite does not. CREATE TABLE authors ( id int PRIMARY KEY ); -- name: GetAuthor :one...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/3788
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Args in sqlite ORDER BY not respected","articleBody":"### Version\n\n1.27.0\n\n### What happened?\n\nSimilarly to https://github.com/sqlc-dev/sqlc/issues/3113\nThe postgres generator supports variables in the ORDER BY, but sqlite does not.\n\n```sql\nCREATE TABLE authors (\n id int PRIMARY KEY\n);\n```\n```sql\n-- name: GetAuthor :one\nSELECT * FROM authors\nWHERE id = @id\nORDER BY @order_by;\n```\n\n```\nconst getAuthor = `-- name: GetAuthor :one\nSELECT id FROM authors\nWHERE id = ?1\nORDER BY @order_by\n`\n\nfunc (q *Queries) GetAuthor(ctx context.Context, id int64) (int64, error) {\n\trow := q.db.QueryRowContext(ctx, getAuthor, id)\n\terr := row.Scan(\u0026id)\n\treturn id, err\n}\n```\nPlayground link is to 1.25.0, but this is happening locally on 1.27.0 as well. Changing only the engine value to `postgresql` results in the expected output for postgresql. But the same is not reflected in sqlite.\n\n\n### Relevant log output\n\n```shell\n\n```\n\n### Database schema\n\n```sql\nCREATE TABLE authors (\n id int PRIMARY KEY\n);\n```\n\n### SQL queries\n\n```sql\n-- name: GetAuthor :one\nSELECT * FROM authors\nWHERE id = @id\nORDER BY @order_by;\n```\n\n### Configuration\n\n```yaml\n{\n \"version\": \"2\",\n \"sql\": [{\n \"schema\": \"schema.sql\",\n \"queries\": \"query.sql\",\n \"engine\": \"sqlite\",\n \"gen\": {\n \"go\": {\n \"out\": \"db\"\n }\n }\n }]\n}\n```\n\n### Playground URL\n\nhttps://play.sqlc.dev/p/a0947e011d5ec187db7c502d1044c9eb10d6a2f9f5c6d44f166b23a2fa6c5f07\n\n### What operating system are you using?\n\nmacOS\n\n### What database engines are you using?\n\nSQLite\n\n### What type of code are you generating?\n\nGo","author":{"url":"https://github.com/bmpender","@type":"Person","name":"bmpender"},"datePublished":"2025-01-14T21:57:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/3788/sqlc/issues/3788"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:231987a6-22fc-3857-fa8b-6d94634b209c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6C4:6F3CF:8A82D7D:C308872:6A50DDA5 |
| html-safe-nonce | 8c116cfbbb745049f7f71ff8c65b88972a8db539d026703e71bd9671288613f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkM0OjZGM0NGOjhBODJEN0Q6QzMwODg3Mjo2QTUwRERBNSIsInZpc2l0b3JfaWQiOiIzMzQzNzk5NTE4NTQ3NzE2MjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c79d10f4074791fcb46752d72a17ce1e712ec577ca25c82409db7dff35a291fd |
| hovercard-subject-tag | issue:2788354936 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlc-dev/sqlc/3788/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db205797aa3eb0cb8d03619b0860aab6b2099c5003ec148cf7943a8e34fe4305/sqlc-dev/sqlc/issues/3788 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db205797aa3eb0cb8d03619b0860aab6b2099c5003ec148cf7943a8e34fe4305/sqlc-dev/sqlc/issues/3788 |
| og:image:alt | Version 1.27.0 What happened? Similarly to #3113 The postgres generator supports variables in the ORDER BY, but sqlite does not. CREATE TABLE authors ( id int PRIMARY KEY ); -- name: GetAuthor :one... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bmpender |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlc-dev/sqlc git https://github.com/sqlc-dev/sqlc.git |
| octolytics-dimension-user_id | 136738596 |
| octolytics-dimension-user_login | sqlc-dev |
| octolytics-dimension-repository_id | 193160679 |
| octolytics-dimension-repository_nwo | sqlc-dev/sqlc |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 193160679 |
| octolytics-dimension-repository_network_root_nwo | sqlc-dev/sqlc |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 17290b65caabb92b271e0949d1bf147b63deab41 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width