Skip to content

Commit

Permalink
fix alter table set (#321)
Browse files Browse the repository at this point in the history
fixes #320
  • Loading branch information
chdsbd authored Oct 25, 2023
1 parent eb7ede1 commit e6983b4
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "squawk"
version = "0.24.0"
version = "0.24.1"
authors = ["Steve Dignam <steve@dignam.xyz>"]
edition = "2018"
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
squawk = final.rustPlatform.buildRustPackage {
pname = "squawk";
version = "0.24.0";
version = "0.24.1";

cargoLock = {
lockFile = ./Cargo.lock;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <steve@dignam.xyz>",
Expand Down
1 change: 1 addition & 0 deletions parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ pub enum AlterTableDef {
Constant(Value),
ReplicaIdentityStmt(Value),
SQLValueFunction(Value),
List(Value),
PartitionCmd(Value),
}

Expand Down
7 changes: 7 additions & 0 deletions parser/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;";
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
),
},
],
)

0 comments on commit e6983b4

Please sign in to comment.