Skip to content

Ignore quotes and braces and case #31

Open
@jlarmstrongiv

Description

Braces from SQL definition

Ignore braces in column names, as they are in the sql column from the sqlite_schema table:

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

Quotes in table names

Ignore quotes in the table names:

const query = generatedSchema.sql<{
  GenreId: number;
  Name: string | null
}>`SELECT * FROM "genres"`;

Without quotes, column selection fails:

const query = generatedSchema.sql<{
  
}>`SELECT * FROM genres`;

Matching case in column and table names

Ignore column and table case in the queries:

  const query = schema.sql<{
  Name: string | null
}>`SELECT Name FROM artists`;

Without matching case, column selection fails:

  const query = schema.sql<{/*
  Could not find selected column name in from clause
*/}>`SELECT name FROM artists`;

Missing Semicolons

Have a user friendly error message when defining schema and forgetting a semicolon or two:

CREATE TABLE "albums"
(
    AlbumId INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    Title TEXT(160)  NOT NULL,
    ArtistId INTEGER  NOT NULL,
    FOREIGN KEY (ArtistId) REFERENCES "artists" (ArtistId)
		ON DELETE NO ACTION ON UPDATE NO ACTION
)

CREATE TABLE sqlite_sequence(name,seq)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions