From cc4f1cc8e411972b42670f8d7a6c1666cc907753 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Mon, 27 Nov 2023 12:31:21 -0500 Subject: [PATCH 1/3] Prepare for 0.40.0 release, derive 0.2.0 release --- CHANGELOG.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- derive/Cargo.toml | 2 +- derive/README.md | 16 +++++++++++ derive/src/lib.rs | 53 +++++++++++++++++++++++------------- 5 files changed, 121 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ec3cc7b..2f2c27d72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,75 @@ Given that the parser produces a typed AST, any changes to the AST will technica ## [Unreleased] Check https://github.com/sqlparser-rs/sqlparser-rs/commits/main for undocumented changes. + +## [0.40.0] 2023-11-27 + + +Document round trip ability (#1052) + +@alamb +alamb committed now +add {pre,post}_visit_query to Visitor (#1044) + +@jmhain +jmhain committed 19 minutes ago +Commits on Nov 22, 2023 +Add support for generated virtual columns with expression (#1051) + +@takluyver +takluyver committed 5 days ago +Commits on Nov 21, 2023 +Adds support for PostgreSQL "END" (#1035) + +@tobyhede +tobyhede committed last week +Support INSERT INTO ... DEFAULT VALUES ... (#1036) + +@CDThomas +CDThomas committed last week +Commits on Nov 20, 2023 +Add support for release and rollback to savepoint syntax (#1045) + +@CDThomas +CDThomas committed last week +Support CONVERT expressions (#1048) + +@lovasoa +lovasoa committed last week +Support global and session parts in show variables for mysql and gene… + +@emin100 +emin100 committed last week +snowflake: PIVOT on derived table factors (#1027) + +@lustefaniak +lustefaniak committed last week +Fix extra whitespace printed before ON CONFLICT (#1037) + +@CDThomas +CDThomas committed last week +Commits on Nov 18, 2023 +Add PRQLto list of users (#1031) + +@vanillajonathan +@alamb +vanillajonathan and alamb committed last week +Support mssql json and xml extensions (#1043) + +@lovasoa +lovasoa committed last week +Commits on Nov 10, 2023 +add support for MAX as a character length (#1038) + +@lovasoa +lovasoa committed 2 weeks ago +Commits on Oct 29, 2023 +Support IN () syntax of SQLite, alternate proposal (#1028) + +@alamb +alamb committed last month + + ## [0.39.0] 2023-10-27 ### Added diff --git a/Cargo.toml b/Cargo.toml index 0af327595..7b6df2842 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ serde = { version = "1.0", features = ["derive"], optional = true } # of dev-dependencies because of # https://github.com/rust-lang/cargo/issues/1596 serde_json = { version = "1.0", optional = true } -sqlparser_derive = { version = "0.1.1", path = "derive", optional = true } +sqlparser_derive = { version = "0.2.0", path = "derive", optional = true } [dev-dependencies] simple_logger = "4.0" diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 58e1fbf57..a40ccb2a2 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sqlparser_derive" description = "proc macro for sqlparser" -version = "0.1.1" +version = "0.2.0" authors = ["sqlparser-rs authors"] homepage = "https://github.com/sqlparser-rs/sqlparser-rs" documentation = "https://docs.rs/sqlparser_derive/" diff --git a/derive/README.md b/derive/README.md index aadf99818..ad4978a89 100644 --- a/derive/README.md +++ b/derive/README.md @@ -131,3 +131,19 @@ visitor.post_visit_expr() visitor.post_visit_expr() visitor.post_visit_expr() ``` + +## Releasing + +This crate's release is not automated. Instead it is released manually as needed + +Steps: +1. Update the version in `Cargo.toml` +2. Update the corresponding version in `../Cargo.toml` +3. Commit via PR +4. Publish to crates.io: + +```shell +# update to latest checked in main branch and publish via +cargo publish +``` + diff --git a/derive/src/lib.rs b/derive/src/lib.rs index fbc3ef2e1..43f406648 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -6,25 +6,30 @@ use syn::{ Ident, Index, Lit, Meta, MetaNameValue, NestedMeta, }; - /// Implementation of `[#derive(Visit)]` #[proc_macro_derive(VisitMut, attributes(visit))] pub fn derive_visit_mut(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - derive_visit(input, &VisitType { - visit_trait: quote!(VisitMut), - visitor_trait: quote!(VisitorMut), - modifier: Some(quote!(mut)), - }) + derive_visit( + input, + &VisitType { + visit_trait: quote!(VisitMut), + visitor_trait: quote!(VisitorMut), + modifier: Some(quote!(mut)), + }, + ) } /// Implementation of `[#derive(Visit)]` #[proc_macro_derive(Visit, attributes(visit))] pub fn derive_visit_immutable(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - derive_visit(input, &VisitType { - visit_trait: quote!(Visit), - visitor_trait: quote!(Visitor), - modifier: None, - }) + derive_visit( + input, + &VisitType { + visit_trait: quote!(Visit), + visitor_trait: quote!(Visitor), + modifier: None, + }, + ) } struct VisitType { @@ -33,15 +38,16 @@ struct VisitType { modifier: Option, } -fn derive_visit( - input: proc_macro::TokenStream, - visit_type: &VisitType, -) -> proc_macro::TokenStream { +fn derive_visit(input: proc_macro::TokenStream, visit_type: &VisitType) -> proc_macro::TokenStream { // Parse the input tokens into a syntax tree. let input = parse_macro_input!(input as DeriveInput); let name = input.ident; - let VisitType { visit_trait, visitor_trait, modifier } = visit_type; + let VisitType { + visit_trait, + visitor_trait, + modifier, + } = visit_type; let attributes = Attributes::parse(&input.attrs); // Add a bound `T: Visit` to every type parameter T. @@ -125,17 +131,26 @@ impl Attributes { } // Add a bound `T: Visit` to every type parameter T. -fn add_trait_bounds(mut generics: Generics, VisitType{visit_trait, ..}: &VisitType) -> Generics { +fn add_trait_bounds(mut generics: Generics, VisitType { visit_trait, .. }: &VisitType) -> Generics { for param in &mut generics.params { if let GenericParam::Type(ref mut type_param) = *param { - type_param.bounds.push(parse_quote!(sqlparser::ast::#visit_trait)); + type_param + .bounds + .push(parse_quote!(sqlparser::ast::#visit_trait)); } } generics } // Generate the body of the visit implementation for the given type -fn visit_children(data: &Data, VisitType{visit_trait, modifier, ..}: &VisitType) -> TokenStream { +fn visit_children( + data: &Data, + VisitType { + visit_trait, + modifier, + .. + }: &VisitType, +) -> TokenStream { match data { Data::Struct(data) => match &data.fields { Fields::Named(fields) => { From a8a2c4e8087d01f82cd4493cbae0a1dd6d59e015 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Mon, 27 Nov 2023 12:37:25 -0500 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 80 +++++++++++----------------------------------------- 1 file changed, 17 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f2c27d72..540b55dd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,71 +11,25 @@ Check https://github.com/sqlparser-rs/sqlparser-rs/commits/main for undocumented ## [0.40.0] 2023-11-27 +### Added +* Add `{pre,post}_visit_query` to `Visitor` (#1044) - Thanks @jmhain +* Support generated virtual columns with expression (#1051) - Thanks @takluyver +* Support PostgreSQL `END` (#1035) - Thanks @tobyhede +* Support `INSERT INTO ... DEFAULT VALUES ...` (#1036) - Thanks @CDThomas +* Support `RELEASE` and `ROLLBACK TO SAVEPOINT` (#1045) - Thanks @CDThomas +* Support `CONVERT` expressions (#1048) - Thanks @lovasoa +* Support `GLOBAL` and `SESSION` parts in `SHOW VARIABLES` for mysql and generic - Thanks @emin100 +* Support snowflake `PIVOT` on derived table factors (#1027) - Thanks @lustefaniak +* Support mssql json and xml extensions (#1043) - Thanks @lovasoa +* Support for `MAX` as a character length (#1038) - Thanks @lovasoa +* Support `IN ()` syntax of SQLite (#1028) - Thanks @alamb -Document round trip ability (#1052) - -@alamb -alamb committed now -add {pre,post}_visit_query to Visitor (#1044) - -@jmhain -jmhain committed 19 minutes ago -Commits on Nov 22, 2023 -Add support for generated virtual columns with expression (#1051) - -@takluyver -takluyver committed 5 days ago -Commits on Nov 21, 2023 -Adds support for PostgreSQL "END" (#1035) - -@tobyhede -tobyhede committed last week -Support INSERT INTO ... DEFAULT VALUES ... (#1036) - -@CDThomas -CDThomas committed last week -Commits on Nov 20, 2023 -Add support for release and rollback to savepoint syntax (#1045) - -@CDThomas -CDThomas committed last week -Support CONVERT expressions (#1048) - -@lovasoa -lovasoa committed last week -Support global and session parts in show variables for mysql and gene… - -@emin100 -emin100 committed last week -snowflake: PIVOT on derived table factors (#1027) - -@lustefaniak -lustefaniak committed last week -Fix extra whitespace printed before ON CONFLICT (#1037) - -@CDThomas -CDThomas committed last week -Commits on Nov 18, 2023 -Add PRQLto list of users (#1031) - -@vanillajonathan -@alamb -vanillajonathan and alamb committed last week -Support mssql json and xml extensions (#1043) - -@lovasoa -lovasoa committed last week -Commits on Nov 10, 2023 -add support for MAX as a character length (#1038) - -@lovasoa -lovasoa committed 2 weeks ago -Commits on Oct 29, 2023 -Support IN () syntax of SQLite, alternate proposal (#1028) - -@alamb -alamb committed last month +### Fixed +* Fix extra whitespace printed before `ON CONFLICT` (#1037) - Thanks @CDThomas +### Changed +* Document round trip ability (#1052) - Thanks @alamb +* Add PRQL to list of users (#1031) - Thanks @vanillajonathan ## [0.39.0] 2023-10-27 From 1474dd1f9406c9171eaa159599c9971a952bd037 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Mon, 27 Nov 2023 12:39:42 -0500 Subject: [PATCH 3/3] remove unintended change --- derive/src/lib.rs | 53 +++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/derive/src/lib.rs b/derive/src/lib.rs index 43f406648..fbc3ef2e1 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -6,30 +6,25 @@ use syn::{ Ident, Index, Lit, Meta, MetaNameValue, NestedMeta, }; + /// Implementation of `[#derive(Visit)]` #[proc_macro_derive(VisitMut, attributes(visit))] pub fn derive_visit_mut(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - derive_visit( - input, - &VisitType { - visit_trait: quote!(VisitMut), - visitor_trait: quote!(VisitorMut), - modifier: Some(quote!(mut)), - }, - ) + derive_visit(input, &VisitType { + visit_trait: quote!(VisitMut), + visitor_trait: quote!(VisitorMut), + modifier: Some(quote!(mut)), + }) } /// Implementation of `[#derive(Visit)]` #[proc_macro_derive(Visit, attributes(visit))] pub fn derive_visit_immutable(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - derive_visit( - input, - &VisitType { - visit_trait: quote!(Visit), - visitor_trait: quote!(Visitor), - modifier: None, - }, - ) + derive_visit(input, &VisitType { + visit_trait: quote!(Visit), + visitor_trait: quote!(Visitor), + modifier: None, + }) } struct VisitType { @@ -38,16 +33,15 @@ struct VisitType { modifier: Option, } -fn derive_visit(input: proc_macro::TokenStream, visit_type: &VisitType) -> proc_macro::TokenStream { +fn derive_visit( + input: proc_macro::TokenStream, + visit_type: &VisitType, +) -> proc_macro::TokenStream { // Parse the input tokens into a syntax tree. let input = parse_macro_input!(input as DeriveInput); let name = input.ident; - let VisitType { - visit_trait, - visitor_trait, - modifier, - } = visit_type; + let VisitType { visit_trait, visitor_trait, modifier } = visit_type; let attributes = Attributes::parse(&input.attrs); // Add a bound `T: Visit` to every type parameter T. @@ -131,26 +125,17 @@ impl Attributes { } // Add a bound `T: Visit` to every type parameter T. -fn add_trait_bounds(mut generics: Generics, VisitType { visit_trait, .. }: &VisitType) -> Generics { +fn add_trait_bounds(mut generics: Generics, VisitType{visit_trait, ..}: &VisitType) -> Generics { for param in &mut generics.params { if let GenericParam::Type(ref mut type_param) = *param { - type_param - .bounds - .push(parse_quote!(sqlparser::ast::#visit_trait)); + type_param.bounds.push(parse_quote!(sqlparser::ast::#visit_trait)); } } generics } // Generate the body of the visit implementation for the given type -fn visit_children( - data: &Data, - VisitType { - visit_trait, - modifier, - .. - }: &VisitType, -) -> TokenStream { +fn visit_children(data: &Data, VisitType{visit_trait, modifier, ..}: &VisitType) -> TokenStream { match data { Data::Struct(data) => match &data.fields { Fields::Named(fields) => {