-
Notifications
You must be signed in to change notification settings - Fork 919
Closed
Labels
Description
Version
1.16.0
What happened?
When I run sqlc generate
it gives me the error I pasted below.
I expect it to, well, parse/generate without errors but it panics at a runtime error (index out of range) error.
Relevant log output
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).resolveCatalogRefs(0xc0002f3570?, 0xc000ad89d0, {0xc000ad89c0, 0x2, 0xc000aa3019?}, {0xc0003f4a20, 0x3, 0x40?}, 0xc000ade060)
github.com/kyleconroy/sqlc/internal/compiler/resolve.go:332 +0x2e17
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQuery(0xc00044c800, {0x5596be93d8a0?, 0xc0004ba9a0?}, {0xc000aa3000, 0xfa0}, {{0x80?, 0x1f?, {0x0?, 0x10?}}})
github.com/kyleconroy/sqlc/internal/compiler/parse.go:91 +0x7cd
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).parseQueries(0xc00044c800, {{0x60?, 0x98?, {0x0?, 0x5?}}})
github.com/kyleconroy/sqlc/internal/compiler/compile.go:108 +0x4da
github.com/kyleconroy/sqlc/internal/compiler.(*Compiler).ParseQueries(...)
github.com/kyleconroy/sqlc/internal/compiler/engine.go:49
github.com/kyleconroy/sqlc/internal/cmd.parse({_, _}, {_, _}, {_, _}, {_, _}, {{0xc0002130d6, 0xa}, ...}, ...)
github.com/kyleconroy/sqlc/internal/cmd/generate.go:277 +0x25b
github.com/kyleconroy/sqlc/internal/cmd.Generate({0x5596be947b30, 0xc000126000}, {0x0?, 0x0?}, {0xc00004e004, 0x3e}, {0x0?, 0x0?}, {0x5596be9427c0, 0xc000120010})
github.com/kyleconroy/sqlc/internal/cmd/generate.go:219 +0x80d
github.com/kyleconroy/sqlc/internal/cmd.glob..func3(0x5596bf1a40c0, {0x5596bdd4bd81?, 0x0?, 0x0?})
github.com/kyleconroy/sqlc/internal/cmd/cmd.go:147 +0x194
github.com/spf13/cobra.(*Command).execute(0x5596bf1a40c0, {0x5596bf7ed190, 0x0, 0x0})
github.com/spf13/cobra@v1.6.0/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001aec00)
github.com/spf13/cobra@v1.6.0/command.go:1040 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.6.0/command.go:968
github.com/spf13/cobra.(*Command).ExecuteContext(...)
github.com/spf13/cobra@v1.6.0/command.go:961
github.com/kyleconroy/sqlc/internal/cmd.Do({0xc000124010, 0x1, 0x1}, {0x5596be942780?, 0xc000120000}, {0x5596be9427c0?, 0xc000120008}, {0x5596be9427c0?, 0xc000120010})
github.com/kyleconroy/sqlc/internal/cmd/cmd.go:50 +0x487
main.main()
github.com/kyleconroy/sqlc/cmd/sqlc/main.go:10 +0x78
Database schema
CREATE TABLE IF NOT EXISTS student (
roll_number CHAR(8) PRIMARY KEY,
section VARCHAR(6) NOT NULL CHECK(section SIMILAR TO '__-_[1-9][0-9]?'),
name VARCHAR(50) NOT NULL,
gender CHAR(1) CHECK(gender IN ('M', 'F', 'O')),
mobile VARCHAR(14) UNIQUE,
birth_date DATE,
email VARCHAR(40) NOT NULL CHECK(email LIKE '%___@nitkkr.ac.in'),
batch SMALLINT NOT NULL CHECK(batch >= 0),
hostel_id VARCHAR(4) NOT NULL REFERENCES hostel(id),
room_id VARCHAR(6) CHECK(room_id LIKE '%_-___'),
discord_id BIGINT UNIQUE,
clubs JSONB NOT NULL,
is_verified BOOLEAN DEFAULT false NOT NULL
);
SQL queries
UPDATE
student
SET
clubs = clubs || JSONB_BUILD_OBJECT($1, $2)
WHERE
roll_number = $3;
Configuration
version: 1
packages:
- name: "query"
path: "internal/query"
queries: "./sql/queries"
schema:
# These are listed separately so that the tables are created in a preferred order
- "./sql/schemas/student.sql"
- "./sql/schemas/faculty.sql"
- "./sql/schemas/guild.sql"
- "./sql/schemas/club.sql"
- "./sql/schemas/course.sql"
engine: "postgresql"
emit_json_tags: true
json_tags_case_style: "snake"
Playground URL
https://play.sqlc.dev/p/fc76f60292e16ea3caf51789872775bc486d3b80fa7cdc577a1077b0db6506ca
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go