diff --git a/CHANGELOG.md b/CHANGELOG.md index bd07ee5a..12e4a1f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## v0.24.1 - 2023-10-24 + +### Fixed + +- support parsing `alter table set` statements (#321) + ## v0.24.0 - 2023-04-11 ### Added diff --git a/Cargo.lock b/Cargo.lock index e2cdf8ec..48b8c520 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1595,7 +1595,7 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "squawk" -version = "0.24.0" +version = "0.24.1" dependencies = [ "atty", "base64 0.12.3", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 71494adb..3ea7020b 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk" -version = "0.24.0" +version = "0.24.1" authors = ["Steve Dignam "] edition = "2018" license = "GPL-3.0" diff --git a/flake.nix b/flake.nix index 5e1638a5..27ea73f5 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ { squawk = final.rustPlatform.buildRustPackage { pname = "squawk"; - version = "0.24.0"; + version = "0.24.1"; cargoLock = { lockFile = ./Cargo.lock; diff --git a/package.json b/package.json index a694cfd7..0fc1431b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squawk-cli", - "version": "0.24.0", + "version": "0.24.1", "description": "linter for PostgreSQL, focused on migrations", "repository": "git@github.com:sbdchd/squawk.git", "author": "Steve Dignam ", diff --git a/parser/src/ast.rs b/parser/src/ast.rs index 2a68a456..8278af1b 100644 --- a/parser/src/ast.rs +++ b/parser/src/ast.rs @@ -663,6 +663,7 @@ pub enum AlterTableDef { Constant(Value), ReplicaIdentityStmt(Value), SQLValueFunction(Value), + List(Value), PartitionCmd(Value), } diff --git a/parser/src/parse.rs b/parser/src/parse.rs index 3f9532fe..6d7049aa 100644 --- a/parser/src/parse.rs +++ b/parser/src/parse.rs @@ -249,6 +249,13 @@ ALTER TABLE "legacy_questiongrouppg" assert_debug_snapshot!(res); } + #[test] + fn test_parse_alter_table_set_list() { + let sql = "ALTER TABLE table_name SET (autovacuum_vacuum_scale_factor = 0.0);"; + let res = parse_sql_query(sql); + assert_debug_snapshot!(res); + } + #[test] fn test_parse_alter_collation_stmt() { let sql = "ALTER COLLATION name RENAME TO new_name;"; diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap new file mode 100644 index 00000000..c9f7d74b --- /dev/null +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap @@ -0,0 +1,67 @@ +--- +source: parser/src/parse.rs +expression: res +--- +Ok( + [ + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: SetRelOptions, + name: None, + def: Some( + List( + Object({ + "items": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Float": Object({ + "fval": String( + "0.0", + ), + }), + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "autovacuum_vacuum_scale_factor", + ), + "location": Number( + 28, + ), + }), + }), + ]), + }), + ), + ), + behavior: Restrict, + missing_ok: false, + }, + ), + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + objtype: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 65, + ), + }, + ], +)