Title: Delete query with join returns panic: expected range var error · Issue #3848 · sqlc-dev/sqlc · GitHub
Open Graph Title: Delete query with join returns panic: expected range var error · Issue #3848 · sqlc-dev/sqlc
X Title: Delete query with join returns panic: expected range var error · Issue #3848 · sqlc-dev/sqlc
Description: Version 1.28.0 What happened? When generating a query with a delete statement that uses a join, sqlc returns this error: panic: expected range var The code itself works in my database if I run it native. I've made a simplified version of...
Open Graph Description: Version 1.28.0 What happened? When generating a query with a delete statement that uses a join, sqlc returns this error: panic: expected range var The code itself works in my database if I run it n...
X Description: Version 1.28.0 What happened? When generating a query with a delete statement that uses a join, sqlc returns this error: panic: expected range var The code itself works in my database if I run it n...
Opengraph URL: https://github.com/sqlc-dev/sqlc/issues/3848
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Delete query with join returns panic: expected range var error","articleBody":"### Version\n\n1.28.0\n\n### What happened?\n\nWhen generating a query with a delete statement that uses a join, sqlc returns this error:\n\n`panic: expected range var`\n\nThe code itself works in my database if I run it native. I've made a simplified version of my database and query to show the issue.\n\n### Relevant log output\n\n```shell\npanic: expected range var\n\ngoroutine 7 [running]:\ngithub.com/sqlc-dev/sqlc/internal/engine/dolphin.convertToRangeVarList(0xc00006aa40?, 0xc0004bb3b0)\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/engine/dolphin/utils.go:68 +0x328\ngithub.com/sqlc-dev/sqlc/internal/engine/dolphin.(*cc).convertDeleteStmt(0xc00006aa40, 0xc000b93cc0)\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/engine/dolphin/convert.go:302 +0x90\ngithub.com/sqlc-dev/sqlc/internal/engine/dolphin.(*cc).convert(0xc00006aa40, {0x1e8c7e0?, 0xc000b93cc0?})\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/engine/dolphin/convert.go:1557 +0x3e5\ngithub.com/sqlc-dev/sqlc/internal/engine/dolphin.(*Parser).Parse(0xc0000a70f8, {0x1e692e0?, 0xc0007f14c0?})\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/engine/dolphin/parse.go:63 +0x205\ngithub.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).parseQueries(0xc000474008, {{0x0, 0x0, {0x0, 0x0}, 0x0, 0x0, 0x0, 0x0}})\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/compiler/compile.go:75 +0x24e\ngithub.com/sqlc-dev/sqlc/internal/compiler.(*Compiler).ParseQueries(...)\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/compiler/engine.go:72\ngithub.com/sqlc-dev/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {{0x0, 0x0}, {0xc000438866, 0x5}, ...}, ...)\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/cmd/generate.go:322 +0x2dc\ngithub.com/sqlc-dev/sqlc/internal/cmd.processQuerySets.func1()\n\t/home/wout/go/pkg/mod/github.com/sqlc-dev/sqlc@v1.28.0/internal/cmd/process.go:107 +0x81a\ngolang.org/x/sync/errgroup.(*Group).Go.func1()\n\t/home/wout/go/pkg/mod/golang.org/x/sync@v0.10.0/errgroup/errgroup.go:78 +0x50\ncreated by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1\n\t/home/wout/go/pkg/mod/golang.org/x/sync@v0.10.0/errgroup/errgroup.go:75 +0x96\n```\n\n### Database schema\n\n```sql\nCREATE TABLE `conflicts` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `currency_id` int(10) unsigned NOT NULL,\n `blockchain_id` int(10) unsigned NOT NULL,\n `reference` varchar(255) NOT NULL,\n PRIMARY KEY (`id`)\n);\n```\n\n### SQL queries\n\n```sql\n-- name: DeleteConflicts :execrows\nDELETE conflicts\nFROM conflicts\n JOIN (\n SELECT blockchain_id, reference\n FROM conflicts\n GROUP BY blockchain_id, reference\n HAVING COUNT(DISTINCT currency_id) = 1\n ) AS resolved_conflicts\n ON conflicts.blockchain_id = resolved_conflicts.blockchain_id\n AND conflicts.reference = resolved_conflicts.reference;\n```\n\n### Configuration\n\n```yaml\nversion: \"2\"\ncloud:\n organization: \"\"\n project: \"\"\n hostname: \"\"\nsql:\n - schema: ./sql/schema.sql\n queries: ./sql/queries\n engine: mysql\n gen:\n go:\n package: sqlc\n out: ./_sqlc\n emit_json_tags: true\n emit_prepared_queries: false\n emit_interface: false\n emit_exact_table_names: true\noverrides:\n go: null\nplugins: []\nrules: []\noptions: {}\n```\n\n### Playground URL\n\nhttps://play.sqlc.dev/p/8b36238bfbc667bc2478394d370938fdaad11bd2c82df63a5e59f17b699b24f0\n\n### What operating system are you using?\n\nLinux\n\n### What database engines are you using?\n\nMySQL\n\n### What type of code are you generating?\n\nGo","author":{"url":"https://github.com/wouthoekstra","@type":"Person","name":"wouthoekstra"},"datePublished":"2025-02-17T10:37:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/3848/sqlc/issues/3848"}
| 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:c90e53e6-52f3-a5cd-6cec-c3c9798bce38 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D84A:73E1D:636497:854E9F:6A504C9A |
| html-safe-nonce | 060b7445a18e991099704d69a5f0b0b12ecbe66f2d034117f262d2c03932beb4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODRBOjczRTFEOjYzNjQ5Nzo4NTRFOUY6NkE1MDRDOUEiLCJ2aXNpdG9yX2lkIjoiMzk5NDUwNDYwOTk1OTc5MTc3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a419c548929b378f287e6bff7a6bcca622d3d3f685e7514b8dac44d3a6d5eba0 |
| hovercard-subject-tag | issue:2857448284 |
| 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/3848/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5509b81e14808ccd322d5201639e67a074f00ba21651e1723dc2006a44f94539/sqlc-dev/sqlc/issues/3848 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5509b81e14808ccd322d5201639e67a074f00ba21651e1723dc2006a44f94539/sqlc-dev/sqlc/issues/3848 |
| og:image:alt | Version 1.28.0 What happened? When generating a query with a delete statement that uses a join, sqlc returns this error: panic: expected range var The code itself works in my database if I run it n... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wouthoekstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 5741a45fe07e5f377d0d4c524a92e3056acc51bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width