Skip to content

Commit

Permalink
Rename feature flag to field-snake-case and field-camel-case
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Oct 8, 2024
1 parent bc429f4 commit 85ae10b
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ thiserror = { version = "1.0.44" }
fnv = { version = "1.0.7" }

[features]
default = ["camel-case-field"]
default = ["field-camel-case"]
with-json = ["sea-orm/with-json"]
with-chrono = ["sea-orm/with-chrono", "async-graphql/chrono"]
with-time = ["sea-orm/with-time", "async-graphql/time"]
Expand All @@ -34,5 +34,5 @@ with-bigdecimal = ["sea-orm/with-bigdecimal", "async-graphql/bigdecimal"]
with-postgres-array = ["sea-orm/postgres-array"]
# with-ipnetwork = ["sea-orm/with-ipnetwork"]
# with-mac_address = ["sea-orm/with-mac_address"]
snake-case-field = []
camel-case-field = []
field-snake-case = []
field-camel-case = []
2 changes: 1 addition & 1 deletion src/enumerations/active_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl std::default::Default for ActiveEnumConfig {
format!("{}Enum", name.to_upper_camel_case())
}),
variant_name: Box::new(|_enum_name: &str, variant: &str| -> String {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
variant.to_snake_case()
} else {
variant.to_upper_camel_case().to_ascii_uppercase()
Expand Down
2 changes: 1 addition & 1 deletion src/inputs/active_enum_filter_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
let extract_variant = move |input: &str| -> String {
let variant = variants.iter().find(|variant| {
let variant = variant.to_string();
let variant = if cfg!(feature = "snake-case-field") {
let variant = if cfg!(feature = "field-snake-case") {
variant.to_snake_case()
} else {
variant.to_upper_camel_case().to_ascii_uppercase()
Expand Down
2 changes: 1 addition & 1 deletion src/mutation/entity_create_batch_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl std::default::Default for EntityCreateBatchMutationConfig {
fn default() -> Self {
EntityCreateBatchMutationConfig {
mutation_suffix: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"_create_batch"
} else {
"CreateBatch"
Expand Down
2 changes: 1 addition & 1 deletion src/mutation/entity_create_one_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl std::default::Default for EntityCreateOneMutationConfig {
fn default() -> Self {
EntityCreateOneMutationConfig {
mutation_suffix: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"_create_one"
} else {
"CreateOne"
Expand Down
2 changes: 1 addition & 1 deletion src/mutation/entity_delete_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl std::default::Default for EntityDeleteMutationConfig {
fn default() -> Self {
Self {
mutation_suffix: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"_delete"
} else {
"Delete"
Expand Down
2 changes: 1 addition & 1 deletion src/mutation/entity_update_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl std::default::Default for EntityUpdateMutationConfig {
fn default() -> Self {
Self {
mutation_suffix: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"_update"
} else {
"Update"
Expand Down
4 changes: 2 additions & 2 deletions src/outputs/connection_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ impl std::default::Default for ConnectionObjectConfig {
format!("{object_name}Connection")
}),
page_info: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"page_info"
} else {
"pageInfo"
}
.into()
},
pagination_info: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"pagination_info"
} else {
"paginationInfo"
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/entity_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl std::default::Default for EntityObjectConfig {
entity_name.to_upper_camel_case()
}),
column_name: Box::new(|_entity_name: &str, column_name: &str| -> String {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
column_name.to_snake_case()
} else {
column_name.to_lower_camel_case()
Expand Down
8 changes: 4 additions & 4 deletions src/outputs/page_info_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ impl std::default::Default for PageInfoObjectConfig {
PageInfoObjectConfig {
type_name: "PageInfo".into(),
has_previous_page: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"has_previous_page"
} else {
"hasPreviousPage"
}
.into()
},
has_next_page: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"has_next_page"
} else {
"hasNextPage"
}
.into()
},
start_cursor: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"start_cursor"
} else {
"startCursor"
}
.into()
},
end_cursor: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"end_cursor"
} else {
"endCursor"
Expand Down
2 changes: 1 addition & 1 deletion src/query/entity_object_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl EntityObjectRelationBuilder {
<R as sea_orm::EntityTrait>::Model: Sync,
<<R as sea_orm::EntityTrait>::Column as std::str::FromStr>::Err: core::fmt::Debug,
{
let name = if cfg!(feature = "snake-case-field") {
let name = if cfg!(feature = "field-snake-case") {
name.to_snake_case()
} else {
name.to_lower_camel_case()
Expand Down
2 changes: 1 addition & 1 deletion src/query/entity_object_via_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl EntityObjectViaRelationBuilder {
<<T as sea_orm::EntityTrait>::Column as std::str::FromStr>::Err: core::fmt::Debug,
<<R as sea_orm::EntityTrait>::Column as std::str::FromStr>::Err: core::fmt::Debug,
{
let name = if cfg!(feature = "snake-case-field") {
let name = if cfg!(feature = "field-snake-case") {
name.to_snake_case()
} else {
name.to_lower_camel_case()
Expand Down
4 changes: 2 additions & 2 deletions src/query/entity_query_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ impl std::default::Default for EntityQueryFieldConfig {
fn default() -> Self {
EntityQueryFieldConfig {
type_name: Box::new(|object_name: &str| -> String {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
object_name.to_snake_case()
} else {
object_name.to_lower_camel_case()
}
}),
filters: "filters".into(),
order_by: {
if cfg!(feature = "snake-case-field") {
if cfg!(feature = "field-snake-case") {
"order_by"
} else {
"orderBy"
Expand Down

0 comments on commit 85ae10b

Please sign in to comment.