Skip to content

CREATE TRIGGER support for SQLite syntax #2023

@LucaCappelletti94

Description

@LucaCappelletti94

At the time of writing, as described earlier in issues such as #1388, the CREATE TRIGGER syntax for SQLite is not supported.

For instance, once this feature is fully supported, I expect the following snippet to execute, while at this time it crashes with ParserError("Expected: an object type after CREATE, found: TRIGGER at Line: 1, Column: 8").

I will proceed with a PR attempt after determining what to do with #2020 and #2022.

let to_parse = r#"CREATE TRIGGER trg_inherit_asset_models
AFTER INSERT ON parent_procedure_templates
FOR EACH ROW
BEGIN
    INSERT INTO procedure_template_asset_models (
        name,
        procedure_template,
        based_on,
        asset_model,
        created_by,
        created_at
    )
    SELECT
        pam.name,
        NEW.parent,
        pam.id,
        pam.asset_model,
        NEW.created_by,
        NEW.created_at
    FROM procedure_template_asset_models pam
    WHERE pam.procedure_template = NEW.child;
END;
"#;
let stmt =
  sqlparser::parser::Parser::parse_sql(&sqlparser::dialect::SQLiteDialect {}, to_parse)
      .unwrap();

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