Skip to content

Sqlite INSERT: "sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext" #2494

Description

@lormayna

Version

1.19.1

What happened?

When I tried to create an insert query, I am getting the following error:

`sqlc generate failed.
2023/07/23 15:12:44 sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext
2023/07/23 15:12:44 sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext

package db

query.sql:34:1: column "TicketNumber" does not exist`

The same parameter don't generate error when used in SELECT.

Relevant log output

sqlc generate failed.
2023/07/23 15:12:44 sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext
2023/07/23 15:12:44 sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext
# package db
query.sql:34:1: column "TicketNumber" does not exist`

Database schema

CREATE TABLE Subscribers (
    Id INTEGER NOT NULL,
    Cookie varchar(30) NOT NULL,
    Phone varchar(15) NOT NULL,
    TicketId INTEGER NOT NULL,
    UserAgent text,
    CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    SmsSent BOOLEAN DEFAULT False,
    SmsSentAt TIMESTAMP DEFAULT NULL,
    Voted BOOLEAN DEFAULT False,
    VotedAt TIMESTAMP DEFAULT NULL,
    PRIMARY KEY(Id),
    UNIQUE(Cookie),
    UNIQUE(Phone),
    FOREIGN KEY(TicketId) REFERENCES Tickets(Id)
);

CREATE TABLE Tickets (
    Id INTEGER NOT NULL,
    TicketNumber varchar(40) NOT NULL,
    Activated BOOLEAN DEFAULT False,
    ActivatedAt TIMESTAMP DEFAULT NULL,
    PRIMARY KEY(Id),
    UNIQUE(TicketNumber)
);

SQL queries

-- name: GetTicket :one
SELECT Id FROM Tickets  WHERE TicketNumber=? AND Activated=False;

-- name: ConsumeTicket :exec
UPDATE Tickets SET Activated=True, ActivatedAt=CURRENT_TIMESTAMP WHERE TicketNumber=?;

-- name: InsertTicket :exec
INSERT INTO Tickets (TicketNumber) VALUES (?);

Configuration

version: 2
sql:
  - engine: "sqlite"
    schema: "./db/schema.sql"
    queries: "./db/query.sql"
    gen:
      go:
        package: "models"
        out: "models"

Playground URL

https://play.sqlc.dev/p/598549928daf00679cb6315d8539ed796609774aff56278ca9cf116d6503c5c2

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jul 23, 2023
  2. changed the title [-]SQLite: "sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext"[/-] [+]Sqlite INSERT: "sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext"[/+] on Jul 23, 2023
  3. orisano commented on Jul 23, 2023

    @orisano
    Contributor

    Same problem as #2120
    I have confirmed that this issue will also be resolved in #2433

  4. orisano commented on Aug 2, 2023

    @orisano
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions