From 264e14e0b9e684a2c21765e8fd10c0c02716748a Mon Sep 17 00:00:00 2001 From: kuqmua Date: Sun, 5 Jan 2025 14:16:18 +0300 Subject: [PATCH] next steps --- .../src/lib.rs | 46 +++---------------- .../postgresql_type/postgresql_base_type.rs | 13 ++++++ 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/postgresql_crud/postgresql_crud_common/postgresql_crud_types_macro_logic_reuse/src/lib.rs b/postgresql_crud/postgresql_crud_common/postgresql_crud_types_macro_logic_reuse/src/lib.rs index f6586f2b7..9293730bc 100644 --- a/postgresql_crud/postgresql_crud_common/postgresql_crud_types_macro_logic_reuse/src/lib.rs +++ b/postgresql_crud/postgresql_crud_common/postgresql_crud_types_macro_logic_reuse/src/lib.rs @@ -4349,15 +4349,9 @@ impl RangeType { Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDateTime => quote::quote!{sqlx::types::chrono::NaiveDateTime}, Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDate => quote::quote!{sqlx::types::chrono::NaiveDate}, Self::SqlxPostgresTypesPgRangeSqlxTypesDecimal => quote::quote!{sqlx::types::Decimal}, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => quote::quote!{ - sqlx::types::time::OffsetDateTime - }, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime => quote::quote!{ - sqlx::types::time::PrimitiveDateTime - }, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimeDate => quote::quote!{ - SqlxTypesTimeDate - }, + Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => quote::quote!{SqlxTypesTimeOffsetDateTime}, + Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime => quote::quote!{SqlxTypesTimePrimitiveDateTime}, + Self::SqlxPostgresTypesPgRangeSqlxTypesTimeDate => quote::quote!{SqlxTypesTimeDate}, } } fn should_impl_range_length(&self) -> ShouldImplRangeLength { @@ -4383,39 +4377,13 @@ impl RangeType { Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDateTime | Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDate | Self::SqlxPostgresTypesPgRangeSqlxTypesDecimal => quote::quote!{::core::default::Default::default()}, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => quote::quote!{ - sqlx::types::time::OffsetDateTime::UNIX_EPOCH - }, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime => quote::quote!{ - sqlx::types::time::PrimitiveDateTime::new( - sqlx::types::time::Date::from_ordinal_date( - ::core::default::Default::default(), - 1, - ).unwrap(),//todo - sqlx::types::time::Time::MIDNIGHT, - ) - - - }, + Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime | + Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime | Self::SqlxPostgresTypesPgRangeSqlxTypesTimeDate => quote::quote!{ crate::generate_postgresql_json_type::StdDefaultDefaultButStdOptionOptionIsAlwaysSomeAndStdVecVecAlwaysContainsOneElement::std_default_default_but_std_option_option_is_always_some_and_std_vec_vec_always_contains_one_element() }, } } - fn serde_based_on_wrapper_type(&self) -> std::option::Option { - match &self { - Self::I32 | - Self::I64 | - Self::SqlxTypesChronoDateTimeSqlxTypesChronoUtc | - Self::SqlxTypesChronoDateTimeSqlxTypesChronoLocal | - Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDateTime | - Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDate | - Self::SqlxPostgresTypesPgRangeSqlxTypesDecimal => None, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => Some(quote::quote!{}), - Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime => Some(quote::quote!{}), - Self::SqlxPostgresTypesPgRangeSqlxTypesTimeDate => Some(quote::quote!{}), - } - } fn postgresql_type_self_where_bind_value_to_query_parameter_token_stream(&self) -> proc_macro2::TokenStream { match &self { Self::I32 | @@ -4425,8 +4393,8 @@ impl RangeType { Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDateTime | Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDate | Self::SqlxPostgresTypesPgRangeSqlxTypesDecimal => proc_macro2::TokenStream::new(), - Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => quote::quote!{}, - Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime => quote::quote!{}, + Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime | + Self::SqlxPostgresTypesPgRangeSqlxTypesTimePrimitiveDateTime | Self::SqlxPostgresTypesPgRangeSqlxTypesTimeDate => quote::quote!{.0}, } } diff --git a/postgresql_crud/postgresql_crud_common/src/postgresql_type/postgresql_base_type.rs b/postgresql_crud/postgresql_crud_common/src/postgresql_type/postgresql_base_type.rs index 600974950..8e6dc9fc1 100644 --- a/postgresql_crud/postgresql_crud_common/src/postgresql_type/postgresql_base_type.rs +++ b/postgresql_crud/postgresql_crud_common/src/postgresql_type/postgresql_base_type.rs @@ -3702,9 +3702,22 @@ const _: () = { }; +// #[derive( +// Debug, +// Clone, +// PartialEq, +// Eq, +// // postgresql_crud_types_macro_logic_reuse::PostgresqlBaseTypeTokensSqlxPostgresTypesPgRangeSqlxTypesBigDecimal, +// // postgresql_crud_types_macro_logic_reuse::PostgresqlBaseTypeTokensWhereElementSqlxPostgresTypesPgRangeSqlxTypesBigDecimal, +// )] // pub struct SqlxPostgresTypesPgRangeSqlxTypesBigDecimal(pub sqlx::postgres::types::PgRange); + + + + + // pub struct SqlxPostgresTypesPgMoney(pub sqlx::postgres::types::PgMoney); // pub struct SqlxPostgresTypesPgCiText(pub sqlx::postgres::types::PgCiText);