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

Recognize type affinities #28

Open
jlarmstrongiv opened this issue Aug 3, 2023 · 0 comments
Open

Recognize type affinities #28

jlarmstrongiv opened this issue Aug 3, 2023 · 0 comments

Comments

@jlarmstrongiv
Copy link
Contributor

SQLite supports type affinities with CREATE TABLE:

Example Typenames From TheCREATE TABLE Statement or CAST Expression Resulting Affinity Rule Used To Determine Affinity
INT INTEGER TINYINT SMALLINT MEDIUMINT BIGINT UNSIGNED BIG INT INT2 INT8 INTEGER 1
CHARACTER(20) VARCHAR(255) VARYING CHARACTER(255) NCHAR(55) NATIVE CHARACTER(70) NVARCHAR(100) TEXT CLOB TEXT 2
BLOB no datatype specified BLOB 3
REAL DOUBLE DOUBLE PRECISION FLOAT REAL 4
NUMERIC DECIMAL(10,5) BOOLEAN DATE DATETIME NUMERIC 5

When I use type affinities in SQLite:

CREATE TABLE sqlite_sequence(name,seq);

CREATE TABLE "artists"
(
    ArtistId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    Name NVARCHAR(120)
);

It generates invalid TypeScript types:

export const generatedSchema = schema<{
  sqlite_sequence: {
    name: any | null;
    seq: any | null
  };
  "artists": {
    ArtistId: number;
    Name: NVARCHAR | null
  };
}>;

Database originally from https://www.sqlitetutorial.net/sqlite-sample-database/

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

No branches or pull requests

1 participant