Skip to content

Support more forms of generated columns for SQLite dialect #1050

@takluyver

Description

@takluyver

SQLite allows some ways of defining a generated column which sqlparser currently rejects.

First, the GENERATED ALWAYS keywords are optional:

Parser::parse_sql(&SQLiteDialect {},
    "CREATE TABLE t1(a INT, b INT AS (a * 2) STORED);")?;
Error: sql parser error: Expected ',' or ')' after column definition, found: AS at Line: 1, Column 30

Second, the clause can have a VIRTUAL keyword stuck on the end (instead of STORED). This is the default behaviour anyway, just made explicit.

Parser::parse_sql(&SQLiteDialect {},
    "CREATE TABLE t1(a INT, b INT GENERATED ALWAYS AS (a * 2) VIRTUAL);")?;
Error: sql parser error: Expected ',' or ')' after column definition, found: VIRTUAL at Line: 1, Column 58

I think the distinction of stored-or-not is also not exposed in the AST at present.

I can have a go at fixing one or both of these, but I wanted to record the issue clearly first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions