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"] }
rust_decimal = { version = "^1", 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-binder = { version = "^0.1", git = "https://github.com/SeaQL/sea-query", optional = true }
sea-query = { version = "^0.27", features = ["thread-safe"] }
sea-query-binder = { version = "^0.2", optional = true }
sea-strum = { version = "^0.23", features = ["derive", "sea-orm"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1.0", optional = true }
@ -45,6 +45,10 @@ ouroboros = "0.15"
url = "^2.2"
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]
smol = { version = "^1.2" }
smol-potat = { version = "^1.1" }

View File

@ -72,6 +72,10 @@ macro_rules! into_sea_query_value {
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 {
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()
}
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::Uuid
}
fn column_type() -> sea_orm::sea_query::ColumnType {
sea_orm::sea_query::ColumnType::Uuid
}

View File

@ -17,7 +17,7 @@ name = "sea_orm_codegen"
path = "src/lib.rs"
[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 = [
"derive",
"parsing",

View File

@ -335,6 +335,10 @@ impl ActiveEnum {
<<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 {
<Self as sea_orm::ActiveEnum>::db_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()
}
fn array_type() -> sea_orm::sea_query::ArrayType {
sea_orm::sea_query::ArrayType::Json
}
fn column_type() -> sea_orm::sea_query::ColumnType {
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 sqlx::{
mysql::{MySqlArguments, MySqlConnectOptions, MySqlQueryResult, MySqlRow},
mysql::{MySqlConnectOptions, MySqlQueryResult, MySqlRow},
MySql, MySqlPool,
};
use sea_query_binder::{SqlxBinder, SqlxValues};
use sea_query_binder::SqlxValues;
use tracing::instrument;
use crate::{

View File

@ -1,5 +1,4 @@
use sea_query::Values;
use sea_query_binder::SqlxValues;
use std::{future::Future, pin::Pin, sync::Arc};
use sqlx::{
@ -7,6 +6,7 @@ use sqlx::{
PgPool, Postgres,
};
use sea_query_binder::SqlxValues;
use tracing::instrument;
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.
///
/// ```rust
/// use sea_orm::entity::prelude::*;
/// use sea_orm::{
/// entity::prelude::*,
/// sea_query::{DynIden, SeaRc},
/// };
///
/// // Using the derive macro
/// #[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)]

View File

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

View File

@ -110,7 +110,7 @@ where
let av = self.model.get(col);
if av.is_set() {
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
@ -200,7 +200,7 @@ where
where
T: IntoIden,
{
self.query.col_expr(col, expr);
self.query.value(col, expr);
self
}
}

View File

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

View File

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