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

[BUG]In PostgreSQL, int8 represents the 64-bit integer type, not tinyint #3391

Closed
fuzi1996 opened this issue May 1, 2024 · 0 comments · Fixed by #3392
Closed

[BUG]In PostgreSQL, int8 represents the 64-bit integer type, not tinyint #3391

fuzi1996 opened this issue May 1, 2024 · 0 comments · Fixed by #3392

Comments

@fuzi1996
Copy link

fuzi1996 commented May 1, 2024

Fully reproducible code snippet

import sqlglot

if __name__ == '__main__':
    sql = """create table a_table
        (
            column_id      int8 not null constraint a_table_pk primary key,
            column_2       date,
            column_3       varchar(2000),
            column_4       int2,
            column_5       int4
        );
    """
    expressions = sqlglot.parse(sql, dialect="postgres")
    expression = expressions[0]
    print(expression.sql())

output

CREATE TABLE a_table (column_id **TINYINT** NOT NULL CONSTRAINT a_table_pk PRIMARY KEY, column_2 DATE, column_3 VARCHAR(2000), column_4 SMALLINT, column_5 INT)

"int8" being mistranslated as "tinyint"

Official Documentation

postgresql 10 official document: https://www.postgresql.org/docs/10/datatype.html#DATATYPE-TABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant