Skip to content

Commit

Permalink
next steps
Browse files Browse the repository at this point in the history
  • Loading branch information
kuqmua committed Jan 4, 2025
1 parent f87ad25 commit a8955dd
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4350,6 +4350,18 @@ impl RangeType {
Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => quote::quote!{sqlx::types::time::OffsetDateTime},
}
}
fn should_impl_range_length(&self) -> ShouldImplRangeLength {
match &self {
Self::I32 => ShouldImplRangeLength::True,
Self::I64 => ShouldImplRangeLength::True,
Self::SqlxTypesChronoDateTimeSqlxTypesChronoUtc => ShouldImplRangeLength::False,
Self::SqlxTypesChronoDateTimeSqlxTypesChronoLocal => ShouldImplRangeLength::False,
Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDateTime => ShouldImplRangeLength::False,
Self::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDate => ShouldImplRangeLength::False,
Self::SqlxPostgresTypesPgRangeSqlxTypesDecimal => ShouldImplRangeLength::False,
Self::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime => ShouldImplRangeLength::False,
}
}
}
enum ShouldImplRangeLength {
True,
Expand All @@ -4358,14 +4370,14 @@ enum ShouldImplRangeLength {
fn generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input: proc_macro::TokenStream,
range_type: RangeType,
should_impl_range_length: ShouldImplRangeLength,
) -> proc_macro::TokenStream {
panic_location::panic_location();
let syn_derive_input: syn::DeriveInput = syn::parse(input).unwrap_or_else(|error| panic!("{}: {error}", constants::AST_PARSE_FAILED));
let ident = &syn_derive_input.ident;
let field_type = extract_first_syn_type_from_unnamed_struct(&syn_derive_input);
let generate_postgresql_type_tokens_where_element_token_stream = |is_nullable: IsNullable|{
let range_type_token_stream = range_type.type_token_stream();
let should_impl_range_length = range_type.should_impl_range_length();

let increment_snake_case = naming::IncrementSnakeCase;
let value_snake_case = naming::ValueSnakeCase;
Expand Down Expand Up @@ -5056,7 +5068,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_st
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::I32,
ShouldImplRangeLength::True,
)
}

Expand All @@ -5065,7 +5076,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_st
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::I64,
ShouldImplRangeLength::True,
)
}

Expand All @@ -5074,7 +5084,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::SqlxTypesChronoDateTimeSqlxTypesChronoUtc,
ShouldImplRangeLength::False,
)
}

Expand All @@ -5083,7 +5092,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::SqlxTypesChronoDateTimeSqlxTypesChronoLocal,
ShouldImplRangeLength::False,
)
}

Expand All @@ -5092,7 +5100,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDateTime,
ShouldImplRangeLength::False,
)
}

Expand All @@ -5101,7 +5108,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::SqlxPostgresTypesPgRangeSqlxTypesChronoNaiveDate,
ShouldImplRangeLength::False,
)
}

Expand All @@ -5110,7 +5116,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq
generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
input,
RangeType::SqlxPostgresTypesPgRangeSqlxTypesDecimal,
ShouldImplRangeLength::False,
)
}

Expand Down Expand Up @@ -9954,7 +9959,6 @@ pub fn postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_sq
// generate_postgresql_base_type_tokens_where_element_sqlx_postgres_types_pg_range_tokens(
// input,
// RangeType::SqlxPostgresTypesPgRangeSqlxTypesTimeOffsetDateTime,
// ShouldImplRangeLength::False,
// )

// let input: proc_macro::TokenStream,
Expand Down

0 comments on commit a8955dd

Please sign in to comment.