-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parse): support SQLValueFunction (#154)
Running Squawk on the following SQL statement `alter table if exists foo alter column created_at set default current_timestamp`, errors out with ``` Problem linting SQL files: Squawk schema failed to parse Postgres response. This indicates a bug with Squawk. Please report this error to https://github.com/sbdchd/squawk. Schema error: unknown variant `SQLValueFunction`, expected one of `TypeCast`, `FuncCall`, `Constraint`, `ColumnDef`, `A_Const`, `ReplicaIdentityStmt` at line 1 column 267 ``` This PR adds the alter table command definition `SQLValueFunction` to the parser.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
source: parser/src/parse.rs | ||
expression: res | ||
--- | ||
Ok( | ||
[ | ||
RawStmt( | ||
RawStmt { | ||
stmt: AlterTableStmt( | ||
AlterTableStmt { | ||
cmds: [ | ||
AlterTableCmd( | ||
AlterTableCmd { | ||
subtype: ColumnDefault, | ||
name: Some( | ||
"column_name", | ||
), | ||
def: Some( | ||
SQLValueFunction( | ||
Object({ | ||
"location": Number( | ||
73, | ||
), | ||
"op": Number( | ||
3, | ||
), | ||
"typmod": Number( | ||
-1, | ||
), | ||
}), | ||
), | ||
), | ||
behavior: Restrict, | ||
missing_ok: false, | ||
}, | ||
), | ||
], | ||
relation: RangeVar( | ||
RangeVar { | ||
catalogname: None, | ||
schemaname: None, | ||
relname: "table_name", | ||
inh: true, | ||
relpersistence: "p", | ||
alias: None, | ||
location: 21, | ||
}, | ||
), | ||
relkind: Table, | ||
missing_ok: false, | ||
}, | ||
), | ||
stmt_location: 0, | ||
stmt_len: Some( | ||
90, | ||
), | ||
}, | ||
), | ||
], | ||
) |