diff --git a/Cargo.toml b/Cargo.toml index 782c24e1..9e6d4a3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ categories = ["database"] [dependencies] async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } -sea-orm = { version = "~1.1.0-rc.1", default-features = false, features = ["seaography"] } +sea-orm = { version = "~1.1.0-rc.3", default-features = false, features = ["seaography"] } itertools = { version = "0.12.0" } heck = { version = "0.4.1" } thiserror = { version = "1.0.44" } diff --git a/examples/mysql/Cargo.toml b/examples/mysql/Cargo.toml index ab2acc05..1f6a13b0 100644 --- a/examples/mysql/Cargo.toml +++ b/examples/mysql/Cargo.toml @@ -8,7 +8,7 @@ axum = { version = "0.7" } async-graphql-axum = { version = "7.0" } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } dotenv = "0.15.0" -sea-orm = { version = "~1.1.0-rc.1", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] } +sea-orm = { version = "~1.1.0-rc.3", features = ["sqlx-mysql", "runtime-async-std-native-tls", "seaography"] } tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } diff --git a/examples/postgres/Cargo.toml b/examples/postgres/Cargo.toml index b79ac2ca..6ffe215f 100644 --- a/examples/postgres/Cargo.toml +++ b/examples/postgres/Cargo.toml @@ -8,7 +8,7 @@ poem = { version = "3.0" } async-graphql-poem = { version = "7.0" } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } dotenv = "0.15.0" -sea-orm = { version = "~1.1.0-rc.1", features = ["sqlx-postgres", "runtime-async-std-native-tls", "seaography"] } +sea-orm = { version = "~1.1.0-rc.3", features = ["sqlx-postgres", "runtime-async-std-native-tls", "seaography"] } tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } diff --git a/examples/sqlite/Cargo.toml b/examples/sqlite/Cargo.toml index f75d44ea..5af603d6 100644 --- a/examples/sqlite/Cargo.toml +++ b/examples/sqlite/Cargo.toml @@ -8,7 +8,7 @@ actix-web = { version = "4.5", default-features = false, features = ["macros"] } async-graphql-actix-web = { version = "7.0" } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } dotenv = "0.15.0" -sea-orm = { version = "~1.1.0-rc.1", features = ["sqlx-sqlite", "runtime-async-std-rustls", "seaography"] } +sea-orm = { version = "~1.1.0-rc.3", features = ["sqlx-sqlite", "runtime-async-std-rustls", "seaography"] } tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } diff --git a/generator/src/templates/actix_cargo.toml b/generator/src/templates/actix_cargo.toml index 9ee2914d..31f884bb 100644 --- a/generator/src/templates/actix_cargo.toml +++ b/generator/src/templates/actix_cargo.toml @@ -8,7 +8,7 @@ actix-web = { version = "4.5", default-features = false, features = ["macros"] } async-graphql-actix-web = { version = "7.0" } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } dotenv = "0.15.0" -sea-orm = { version = "~1.1.0-rc.1", features = ["", "runtime-async-std-native-tls", "seaography"] } +sea-orm = { version = "~1.1.0-rc.3", features = ["", "runtime-async-std-native-tls", "seaography"] } tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } diff --git a/generator/src/templates/axum_cargo.toml b/generator/src/templates/axum_cargo.toml index 59529b0b..73d3470d 100644 --- a/generator/src/templates/axum_cargo.toml +++ b/generator/src/templates/axum_cargo.toml @@ -8,7 +8,7 @@ axum = { version = "0.7" } async-graphql-axum = { version = "7.0" } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } dotenv = "0.15.0" -sea-orm = { version = "~1.1.0-rc.1", features = ["", "runtime-async-std-native-tls", "seaography"] } +sea-orm = { version = "~1.1.0-rc.3", features = ["", "runtime-async-std-native-tls", "seaography"] } tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } diff --git a/generator/src/templates/poem_cargo.toml b/generator/src/templates/poem_cargo.toml index ec21acd7..8fc4c3c0 100644 --- a/generator/src/templates/poem_cargo.toml +++ b/generator/src/templates/poem_cargo.toml @@ -8,7 +8,7 @@ poem = { version = "3.0" } async-graphql-poem = { version = "7.0" } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } dotenv = "0.15.0" -sea-orm = { version = "~1.1.0-rc.1", features = ["", "runtime-async-std-native-tls", "seaography"] } +sea-orm = { version = "~1.1.0-rc.3", features = ["", "runtime-async-std-native-tls", "seaography"] } tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } diff --git a/src/inputs/entity_input.rs b/src/inputs/entity_input.rs index 2a08503d..123dec7a 100644 --- a/src/inputs/entity_input.rs +++ b/src/inputs/entity_input.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use async_graphql::dynamic::{InputObject, InputValue, ObjectAccessor}; -use sea_orm::{ColumnTrait, EntityTrait, Iterable}; +use sea_orm::{ColumnTrait, EntityTrait, Iterable, PrimaryKeyToColumn, PrimaryKeyTrait}; use crate::{BuilderContext, EntityObjectBuilder, SeaResult, TypesMapHelper}; @@ -96,9 +96,17 @@ impl EntityInputBuilder { let column_def = column.def(); + let auto_increment = match ::from_column(column) { + Some(_) => T::PrimaryKey::auto_increment(), + None => false, + }; + let has_default_expr = column_def.get_column_default().is_some(); + let is_insert_not_nullable = + is_insert && !(column_def.is_null() || auto_increment || has_default_expr); + let graphql_type = match types_map_helper.sea_orm_column_type_to_graphql_type( column_def.get_column_type(), - !column_def.is_null() && is_insert, + is_insert_not_nullable, ) { Some(type_name) => type_name, None => return object,