Skip to content

panic: expected range var #1590

Closed
Closed
@drhoden-fastly

Description

@drhoden-fastly

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 +0x7a

Database 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions