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 errors when setting BOOLEAN #3196

Closed
sjunepark opened this issue Feb 13, 2024 · 1 comment
Closed

SQlite errors when setting BOOLEAN #3196

sjunepark opened this issue Feb 13, 2024 · 1 comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@sjunepark
Copy link

Version

1.25.0

What happened?

Hi,

If I type a field as BOOLEAN, sqlc creates a struct with type bool.

CREATE TABLE IF NOT EXISTS locations
(
    ValidPosition      BOOLEAN NOT NULL CHECK (ValidPosition = 0 OR ValidPosition = 1),
)
type Location struct {
	Validposition      bool
}

Which results to a INSERT error below

unsupported type bool

As a current work around, I'm just defining related field as INTEGERs, which probably won't be different internally.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

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

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

@sjunepark sjunepark added bug Something isn't working triage New issues that hasn't been reviewed labels Feb 13, 2024
@sjunepark
Copy link
Author

My mistake,

Found out that this wasn't about sqlc and it was because I used the libsql driver when opening the db.
Changing sql.Open("libsql", "file:"+dbName) to sql.Open("sqlite3", "file:"+dbName) and removing `libsql related code solved it.

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

1 participant