Skip to content

Prost upgrade followup #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod node_mut;
mod node_ref;
mod node_structs;
mod parse_result;
#[rustfmt::skip]
pub mod protobuf;
mod query;
mod truncate;
Expand Down
28 changes: 14 additions & 14 deletions src/node_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,39 @@ impl NodeEnum {
}
});
}
match protobuf::SetOperation::from_i32(s.op) {
Some(protobuf::SetOperation::SetopNone) => {
match protobuf::SetOperation::try_from(s.op) {
Ok(protobuf::SetOperation::SetopNone) => {
s.from_clause.iter().for_each(|n| {
if let Some(n) = n.node.as_ref() {
iter.push((n.to_ref(), depth, Context::Select, false));
}
});
}
Some(protobuf::SetOperation::SetopUnion) => {
Ok(protobuf::SetOperation::SetopUnion) => {
if let Some(left) = s.larg.as_ref() {
iter.push((left.to_ref(), depth, Context::Select, false));
}
if let Some(right) = s.rarg.as_ref() {
iter.push((right.to_ref(), depth, Context::Select, false));
}
}
Some(protobuf::SetOperation::SetopExcept) => {
Ok(protobuf::SetOperation::SetopExcept) => {
if let Some(left) = s.larg.as_ref() {
iter.push((left.to_ref(), depth, Context::Select, false));
}
if let Some(right) = s.rarg.as_ref() {
iter.push((right.to_ref(), depth, Context::Select, false));
}
}
Some(protobuf::SetOperation::SetopIntersect) => {
Ok(protobuf::SetOperation::SetopIntersect) => {
if let Some(left) = s.larg.as_ref() {
iter.push((left.to_ref(), depth, Context::Select, false));
}
if let Some(right) = s.rarg.as_ref() {
iter.push((right.to_ref(), depth, Context::Select, false));
}
}
Some(protobuf::SetOperation::Undefined) | None => (),
Ok(protobuf::SetOperation::Undefined) | Err(_) => (),
}
}
NodeRef::InsertStmt(s) => {
Expand Down Expand Up @@ -267,7 +267,7 @@ impl NodeEnum {
}
}
NodeRef::GrantStmt(s) => {
if let Some(protobuf::ObjectType::ObjectTable) = protobuf::ObjectType::from_i32(s.objtype) {
if let Ok(protobuf::ObjectType::ObjectTable) = protobuf::ObjectType::try_from(s.objtype) {
s.objects.iter().for_each(|n| {
if let Some(n) = n.node.as_ref() {
iter.push((n.to_ref(), depth, Context::DDL, false));
Expand Down Expand Up @@ -495,39 +495,39 @@ impl NodeEnum {
}
});
}
match protobuf::SetOperation::from_i32(s.op) {
Some(protobuf::SetOperation::SetopNone) => {
match protobuf::SetOperation::try_from(s.op) {
Ok(protobuf::SetOperation::SetopNone) => {
s.from_clause.iter_mut().for_each(|n| {
if let Some(n) = n.node.as_mut() {
iter.push((n.to_mut(), depth, Context::Select));
}
});
}
Some(protobuf::SetOperation::SetopUnion) => {
Ok(protobuf::SetOperation::SetopUnion) => {
if let Some(left) = s.larg.as_mut() {
iter.push((left.to_mut(), depth, Context::Select));
}
if let Some(right) = s.rarg.as_mut() {
iter.push((right.to_mut(), depth, Context::Select));
}
}
Some(protobuf::SetOperation::SetopExcept) => {
Ok(protobuf::SetOperation::SetopExcept) => {
if let Some(left) = s.larg.as_mut() {
iter.push((left.to_mut(), depth, Context::Select));
}
if let Some(right) = s.rarg.as_mut() {
iter.push((right.to_mut(), depth, Context::Select));
}
}
Some(protobuf::SetOperation::SetopIntersect) => {
Ok(protobuf::SetOperation::SetopIntersect) => {
if let Some(left) = s.larg.as_mut() {
iter.push((left.to_mut(), depth, Context::Select));
}
if let Some(right) = s.rarg.as_mut() {
iter.push((right.to_mut(), depth, Context::Select));
}
}
Some(protobuf::SetOperation::Undefined) | None => (),
Ok(protobuf::SetOperation::Undefined) | Err(_) => (),
}
}
NodeMut::InsertStmt(s) => {
Expand Down Expand Up @@ -711,7 +711,7 @@ impl NodeEnum {
}
NodeMut::GrantStmt(s) => {
let s = s.as_mut().unwrap();
if let Some(protobuf::ObjectType::ObjectTable) = protobuf::ObjectType::from_i32(s.objtype) {
if let Ok(protobuf::ObjectType::ObjectTable) = protobuf::ObjectType::try_from(s.objtype) {
s.objects.iter_mut().for_each(|n| {
if let Some(n) = n.node.as_mut() {
iter.push((n.to_mut(), depth, Context::DDL));
Expand Down
10 changes: 5 additions & 5 deletions src/parse_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ impl ParseResult {
functions.insert((funcname, Context::Call));
}
NodeRef::DropStmt(s) => {
match protobuf::ObjectType::from_i32(s.remove_type) {
Some(protobuf::ObjectType::ObjectTable) => {
match protobuf::ObjectType::try_from(s.remove_type) {
Ok(protobuf::ObjectType::ObjectTable) => {
for o in &s.objects {
if let Some(NodeEnum::List(list)) = &o.node {
let table =
Expand All @@ -101,7 +101,7 @@ impl ParseResult {
};
}
}
Some(protobuf::ObjectType::ObjectRule) | Some(protobuf::ObjectType::ObjectTrigger) => {
Ok(protobuf::ObjectType::ObjectRule) | Ok(protobuf::ObjectType::ObjectTrigger) => {
for o in &s.objects {
if let Some(NodeEnum::List(list)) = &o.node {
// Unlike ObjectTable, this ignores the last string (the rule/trigger name)
Expand All @@ -115,7 +115,7 @@ impl ParseResult {
};
}
}
Some(protobuf::ObjectType::ObjectFunction) => {
Ok(protobuf::ObjectType::ObjectFunction) => {
// Only one function can be dropped in a statement
if let Some(NodeEnum::ObjectWithArgs(object)) = &s.objects[0].node {
if let Some(NodeEnum::String(string)) = &object.objname[0].node {
Expand All @@ -132,7 +132,7 @@ impl ParseResult {
}
}
NodeRef::RenameStmt(s) => {
if let Some(protobuf::ObjectType::ObjectFunction) = protobuf::ObjectType::from_i32(s.rename_type) {
if let Ok(protobuf::ObjectType::ObjectFunction) = protobuf::ObjectType::try_from(s.rename_type) {
if let Some(object) = &s.object {
if let Some(NodeEnum::ObjectWithArgs(object)) = &object.node {
if let Some(NodeEnum::String(string)) = &object.objname[0].node {
Expand Down
72 changes: 54 additions & 18 deletions src/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ pub mod node {
#[prost(message, tag = "9")]
WindowFunc(::prost::alloc::boxed::Box<super::WindowFunc>),
#[prost(message, tag = "10")]
WindowFuncRunCondition(::prost::alloc::boxed::Box<super::WindowFuncRunCondition>),
WindowFuncRunCondition(
::prost::alloc::boxed::Box<super::WindowFuncRunCondition>,
),
#[prost(message, tag = "11")]
MergeSupportFunc(::prost::alloc::boxed::Box<super::MergeSupportFunc>),
#[prost(message, tag = "12")]
Expand Down Expand Up @@ -278,7 +280,9 @@ pub mod node {
#[prost(message, tag = "126")]
JsonArrayConstructor(super::JsonArrayConstructor),
#[prost(message, tag = "127")]
JsonArrayQueryConstructor(::prost::alloc::boxed::Box<super::JsonArrayQueryConstructor>),
JsonArrayQueryConstructor(
::prost::alloc::boxed::Box<super::JsonArrayQueryConstructor>,
),
#[prost(message, tag = "128")]
JsonAggConstructor(::prost::alloc::boxed::Box<super::JsonAggConstructor>),
#[prost(message, tag = "129")]
Expand Down Expand Up @@ -348,7 +352,9 @@ pub mod node {
#[prost(message, tag = "161")]
AlterExtensionStmt(super::AlterExtensionStmt),
#[prost(message, tag = "162")]
AlterExtensionContentsStmt(::prost::alloc::boxed::Box<super::AlterExtensionContentsStmt>),
AlterExtensionContentsStmt(
::prost::alloc::boxed::Box<super::AlterExtensionContentsStmt>,
),
#[prost(message, tag = "163")]
CreateFdwStmt(super::CreateFdwStmt),
#[prost(message, tag = "164")]
Expand Down Expand Up @@ -444,7 +450,9 @@ pub mod node {
#[prost(message, tag = "209")]
RenameStmt(::prost::alloc::boxed::Box<super::RenameStmt>),
#[prost(message, tag = "210")]
AlterObjectDependsStmt(::prost::alloc::boxed::Box<super::AlterObjectDependsStmt>),
AlterObjectDependsStmt(
::prost::alloc::boxed::Box<super::AlterObjectDependsStmt>,
),
#[prost(message, tag = "211")]
AlterObjectSchemaStmt(::prost::alloc::boxed::Box<super::AlterObjectSchemaStmt>),
#[prost(message, tag = "212")]
Expand Down Expand Up @@ -2156,7 +2164,9 @@ pub struct RangeTblEntry {
#[prost(uint32, tag = "8")]
pub perminfoindex: u32,
#[prost(message, optional, boxed, tag = "9")]
pub tablesample: ::core::option::Option<::prost::alloc::boxed::Box<TableSampleClause>>,
pub tablesample: ::core::option::Option<
::prost::alloc::boxed::Box<TableSampleClause>,
>,
#[prost(message, optional, boxed, tag = "10")]
pub subquery: ::core::option::Option<::prost::alloc::boxed::Box<Query>>,
#[prost(bool, tag = "11")]
Expand Down Expand Up @@ -2627,7 +2637,9 @@ pub struct JsonAggConstructor {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct JsonObjectAgg {
#[prost(message, optional, boxed, tag = "1")]
pub constructor: ::core::option::Option<::prost::alloc::boxed::Box<JsonAggConstructor>>,
pub constructor: ::core::option::Option<
::prost::alloc::boxed::Box<JsonAggConstructor>,
>,
#[prost(message, optional, boxed, tag = "2")]
pub arg: ::core::option::Option<::prost::alloc::boxed::Box<JsonKeyValue>>,
#[prost(bool, tag = "3")]
Expand All @@ -2638,7 +2650,9 @@ pub struct JsonObjectAgg {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct JsonArrayAgg {
#[prost(message, optional, boxed, tag = "1")]
pub constructor: ::core::option::Option<::prost::alloc::boxed::Box<JsonAggConstructor>>,
pub constructor: ::core::option::Option<
::prost::alloc::boxed::Box<JsonAggConstructor>,
>,
#[prost(message, optional, boxed, tag = "2")]
pub arg: ::core::option::Option<::prost::alloc::boxed::Box<JsonValueExpr>>,
#[prost(bool, tag = "3")]
Expand All @@ -2662,7 +2676,9 @@ pub struct InsertStmt {
#[prost(message, optional, boxed, tag = "3")]
pub select_stmt: ::core::option::Option<::prost::alloc::boxed::Box<Node>>,
#[prost(message, optional, boxed, tag = "4")]
pub on_conflict_clause: ::core::option::Option<::prost::alloc::boxed::Box<OnConflictClause>>,
pub on_conflict_clause: ::core::option::Option<
::prost::alloc::boxed::Box<OnConflictClause>,
>,
#[prost(message, repeated, tag = "5")]
pub returning_list: ::prost::alloc::vec::Vec<Node>,
#[prost(message, optional, tag = "6")]
Expand Down Expand Up @@ -5710,9 +5726,13 @@ impl AlterTsConfigType {
match self {
Self::AlterTsconfigTypeUndefined => "ALTER_TSCONFIG_TYPE_UNDEFINED",
Self::AlterTsconfigAddMapping => "ALTER_TSCONFIG_ADD_MAPPING",
Self::AlterTsconfigAlterMappingForToken => "ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN",
Self::AlterTsconfigAlterMappingForToken => {
"ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN"
}
Self::AlterTsconfigReplaceDict => "ALTER_TSCONFIG_REPLACE_DICT",
Self::AlterTsconfigReplaceDictForToken => "ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN",
Self::AlterTsconfigReplaceDictForToken => {
"ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN"
}
Self::AlterTsconfigDropMapping => "ALTER_TSCONFIG_DROP_MAPPING",
}
}
Expand All @@ -5721,9 +5741,13 @@ impl AlterTsConfigType {
match value {
"ALTER_TSCONFIG_TYPE_UNDEFINED" => Some(Self::AlterTsconfigTypeUndefined),
"ALTER_TSCONFIG_ADD_MAPPING" => Some(Self::AlterTsconfigAddMapping),
"ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN" => Some(Self::AlterTsconfigAlterMappingForToken),
"ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN" => {
Some(Self::AlterTsconfigAlterMappingForToken)
}
"ALTER_TSCONFIG_REPLACE_DICT" => Some(Self::AlterTsconfigReplaceDict),
"ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN" => Some(Self::AlterTsconfigReplaceDictForToken),
"ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN" => {
Some(Self::AlterTsconfigReplaceDictForToken)
}
"ALTER_TSCONFIG_DROP_MAPPING" => Some(Self::AlterTsconfigDropMapping),
_ => None,
}
Expand All @@ -5748,7 +5772,9 @@ impl PublicationObjSpecType {
Self::Undefined => "PUBLICATION_OBJ_SPEC_TYPE_UNDEFINED",
Self::PublicationobjTable => "PUBLICATIONOBJ_TABLE",
Self::PublicationobjTablesInSchema => "PUBLICATIONOBJ_TABLES_IN_SCHEMA",
Self::PublicationobjTablesInCurSchema => "PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA",
Self::PublicationobjTablesInCurSchema => {
"PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA"
}
Self::PublicationobjContinuation => "PUBLICATIONOBJ_CONTINUATION",
}
}
Expand All @@ -5758,7 +5784,9 @@ impl PublicationObjSpecType {
"PUBLICATION_OBJ_SPEC_TYPE_UNDEFINED" => Some(Self::Undefined),
"PUBLICATIONOBJ_TABLE" => Some(Self::PublicationobjTable),
"PUBLICATIONOBJ_TABLES_IN_SCHEMA" => Some(Self::PublicationobjTablesInSchema),
"PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA" => Some(Self::PublicationobjTablesInCurSchema),
"PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA" => {
Some(Self::PublicationobjTablesInCurSchema)
}
"PUBLICATIONOBJ_CONTINUATION" => Some(Self::PublicationobjContinuation),
_ => None,
}
Expand Down Expand Up @@ -5821,7 +5849,9 @@ impl AlterSubscriptionType {
Self::AlterSubscriptionConnection => "ALTER_SUBSCRIPTION_CONNECTION",
Self::AlterSubscriptionSetPublication => "ALTER_SUBSCRIPTION_SET_PUBLICATION",
Self::AlterSubscriptionAddPublication => "ALTER_SUBSCRIPTION_ADD_PUBLICATION",
Self::AlterSubscriptionDropPublication => "ALTER_SUBSCRIPTION_DROP_PUBLICATION",
Self::AlterSubscriptionDropPublication => {
"ALTER_SUBSCRIPTION_DROP_PUBLICATION"
}
Self::AlterSubscriptionRefresh => "ALTER_SUBSCRIPTION_REFRESH",
Self::AlterSubscriptionEnabled => "ALTER_SUBSCRIPTION_ENABLED",
Self::AlterSubscriptionSkip => "ALTER_SUBSCRIPTION_SKIP",
Expand All @@ -5833,9 +5863,15 @@ impl AlterSubscriptionType {
"ALTER_SUBSCRIPTION_TYPE_UNDEFINED" => Some(Self::Undefined),
"ALTER_SUBSCRIPTION_OPTIONS" => Some(Self::AlterSubscriptionOptions),
"ALTER_SUBSCRIPTION_CONNECTION" => Some(Self::AlterSubscriptionConnection),
"ALTER_SUBSCRIPTION_SET_PUBLICATION" => Some(Self::AlterSubscriptionSetPublication),
"ALTER_SUBSCRIPTION_ADD_PUBLICATION" => Some(Self::AlterSubscriptionAddPublication),
"ALTER_SUBSCRIPTION_DROP_PUBLICATION" => Some(Self::AlterSubscriptionDropPublication),
"ALTER_SUBSCRIPTION_SET_PUBLICATION" => {
Some(Self::AlterSubscriptionSetPublication)
}
"ALTER_SUBSCRIPTION_ADD_PUBLICATION" => {
Some(Self::AlterSubscriptionAddPublication)
}
"ALTER_SUBSCRIPTION_DROP_PUBLICATION" => {
Some(Self::AlterSubscriptionDropPublication)
}
"ALTER_SUBSCRIPTION_REFRESH" => Some(Self::AlterSubscriptionRefresh),
"ALTER_SUBSCRIPTION_ENABLED" => Some(Self::AlterSubscriptionEnabled),
"ALTER_SUBSCRIPTION_SKIP" => Some(Self::AlterSubscriptionSkip),
Expand Down