Repository navigation
panic: expected range var #1590
Copy link
Copy link
Closed
Labels
Description
Version
Other
What happened?
A previously filed bug. Was found again while attempting to perform an implicit JOIN with mysql.
Using version v1.13.0
Relevant log output
panic: expected range var
goroutine 1 [running]:
github.com/kyleconroy/sqlc/internal/engine/dolphin.(*cc).convertUpdateStmt(0x10?, 0xc0001ecc60)
github.com/kyleconroy/sqlc/internal/engine/dolphin/convert.go:551 +0x5ad
github.com/kyleconroy/sqlc/internal/engine/dolphin.(*cc).convert(0xc000418600?, {0x5051910?, 0xc0001ecc60?})
github.com/kyleconroy/sqlc/internal/engine/dolphin/convert.go:1722 +0xb73
github.com/kyleconroy/sqlc/internal/engine/dolphin.(*Parser).Parse(0xc00019a820, {0x5046aa0?, 0xc00003dca0?})
github.com/kyleconroy/sqlc/internal/engine/dolphin/parse.go:63 +0x19d
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQueries(0xc0004cc000, {0x50?, {0x50?, 0xe7?, {0x0?, 0x1?}}})
github.com/kyleconroy/sqlc/internal/compiler/compile.go:102 +0x3ad
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
github.com/kyleconroy/sqlc/internal/compiler/engine.go:49
github.com/kyleconroy/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {_, _}, {{0xc0002934b6, 0x5}, ...}, ...)
github.com/kyleconroy/sqlc/internal/cmd/generate.go:262 +0x253
github.com/kyleconroy/sqlc/internal/cmd.Generate({0x504baa0, 0xc00019e008}, {0xc0?, 0x6b?}, {0xc000040004, 0x21}, {0x0?, 0x4c01500?}, {0x50469c0, 0xc00019a010})
github.com/kyleconroy/sqlc/internal/cmd/generate.go:183 +0x7b4
github.com/kyleconroy/sqlc/internal/cmd.glob..func3(0x5e32000, {0x4d52b07?, 0x0?, 0x0?})
github.com/kyleconroy/sqlc/internal/cmd/cmd.go:144 +0x194
github.com/spf13/cobra.(*Command).execute(0x5e32000, {0x5ea5678, 0x0, 0x0})
github.com/spf13/cobra@v1.4.0/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc000370a00)
github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.4.0/command.go:902
github.com/spf13/cobra.(*Command).ExecuteContext(...)
github.com/spf13/cobra@v1.4.0/command.go:895
github.com/kyleconroy/sqlc/internal/cmd.Do({0xc0001a8010, 0x1, 0x1}, {0x5046980?, 0xc00019a000}, {0x50469c0?, 0xc00019a008}, {0x50469c0?, 0xc00019a010})
github.com/kyleconroy/sqlc/internal/cmd/cmd.go:47 +0x4ba
main.main()
github.com/kyleconroy/sqlc/cmd/sqlc/main.go:10 +0x7aDatabase schema
CREATE TABLE authors (
name text NOT NULL,
deleted_at datetime NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE books (
is_amazing tinyint(1) NOT NULL,
deleted_at datetime NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);SQL queries
-- name: DeleteAuthor :exec
UPDATE authors, books
SET
authors.deleted_at = now(),
authors.updated_at = now()
WHERE books.is_amazing = 1
AND authors.name = sqlc.arg(name);Configuration
{
"version": "1",
"packages": [
{
"path": "db",
"engine": "mysql",
"schema": "query.sql",
"queries": "query.sql"
}
]
}Playground URL
https://play.sqlc.dev/p/9fc9f9695357e74d7f9f4050bda23c51999cd7bb07380ff3615b69b6a4f8428c
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go
Reactions are currently unavailable
Activity
j0holo commentedon May 16, 2022
I have the same
expected var rangeerror with a double INNER JOIN UPDATE query.https://play.sqlc.dev/p/be2e1f7f70d375b63f211a212d08be832943946296fc8f08aa84bde7fd5392ea
blampe commentedon Jul 27, 2022
I also see this with
convertDeleteStmt, although I'm pointing to a migrations folder (golang-migrate) and I'm not sure how to easily identify which one is the culprit.ravayak commentedon Apr 3, 2023
Same 'range var' problem here with this update query:
fix(mysql): Prevent UPDATE ... JOIN panic #1590 (#2154)
fix(mysql): Prevent UPDATE ... JOIN panic sqlc-dev#1590 (sqlc-dev#2154)