diff --git a/common/src/repositories_types/server/routes/api/example/example.http b/common/src/repositories_types/server/routes/api/example/example.http index d62c8a629..bddfe7f26 100644 --- a/common/src/repositories_types/server/routes/api/example/example.http +++ b/common/src/repositories_types/server/routes/api/example/example.http @@ -195,6 +195,22 @@ commit: 72a7f5c066a08a77fb91e75abee9f6e79e00e2b8 # } # }, # { + # "ValueIsContainedWithinRange": { + # "logical_operator": "Or", + # "value": [ + # 1970, + # 1, + # 0, + # 0, + # 0, + # 0, + # 0, + # 0, + # 0 + # ] + # } + # }, + # { # "IsNull": { # "logical_operator": "Or" # } @@ -204,37 +220,53 @@ commit: 72a7f5c066a08a77fb91e75abee9f6e79e00e2b8 "pg_range_time_offset_date_time_as_ts_tz_range_not_null": { "logical_operator": "Or", "value": [ + # { + # "Equal": { + # "logical_operator": "Or", + # "value": { + # "start": { + # "Included": [ + # 1970, + # 1, + # 0, + # 0, + # 0, + # 0, + # 0, + # 0, + # 0 + # ] + # }, + # "end": { + # "Included": [ + # 1970, + # 1, + # 0, + # 0, + # 0, + # 0, + # 0, + # 0, + # 0 + # ] + # } + # } + # } + # }, { - "Equal": { + "ValueIsContainedWithinRange": { "logical_operator": "Or", - "value": { - "start": { - "Included": [ - 1970, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - "end": { - "Included": [ - 1990, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - } - } + "value": [ + 1980, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] } } ] 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 f9bbe4a87..898297df1 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 @@ -4347,7 +4347,7 @@ 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!{SqlxTypesTimeOffsetDateTime}, + Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => quote::quote!{sqlx::types::time::OffsetDateTime}, } } } @@ -10013,35 +10013,35 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq } ); - // let value_is_contained_within_range_upper_camel_case = naming::ValueIsContainedWithinRangeUpperCamelCase; - // let postgresql_type_tokens_where_element_value_is_contained_within_range_token_stream = generate_postgresql_type_tokens_where_element_variant_token_stream( - // &ident, - // &value_is_contained_within_range_upper_camel_case, - // &is_nullable, - // ShouldWhereElementFieldsBePublic::True, - // "e::quote!{pub #value_snake_case: #range_type_token_stream}, - // "e::quote!{#value_snake_case: ::core::default::Default::default()}, - // "e::quote!{ - // match #increment_snake_case.checked_add(1) { - // Some(#value_snake_case) => { - // *#increment_snake_case = #value_snake_case; - // Ok(format!( - // "{}({} @> ${})", - // &self.logical_operator.to_query_part(is_need_to_add_logical_operator), - // #column_snake_case, - // #increment_snake_case - // )) - // }, - // None => Err(crate::#try_generate_bind_increments_error_named_upper_camel_case::#checked_add_upper_camel_case { - // code_occurence: error_occurence_lib::code_occurence!(), - // }) - // } - // }, - // "e::quote!{ - // #query_snake_case = #query_snake_case.bind(self.#value_snake_case); - // #query_snake_case - // } - // ); + let value_is_contained_within_range_upper_camel_case = naming::ValueIsContainedWithinRangeUpperCamelCase; + let postgresql_type_tokens_where_element_value_is_contained_within_range_token_stream = generate_postgresql_type_tokens_where_element_variant_token_stream( + &ident, + &value_is_contained_within_range_upper_camel_case, + &is_nullable, + ShouldWhereElementFieldsBePublic::True, + "e::quote!{pub #value_snake_case: #range_type_token_stream}, + "e::quote!{#value_snake_case: sqlx::types::time::OffsetDateTime::UNIX_EPOCH},//here + "e::quote!{ + match #increment_snake_case.checked_add(1) { + Some(#value_snake_case) => { + *#increment_snake_case = #value_snake_case; + Ok(format!( + "{}({} @> ${})", + &self.logical_operator.to_query_part(is_need_to_add_logical_operator), + #column_snake_case, + #increment_snake_case + )) + }, + None => Err(crate::#try_generate_bind_increments_error_named_upper_camel_case::#checked_add_upper_camel_case { + code_occurence: error_occurence_lib::code_occurence!(), + }) + } + }, + "e::quote!{ + #query_snake_case = #query_snake_case.bind(self.#value_snake_case); + #query_snake_case + } + ); // let contains_another_range_upper_camel_case = naming::ContainsAnotherRangeUpperCamelCase; // let postgresql_type_tokens_where_element_contains_another_range_token_stream = generate_postgresql_type_tokens_where_element_variant_token_stream( @@ -10605,7 +10605,7 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq &{ let mut value: std::vec::Vec<&dyn quote::ToTokens> = vec![ &equal_upper_camel_case, - // &value_is_contained_within_range_upper_camel_case, + &value_is_contained_within_range_upper_camel_case, // &contains_another_range_upper_camel_case, // &strictly_to_left_of_range_upper_camel_case, // &strictly_to_right_of_range_upper_camel_case, @@ -10625,7 +10625,7 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq #maybe_postgresql_type_tokens_where_element_is_null_token_stream #postgresql_type_tokens_where_element_equal_token_stream - // #postgresql_type_tokens_where_element_value_is_contained_within_range_token_stream + #postgresql_type_tokens_where_element_value_is_contained_within_range_token_stream // #postgresql_type_tokens_where_element_contains_another_range_token_stream // #postgresql_type_tokens_where_element_strictly_to_left_of_range_token_stream // #postgresql_type_tokens_where_element_strictly_to_right_of_range_token_stream