This commit is contained in:
Billy Chan 2022-10-17 17:25:35 +08:00
parent 77bddd85a5
commit 671d79469a
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
13 changed files with 40 additions and 13 deletions

View File

@ -34,8 +34,8 @@ log = { version = "^0.4" }
tracing = { version = "^0.1", features = ["log"] } tracing = { version = "^0.1", features = ["log"] }
rust_decimal = { version = "^1", optional = true } rust_decimal = { version = "^1", optional = true }
sea-orm-macros = { version = "^0.10.0", path = "sea-orm-macros", optional = true } sea-orm-macros = { version = "^0.10.0", path = "sea-orm-macros", optional = true }
sea-query = { version = "^0.27", git = "https://github.com/SeaQL/sea-query", features = ["thread-safe"] } sea-query = { version = "^0.27", features = ["thread-safe"] }
sea-query-binder = { version = "^0.1", git = "https://github.com/SeaQL/sea-query", optional = true } sea-query-binder = { version = "^0.2", optional = true }
sea-strum = { version = "^0.23", features = ["derive", "sea-orm"] } sea-strum = { version = "^0.23", features = ["derive", "sea-orm"] }
serde = { version = "^1.0", features = ["derive"] } serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1.0", optional = true } serde_json = { version = "^1.0", optional = true }
@ -45,6 +45,10 @@ ouroboros = "0.15"
url = "^2.2" url = "^2.2"
once_cell = "1.8" once_cell = "1.8"
[patch.crates-io]
sea-query = { git = "https://github.com/SeaQL/sea-query", branch = "sqlite-bind-decimals" }
sea-query-binder = { git = "https://github.com/SeaQL/sea-query", branch = "sqlite-bind-decimals" }
[dev-dependencies] [dev-dependencies]
smol = { version = "^1.2" } smol = { version = "^1.2" }
smol-potat = { version = "^1.1" } smol-potat = { version = "^1.1" }

View File

@ -72,6 +72,10 @@ macro_rules! into_sea_query_value {
stringify!($newtype).to_owned() stringify!($newtype).to_owned()
} }
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::$name
}
fn column_type() -> sea_orm::sea_query::ColumnType { fn column_type() -> sea_orm::sea_query::ColumnType {
sea_orm::sea_query::ColumnType::$name sea_orm::sea_query::ColumnType::$name
} }

View File

@ -73,6 +73,10 @@ impl<T> sea_orm::sea_query::ValueType for AccountId<T> {
stringify!(AccountId).to_owned() stringify!(AccountId).to_owned()
} }
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::Uuid
}
fn column_type() -> sea_orm::sea_query::ColumnType { fn column_type() -> sea_orm::sea_query::ColumnType {
sea_orm::sea_query::ColumnType::Uuid sea_orm::sea_query::ColumnType::Uuid
} }

View File

@ -17,7 +17,7 @@ name = "sea_orm_codegen"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
sea-query = { version = "^0.27", git = "https://github.com/SeaQL/sea-query", features = ["thread-safe"] } sea-query = { version = "^0.27", features = ["thread-safe"] }
syn = { version = "^1", default-features = false, features = [ syn = { version = "^1", default-features = false, features = [
"derive", "derive",
"parsing", "parsing",

View File

@ -335,6 +335,10 @@ impl ActiveEnum {
<<Self as sea_orm::ActiveEnum>::Value as sea_orm::sea_query::ValueType>::type_name() <<Self as sea_orm::ActiveEnum>::Value as sea_orm::sea_query::ValueType>::type_name()
} }
fn array_type() -> sea_orm::sea_query::ArrayType {
unimplemented!("Array of Enum is not supported")
}
fn column_type() -> sea_orm::sea_query::ColumnType { fn column_type() -> sea_orm::sea_query::ColumnType {
<Self as sea_orm::ActiveEnum>::db_type() <Self as sea_orm::ActiveEnum>::db_type()
.get_column_type() .get_column_type()

View File

@ -28,6 +28,10 @@ pub fn expand_derive_from_json_query_result(ident: Ident) -> syn::Result<TokenSt
stringify!(#ident).to_owned() stringify!(#ident).to_owned()
} }
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::Json
}
fn column_type() -> sea_orm::sea_query::ColumnType { fn column_type() -> sea_orm::sea_query::ColumnType {
sea_orm::sea_query::ColumnType::Json sea_orm::sea_query::ColumnType::Json
} }

View File

@ -2,11 +2,11 @@ use sea_query::Values;
use std::{future::Future, pin::Pin, sync::Arc}; use std::{future::Future, pin::Pin, sync::Arc};
use sqlx::{ use sqlx::{
mysql::{MySqlArguments, MySqlConnectOptions, MySqlQueryResult, MySqlRow}, mysql::{MySqlConnectOptions, MySqlQueryResult, MySqlRow},
MySql, MySqlPool, MySql, MySqlPool,
}; };
use sea_query_binder::{SqlxBinder, SqlxValues}; use sea_query_binder::SqlxValues;
use tracing::instrument; use tracing::instrument;
use crate::{ use crate::{

View File

@ -1,5 +1,4 @@
use sea_query::Values; use sea_query::Values;
use sea_query_binder::SqlxValues;
use std::{future::Future, pin::Pin, sync::Arc}; use std::{future::Future, pin::Pin, sync::Arc};
use sqlx::{ use sqlx::{
@ -7,6 +6,7 @@ use sqlx::{
PgPool, Postgres, PgPool, Postgres,
}; };
use sea_query_binder::SqlxValues;
use tracing::instrument; use tracing::instrument;
use crate::{ use crate::{

View File

@ -14,7 +14,10 @@ use sea_query::{DynIden, Nullable, Value, ValueType};
/// > See [DeriveActiveEnum](sea_orm_macros::DeriveActiveEnum) for the full specification of macro attributes. /// > See [DeriveActiveEnum](sea_orm_macros::DeriveActiveEnum) for the full specification of macro attributes.
/// ///
/// ```rust /// ```rust
/// use sea_orm::entity::prelude::*; /// use sea_orm::{
/// entity::prelude::*,
/// sea_query::{DynIden, SeaRc},
/// };
/// ///
/// // Using the derive macro /// // Using the derive macro
/// #[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] /// #[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]

View File

@ -138,7 +138,7 @@ where
} }
} }
self.query.columns(columns); self.query.columns(columns);
self.query.exprs_panic(values); self.query.values_panic(values);
self self
} }

View File

@ -110,7 +110,7 @@ where
let av = self.model.get(col); let av = self.model.get(col);
if av.is_set() { if av.is_set() {
let expr = cast_text_as_enum(Expr::val(av.into_value().unwrap()), &col); let expr = cast_text_as_enum(Expr::val(av.into_value().unwrap()), &col);
self.query.value_expr(col, expr); self.query.value(col, expr);
} }
} }
self self
@ -200,7 +200,7 @@ where
where where
T: IntoIden, T: IntoIden,
{ {
self.query.col_expr(col, expr); self.query.value(col, expr);
self self
} }
} }

View File

@ -1,10 +1,10 @@
use crate::{ use crate::{
unpack_table_ref, ActiveEnum, ColumnDef, ColumnTrait, ColumnType, DbBackend, EntityTrait, unpack_table_ref, ActiveEnum, ColumnTrait, ColumnType, DbBackend, EntityTrait, Identity,
Identity, Iterable, PrimaryKeyToColumn, PrimaryKeyTrait, RelationTrait, Schema, Iterable, PrimaryKeyToColumn, PrimaryKeyTrait, RelationTrait, Schema,
}; };
use sea_query::{ use sea_query::{
extension::postgres::{Type, TypeCreateStatement}, extension::postgres::{Type, TypeCreateStatement},
ForeignKeyCreateStatement, Iden, Index, IndexCreateStatement, TableCreateStatement, ColumnDef, ForeignKeyCreateStatement, Iden, Index, IndexCreateStatement, TableCreateStatement,
}; };
impl Schema { impl Schema {

View File

@ -45,6 +45,10 @@ impl sea_query::ValueType for StringVec {
stringify!(StringVec).to_owned() stringify!(StringVec).to_owned()
} }
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::String
}
fn column_type() -> sea_query::ColumnType { fn column_type() -> sea_query::ColumnType {
sea_query::ColumnType::String(None) sea_query::ColumnType::String(None)
} }