Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ tracing = { version = "0.1", default-features = false, features = ["attributes",
rust_decimal = { version = "1", default-features = false, optional = true }
bigdecimal = { version = "0.4", default-features = false, optional = true }
sea-orm-macros = { version = "~1.2.0-rc.1", path = "sea-orm-macros", default-features = false, features = ["strum"] }
sea-query = { version = "1.0.0-rc.1", default-features = false, features = ["thread-safe", "hashable-value", "backend-mysql", "backend-postgres", "backend-sqlite"] }
sea-query = { version = "1.0.0-rc.2", default-features = false, features = ["thread-safe", "hashable-value", "backend-mysql", "backend-postgres", "backend-sqlite"] }
sea-query-binder = { version = "0.8.0-rc.1", default-features = false, optional = true }
strum = { version = "0.26", default-features = false }
serde = { version = "1.0", default-features = false }
Expand Down Expand Up @@ -109,4 +109,3 @@ seaography = ["sea-orm-macros/seaography"]
# This allows us to develop using a local version of sea-query
[patch.crates-io]
# sea-query = { path = "../sea-query" }
sea-query = { git = "https://github.com/SeaQL/sea-query.git", branch = "master" }
4 changes: 2 additions & 2 deletions sea-orm-macros/src/derives/entity_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec<Attribute>) -> syn::Res

if let Some(select_as) = select_as {
columns_select_as.push(quote! {
Self::#field_name => expr.cast_as(#select_as)
Self::#field_name => ::sea_query::ExprTrait::cast_as(expr, #select_as)
});
}
if let Some(save_as) = save_as {
columns_save_as.push(quote! {
Self::#field_name => val.cast_as(#save_as)
Self::#field_name => ::sea_query::ExprTrait::cast_as(val, #save_as)
});
}

Expand Down
7 changes: 6 additions & 1 deletion sea-orm-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ pub fn derive_from_json_query_result(input: TokenStream) -> TokenStream {
/// For more complete examples, please refer to https://github.com/SeaQL/sea-orm/blob/master/tests/partial_model_tests.rs
///
/// ```rust
/// use sea_orm::sea_query::ExprTrait;
/// use sea_orm::{DerivePartialModel, FromQueryResult, entity::prelude::*};
///
/// #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
Expand Down Expand Up @@ -777,7 +778,11 @@ pub fn derive_from_json_query_result(input: TokenStream) -> TokenStream {
///
/// If all fields in the partial model is `from_expr`, the specifying the `entity` can be skipped.
/// ```
/// use sea_orm::{DerivePartialModel, FromQueryResult, entity::prelude::*, sea_query::Expr};
/// use sea_orm::{
/// DerivePartialModel, FromQueryResult,
/// entity::prelude::*,
/// sea_query::{Expr, ExprTrait},
/// };
///
/// #[derive(Debug, FromQueryResult, DerivePartialModel)]
/// struct SelectResult {
Expand Down
2 changes: 1 addition & 1 deletion src/entity/active_enum.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{ColIdx, ColumnDef, DbErr, Iterable, QueryResult, TryFromU64, TryGetError, TryGetable};
use sea_query::{DynIden, Expr, Nullable, SimpleExpr, Value, ValueType};
use sea_query::{DynIden, Expr, ExprTrait, Nullable, SimpleExpr, Value, ValueType};

/// A Rust representation of enum defined in database.
///
Expand Down
12 changes: 9 additions & 3 deletions src/entity/column.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{DbBackend, EntityName, Iden, IdenStatic, IntoSimpleExpr, Iterable};
use sea_query::{
Alias, BinOper, DynIden, Expr, IntoIden, IntoLikeExpr, SeaRc, SelectStatement, SimpleExpr,
Value,
Alias, BinOper, DynIden, Expr, ExprTrait, IntoIden, IntoLikeExpr, SeaRc, SelectStatement,
SimpleExpr, Value,
};
use std::str::FromStr;

Expand Down Expand Up @@ -265,7 +265,7 @@ pub trait ColumnTrait: IdenStatic + Iterable + FromStr {

/// Construct a [`SimpleExpr::Column`] wrapped in [`Expr`].
fn into_expr(self) -> Expr {
Expr::expr(self.into_simple_expr())
Expr::new(self.into_simple_expr())
}

/// Construct a returning [`Expr`].
Expand Down Expand Up @@ -1026,6 +1026,8 @@ mod tests {
use crate::{ActiveModelTrait, ActiveValue, Update};

mod hello_expanded {
use sea_query::ExprTrait;

use crate as sea_orm;
use crate::entity::prelude::*;
use crate::sea_query::{Expr, SimpleExpr};
Expand Down Expand Up @@ -1157,6 +1159,8 @@ mod tests {
use crate::{ActiveModelTrait, ActiveValue, Update};

mod hello_expanded {
use sea_query::ExprTrait;

use crate as sea_orm;
use crate::entity::prelude::*;
use crate::sea_query::{Expr, SimpleExpr};
Expand Down Expand Up @@ -1288,6 +1292,8 @@ mod tests {
use crate::{ActiveModelTrait, ActiveValue, Update};

mod hello_expanded {
use sea_query::ExprTrait;

use crate as sea_orm;
use crate::entity::prelude::*;
use crate::sea_query::{Expr, SimpleExpr};
Expand Down
4 changes: 2 additions & 2 deletions src/entity/relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl RelationDef {
///
/// ```
/// use sea_orm::{entity::*, query::*, DbBackend, tests_cfg::{cake, cake_filling}};
/// use sea_query::{Expr, IntoCondition};
/// use sea_query::{Expr, ExprTrait, IntoCondition};
///
/// assert_eq!(
/// cake::Entity::find()
Expand Down Expand Up @@ -328,7 +328,7 @@ impl RelationDef {
///
/// ```
/// use sea_orm::{entity::*, query::*, DbBackend, tests_cfg::{cake, cake_filling}};
/// use sea_query::{Expr, IntoCondition, ConditionType};
/// use sea_query::{Expr, ExprTrait, IntoCondition, ConditionType};
///
/// assert_eq!(
/// cake::Entity::find()
Expand Down
4 changes: 2 additions & 2 deletions src/executor/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
SelectThree, SelectThreeModel, SelectTwo, SelectTwoModel, SelectorTrait,
};
use sea_query::{
Condition, DynIden, Expr, IntoValueTuple, Order, SeaRc, SelectStatement, SimpleExpr, Value,
ValueTuple,
Condition, DynIden, Expr, ExprTrait, IntoValueTuple, Order, SeaRc, SelectStatement, SimpleExpr,
Value, ValueTuple,
};
use std::marker::PhantomData;
use strum::IntoEnumIterator as Iterable;
Expand Down
12 changes: 6 additions & 6 deletions src/query/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
ModelTrait, PrimaryKeyToColumn, RelationDef,
};
use sea_query::{
Alias, Expr, Iden, IntoCondition, IntoIden, LockBehavior, LockType, NullOrdering, SeaRc,
SelectExpr, SelectStatement, SimpleExpr, TableRef,
Alias, Expr, ExprTrait, Iden, IntoCondition, IntoIden, LockBehavior, LockType, NullOrdering,
SeaRc, SelectExpr, SelectStatement, SimpleExpr, TableRef,
};
pub use sea_query::{Condition, ConditionalStatement, DynIden, JoinType, Order, OrderedStatement};

Expand Down Expand Up @@ -284,7 +284,7 @@ pub trait QuerySelect: Sized {

/// Add an AND HAVING expression
/// ```
/// use sea_orm::{sea_query::{Alias, Expr}, entity::*, query::*, tests_cfg::cake, DbBackend};
/// use sea_orm::{sea_query::{Alias, Expr, ExprTrait}, entity::*, query::*, tests_cfg::cake, DbBackend};
///
/// assert_eq!(
/// cake::Entity::find()
Expand Down Expand Up @@ -731,7 +731,7 @@ pub trait QueryFilter: Sized {
/// Like above, but using the `ANY` operator. Postgres only.
///
/// ```
/// use sea_orm::sea_query::{Expr, extension::postgres::PgFunc};
/// use sea_orm::sea_query::{Expr, ExprTrait, extension::postgres::PgFunc};
/// use sea_orm::{DbBackend, entity::*, query::*, tests_cfg::cake};
///
/// assert_eq!(
Expand Down Expand Up @@ -790,7 +790,7 @@ pub trait QueryFilter: Sized {
///
/// A slightly more complex example.
/// ```
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, sea_query::Expr, DbBackend};
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, sea_query::{Expr, ExprTrait}, DbBackend};
///
/// assert_eq!(
/// cake::Entity::find()
Expand All @@ -815,7 +815,7 @@ pub trait QueryFilter: Sized {
/// ```
/// Use a sea_query expression
/// ```
/// use sea_orm::{entity::*, query::*, sea_query::Expr, tests_cfg::fruit, DbBackend};
/// use sea_orm::{entity::*, query::*, sea_query::{Expr, ExprTrait}, tests_cfg::fruit, DbBackend};
///
/// assert_eq!(
/// fruit::Entity::find()
Expand Down
2 changes: 1 addition & 1 deletion src/query/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod tests {
RelationTrait,
};
use pretty_assertions::assert_eq;
use sea_query::{Alias, ConditionType, Expr, IntoCondition, JoinType};
use sea_query::{Alias, ConditionType, Expr, ExprTrait, IntoCondition, JoinType};

#[test]
fn join_1() {
Expand Down
4 changes: 3 additions & 1 deletion src/query/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use crate::{
RelationType, Select, error::*,
};
use async_trait::async_trait;
use sea_query::{ColumnRef, DynIden, Expr, IntoColumnRef, SimpleExpr, TableRef, ValueTuple};
use sea_query::{
ColumnRef, DynIden, Expr, ExprTrait, IntoColumnRef, SimpleExpr, TableRef, ValueTuple,
};
use std::{
collections::{HashMap, HashSet},
str::FromStr,
Expand Down
2 changes: 1 addition & 1 deletion src/query/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
C: ColumnTrait,
{
fn into_column_as_expr(self) -> SimpleExpr {
self.select_as(Expr::expr(self.as_column_ref().into_column_ref()))
self.select_as(Expr::new(self.as_column_ref().into_column_ref()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests_cfg/entity_linked.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::entity::prelude::*;
use sea_query::{Expr, IntoCondition};
use sea_query::{Expr, ExprTrait, IntoCondition};

#[derive(Debug)]
pub struct CakeToFilling;
Expand Down
17 changes: 9 additions & 8 deletions tests/active_enum_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use sea_orm::{
entity::*,
sea_query::{BinOper, Expr},
};
use sea_query::ExprTrait;

#[sea_orm_macros::test]
async fn main() -> Result<(), DbErr> {
Expand Down Expand Up @@ -141,10 +142,10 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> {
assert_eq!(
model,
Entity::find()
.filter(
Expr::col(Column::Tea)
.binary(BinOper::In, Expr::tuple([Tea::EverydayTea.as_enum()]))
)
.filter(Expr::col(Column::Tea).binary(
BinOper::In,
Expr::tuple([ActiveEnumTrait::as_enum(&Tea::EverydayTea)])
))
.one(db)
.await?
.unwrap()
Expand Down Expand Up @@ -173,10 +174,10 @@ pub async fn insert_active_enum(db: &DatabaseConnection) -> Result<(), DbErr> {
model,
Entity::find()
.filter(Column::Tea.is_not_null())
.filter(
Expr::col(Column::Tea)
.binary(BinOper::NotIn, Expr::tuple([Tea::BreakfastTea.as_enum()]))
)
.filter(Expr::col(Column::Tea).binary(
BinOper::NotIn,
Expr::tuple([ActiveEnumTrait::as_enum(&Tea::BreakfastTea)])
))
.one(db)
.await?
.unwrap()
Expand Down
1 change: 1 addition & 0 deletions tests/cursor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod common;
pub use common::{TestContext, features::*, setup::*};
use pretty_assertions::assert_eq;
use sea_orm::{DerivePartialModel, FromQueryResult, QuerySelect, Set, entity::prelude::*};
use sea_query::ExprTrait;
use serde_json::json;

#[sea_orm_macros::test]
Expand Down
2 changes: 1 addition & 1 deletion tests/dyn_table_name_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sea_orm::{
DatabaseConnection, Delete, IntoActiveModel, Iterable, QueryTrait, Set, Update,
entity::prelude::*,
};
use sea_query::{Expr, Query};
use sea_query::{Expr, ExprTrait, Query};

#[sea_orm_macros::test]
async fn main() -> Result<(), DbErr> {
Expand Down
9 changes: 5 additions & 4 deletions tests/enum_primary_key_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use sea_orm::{
entity::*,
sea_query::{BinOper, Expr},
};
use sea_query::ExprTrait;

#[sea_orm_macros::test]
async fn main() -> Result<(), DbErr> {
Expand Down Expand Up @@ -106,10 +107,10 @@ pub async fn insert_teas(db: &DatabaseConnection) -> Result<(), DbErr> {
assert_eq!(
model,
Entity::find()
.filter(
Expr::col(Column::Id)
.binary(BinOper::In, Expr::tuple([Tea::EverydayTea.as_enum()]))
)
.filter(Expr::col(Column::Id).binary(
BinOper::In,
Expr::tuple([ActiveEnumTrait::as_enum(&Tea::EverydayTea)])
))
.one(db)
.await?
.unwrap()
Expand Down
1 change: 1 addition & 0 deletions tests/partial_model_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use sea_orm::{
DerivePartialModel, FromQueryResult, IntoActiveModel, JoinType, NotSet, QueryOrder,
QuerySelect, Set, prelude::*, sea_query::Alias,
};
use sea_query::ExprTrait;

use crate::common::TestContext;
use common::bakery_chain::*;
Expand Down
Loading