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]sqlc always convert something like BOOLEAN(2) and CHAR(255) to interface{} #3754

Open
leopku opened this issue Dec 19, 2024 · 0 comments
Labels
📚 sqlite bug Something isn't working 🔧 golang

Comments

@leopku
Copy link

leopku commented Dec 19, 2024

Version

1.27.0

What happened?

Sqlite field types with size like CHAR(255), CHAR(16), BOOLEAN(2) etc were converted to interface{} incorrectly.

Relevant log output

No response

Database schema

-- BIOG_MAIN definition
CREATE TABLE BIOG_MAIN (
    c_personid INTEGER NOT NULL,
    c_name CHAR(255),
    c_name_chn CHAR(255),
    c_index_year INTEGER,
    c_index_year_type_code CHAR(16),
    c_index_year_source_id INTEGER,
    c_female BOOLEAN(2) NOT NULL,
    c_index_addr_id INTEGER,
    c_index_addr_type_code INTEGER,
    c_ethnicity_code INTEGER,
    c_household_status_code INTEGER,
    c_tribe CHAR(255),
    c_birthyear INTEGER,
    c_by_nh_code INTEGER,
    c_by_nh_year INTEGER,
    c_by_range INTEGER,
    c_deathyear INTEGER,
    c_dy_nh_code INTEGER,
    c_dy_nh_year INTEGER,
    c_dy_range INTEGER,
    c_death_age INTEGER,
    c_death_age_range INTEGER,
    c_fl_earliest_year INTEGER,
    c_fl_ey_nh_code INTEGER,
    c_fl_ey_nh_year INTEGER,
    c_fl_ey_notes CHAR,
    c_fl_latest_year INTEGER,
    c_fl_ly_nh_code INTEGER,
    c_fl_ly_nh_year INTEGER,
    c_fl_ly_notes CHAR,
    c_surname CHAR(255),
    c_surname_chn CHAR(255),
    c_mingzi CHAR(255),
    c_mingzi_chn CHAR(255),
    c_dy INTEGER,
    c_choronym_code INTEGER,
    c_notes CHAR,
    c_by_intercalary BOOLEAN(2) NOT NULL,
    c_dy_intercalary BOOLEAN(2) NOT NULL,
    c_by_month INTEGER,
    c_dy_month INTEGER,
    c_by_day INTEGER,
    c_dy_day INTEGER,
    c_by_day_gz INTEGER,
    c_dy_day_gz INTEGER,
    c_surname_proper CHAR(255),
    c_mingzi_proper CHAR(255),
    c_name_proper CHAR(255),
    c_surname_rm CHAR(255),
    c_mingzi_rm CHAR(255),
    c_name_rm CHAR(255),
    c_created_by CHAR(255),
    c_created_date CHAR(255),
    c_modified_by CHAR(255),
    c_modified_date CHAR(255),
    c_self_bio BOOLEAN(2) NOT NULL
);

CREATE INDEX BIOG_MAIN_PrimaryKey ON BIOG_MAIN (c_personid ASC);

CREATE INDEX BIOG_MAIN_c_index_addr_id ON BIOG_MAIN (c_index_addr_id ASC);

CREATE INDEX BIOG_MAIN_c_index_addr_type_code ON BIOG_MAIN (c_index_addr_type_code ASC);

CREATE INDEX BIOG_MAIN_c_name ON BIOG_MAIN (c_name ASC);

CREATE INDEX BIOG_MAIN_c_name_chn ON BIOG_MAIN (c_name_chn ASC);

CREATE INDEX BIOG_MAIN_c_personid ON BIOG_MAIN (c_personid ASC);

SQL queries

-- name: GetAllBiogMain :many
SELECT
    c_personid as person_id,
    c_name as name_py,
    c_name_chn as name,
    c_female as is_female
FROM
    BIOG_MAIN
LIMIT
    ?
OFFSET
    ?;

Configuration

version: "2"
sql:
  - engine: "sqlite"
    queries: "sqlc/biog_main_query.sql"
    schema: "sqlc/biog_main_schema.sql"
    gen:
      go:
        package: "biogmain"
        out: "pkg/models/biogmain"
        emit_db_tags: true

Playground URL

https://play.sqlc.dev/p/92af62bf6b092599b40a0a424d07090367d6c8b64b4123bbcad4eb6c5bd4ce7c

What operating system are you using?

Windows, macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

@leopku leopku added the bug Something isn't working label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 sqlite bug Something isn't working 🔧 golang
Projects
None yet
Development

No branches or pull requests

1 participant