Skip to content

Commit

Permalink
fix: update test sqlite capabilities and fix some issues (#5102)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacek-prisma authored Jan 2, 2025
1 parent a510d27 commit c49e56c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/test-setup/src/test_api_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static DB_UNDER_TEST: Lazy<Result<DbUnderTest, String>> = Lazy::new(|| {
"file" | "sqlite" => Ok(DbUnderTest {
database_url,
tags: Tags::Sqlite.into(),
capabilities: Capabilities::CreateDatabase.into(),
capabilities: Capabilities::CreateDatabase | Capabilities::Json,
provider: "sqlite",
shadow_database_url,
max_ddl_refresh_delay: None,
Expand Down
4 changes: 4 additions & 0 deletions schema-engine/sql-migration-tests/tests/migrations/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ fn database_level_json_defaults_can_be_defined(api: TestApi) {
)))
} else if api.is_mysql() {
None
} else if api.is_sqlite() {
Some(DefaultValue::value(PrismaValue::String(
"[\"sticks\",\"chimken\",100, \"dog park\"]".into(),
)))
} else {
unreachable!()
})
Expand Down
3 changes: 2 additions & 1 deletion schema-engine/sql-schema-describer/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ async fn push_columns(
}
_ => DefaultValue::db_generated(default_string),
},
ColumnTypeFamily::Json => DefaultValue::value(default_string),
ColumnTypeFamily::Binary => DefaultValue::db_generated(default_string),
ColumnTypeFamily::Json => DefaultValue::db_generated(default_string),
ColumnTypeFamily::Uuid => DefaultValue::db_generated(default_string),
ColumnTypeFamily::Enum(_) => DefaultValue::value(PrismaValue::Enum(default_string)),
ColumnTypeFamily::Unsupported(_) => DefaultValue::db_generated(default_string),
Expand Down Expand Up @@ -581,6 +581,7 @@ fn get_column_type(mut tpe: String, arity: ColumnArity) -> ColumnType {
"int[]" => ColumnTypeFamily::Int,
"integer[]" => ColumnTypeFamily::Int,
"text[]" => ColumnTypeFamily::String,
"jsonb" => ColumnTypeFamily::Json,
// NUMERIC type affinity
data_type if data_type.starts_with("decimal") => ColumnTypeFamily::Decimal,
data_type => ColumnTypeFamily::Unsupported(data_type.into()),
Expand Down

0 comments on commit c49e56c

Please sign in to comment.