SeaORM creating NOT NULL constraints for columns marked with .null() and causes NOT NULL violation in Sqlite
#2324
Replies: 3 comments 2 replies
-
|
Same issue! This is how I create the table: manager
.create_table(
Table::create()
.table(Users::Table)
.if_not_exists()
.col(string(Users::Ulid).primary_key())
.col(string(Users::Username).unique_key().not_null())
.col(string(Users::Email).unique_key().not_null())
.col(string(Users::Password).not_null())
.col(string(Users::DisplayName).not_null())
.col(string(Users::Avatar).null())
.col(integer(Users::Coins).default(0))
.col(enumeration(Users::Role, Alias::new("role"), Role::iter()).default(Role::Standard))
.col(date_time(Users::CreatedAt).default(chrono::Utc::now()))
.col(date_time(Users::UpdatedAt))
.to_owned(),
)
.await?This is the SQL I'm getting: CREATE TABLE IF NOT EXISTS "users" ( "ulid" varchar NOT NULL PRIMARY KEY, "username" varchar NOT NULL UNIQUE NOT NULL, "email" varchar NOT NULL UNIQUE NOT NULL, "password" varchar NOT NULL NOT NULL, "display_name" varchar NOT NULL NOT NULL, "avatar" varchar NOT NULL NULL, "coins" integer NOT NULL DEFAULT 0, "role" enum_text NOT NULL DEFAULT 2, "created_at" datetime_text NOT NULL DEFAULT '2024-09-01 16:00:25 +00:00', "updated_at" datetime_text NOT NULL )where [dependencies.sea-orm-migration]
version = "~1.1.0-rc.1" # sea-orm-migration version
features = [
"runtime-tokio-rustls",
]
|
Beta Was this translation helpful? Give feedback.
2 replies
-
|
@billy1624 This is a critical bug, can you please look into it? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Close in favor of #2337 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a migration defined as follows:
But every time I try to insert into the table, I get the following error:
I'm using SQLite.
I have the following dependencies in my
Cargo.tomlfile:Any help will be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions