Skip to content

Commit e01b75e

Browse files
authored
pgmold-294: bump pgmold-sqlparser to 0.62.0 + adopt table_name rename (#272)
The 0.62.0 release (fmguerreiro/datafusion-sqlparser-rs#32) renames Statement::Comment.relation to table_name for consistency with sibling AST nodes (AlterPolicy.table_name, CreatePolicy.table_name, DropPolicy.table_name, AlterTrigger.table_name). pgmold-293's audit had concluded the bump was Cargo.toml-only because pgmold matched Statement::Comment { .. } without field-name destructure. That audit was stale: pgmold-273 (e860e3d) had since added a destructure that bound `relation`. This commit therefore also: - renames pgmold's internal CommentStatement.relation -> table_name to mirror the upstream AST. - aliases the field at the destructure site to `partner_table` so the Trigger arm's `let (table_schema, table_name) = extract_qualified_name(...)` doesn't shadow it. Discovered-from: pgmold-293.
1 parent 5eb828d commit e01b75e

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ categories = ["command-line-utilities", "database"]
1717
clap = { version = "4.5", features = ["derive", "env"] }
1818
tokio = { version = "1.35", features = ["full"] }
1919
sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "postgres"] }
20-
sqlparser = { package = "pgmold-sqlparser", version = "0.61.1", features = ["visitor"] }
20+
sqlparser = { package = "pgmold-sqlparser", version = "0.62.0", features = ["visitor"] }
2121
serde = { version = "1.0", features = ["derive"] }
2222
serde_json = "1.0"
2323
anyhow = "1.0"
@@ -37,11 +37,11 @@ sqlx = { version = "0.8", features = ["runtime-tokio-rustls", "postgres"] }
3737
tokio = { version = "1.35", features = ["full"] }
3838
assert_cmd = "2"
3939
criterion = { version = "0.5", features = ["html_reports"] }
40-
sqlparser = { package = "pgmold-sqlparser", version = "0.61.1", features = ["visitor"] }
40+
sqlparser = { package = "pgmold-sqlparser", version = "0.62.0", features = ["visitor"] }
4141

4242
[[bench]]
4343
name = "performance"
4444
harness = false
4545

4646
[build-dependencies]
47-
sqlparser = { package = "pgmold-sqlparser", version = "0.61.1", features = ["visitor"] }
47+
sqlparser = { package = "pgmold-sqlparser", version = "0.62.0", features = ["visitor"] }

src/parser/comments.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(super) struct CommentStatement<'a> {
3131
pub object_type: CommentObject,
3232
pub object_name: &'a ObjectName,
3333
pub arguments: Option<&'a [DataType]>,
34-
pub relation: Option<&'a ObjectName>,
34+
pub table_name: Option<&'a ObjectName>,
3535
pub comment: Option<String>,
3636
}
3737

@@ -47,7 +47,7 @@ pub(super) fn apply_comment_statement(
4747
object_type,
4848
object_name,
4949
arguments,
50-
relation,
50+
table_name: partner_table,
5151
comment,
5252
} = stmt;
5353

@@ -155,12 +155,12 @@ pub(super) fn apply_comment_statement(
155155
)));
156156
}
157157
let trigger_name = trigger_parts.into_iter().next().unwrap();
158-
let Some(relation) = relation else {
158+
let Some(partner_table) = partner_table else {
159159
return Err(SchemaError::ParseError(
160160
"COMMENT ON TRIGGER missing ON <table> tail".into(),
161161
));
162162
};
163-
let (table_schema, table_name) = extract_qualified_name(relation);
163+
let (table_schema, table_name) = extract_qualified_name(partner_table);
164164
let key = format!("{table_schema}.{table_name}.{trigger_name}");
165165
push(schema, PendingCommentObjectType::Trigger, key, comment);
166166
}
@@ -169,7 +169,7 @@ pub(super) fn apply_comment_statement(
169169
// these via its preprocess-stage scan and turn them into errors
170170
// under `--strict`.
171171
CommentObject::Policy => {
172-
let target = match relation {
172+
let target = match partner_table {
173173
Some(rel) => {
174174
let (rs, rn) = extract_qualified_name(rel);
175175
format!("{object_name} ON {rs}.{rn}")

src/parser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ fn parse_sql_string_inner(sql: &str) -> Result<Schema> {
13281328
object_type,
13291329
object_name,
13301330
arguments,
1331-
relation,
1331+
table_name,
13321332
comment,
13331333
if_exists: _,
13341334
} => {
@@ -1337,7 +1337,7 @@ fn parse_sql_string_inner(sql: &str) -> Result<Schema> {
13371337
object_type,
13381338
object_name: &object_name,
13391339
arguments: arguments.as_deref(),
1340-
relation: relation.as_ref(),
1340+
table_name: table_name.as_ref(),
13411341
comment,
13421342
},
13431343
&mut schema,

0 commit comments

Comments
 (0)