Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lormayna opened this issue Jul 23, 2023 · 2 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@lormayna
Copy link

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

@lormayna lormayna added bug Something isn't working triage New issues that hasn't been reviewed labels Jul 23, 2023
@lormayna lormayna changed the title SQLite: "sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext" Sqlite INSERT: "sqlite.convertLiteral: Unknown node type *parser.Expr_literalContext" Jul 23, 2023
@orisano
Copy link
Contributor

orisano commented Jul 23, 2023

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

@orisano
Copy link
Contributor

orisano commented Aug 2, 2023

This is already fixed.
https://play.sqlc.dev/p/428b4c67ba3f25cd1d7b64a7cb37bb91a87cbacbb6d4ef7a44e844a3d92b4c93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

3 participants