Comments (4)
Hi @Makiras, I guess what you want is something like this?
let query = Query::select()
.column(Char::Character)
.table_column(Font::Table, Font::Name)
.from(Char::Table)
.join(
JoinType::RightJoin,
Font::Table,
Expr::tbl(Char::Table, Char::FontId)
.equals(Font::Table, Font::Id)
.and(Expr::tbl(Char::Table, Char::FontId).equals(Font::Table, Font::Id))
.and(Expr::tbl(Char::Table, Char::FontId).equals(Font::Table, Font::Id)),
)
.group_by_columns(vec![(Char::Table, Char::Character)])
.to_owned();
assert_eq!(
query.to_string(MysqlQueryBuilder),
[
r#"SELECT `character`, `font`.`name`"#,
r#"FROM `character`"#,
r#"RIGHT JOIN `font` ON (`character`.`font_id` = `font`.`id`)"#,
r#"AND (`character`.`font_id` = `font`.`id`)"#,
r#"AND (`character`.`font_id` = `font`.`id`)"#,
r#"GROUP BY `character`.`character`"#
]
.join(" ")
);
from sea-query.
Is this a good idea to add func join_cond() which accept Condtion instead of SimpleExpr ?
Regarding the change of API... I think we can do this without breaking anything and always use Condition
internally? @tyt2y3
pub fn join<R, C>(&mut self, join: JoinType, tbl_ref: R, condition: C) -> &mut Self
where
R: IntoTableRef,
C: IntoCondition,
{
// ...
}
Considering we have...
impl IntoCondition for SimpleExpr {
fn into_condition(self) -> Condition {
Condition::all().add(self)
}
}
impl IntoCondition for Condition {
fn into_condition(self) -> Condition {
self
}
}
from sea-query.
ops! I'm sorry that I didn't read the manual carefully, it works well and thanks a lot.
from sea-query.
I agree. Yes it seems to be nicer to use Cond:all
instead of and
chains.
from sea-query.
Related Issues (20)
- sea-query-derive 0.3.1 backward incompatible with 0.3.0 HOT 1
- Support bigdecimal 0.4
- Wrong casting of array of Datetime<FixedOffset>
- Mark query builder functions as const function
- Cast issues with enums HOT 1
- sea-query-rusqlite doesn't compile with v0.29.0 of rusqlite HOT 1
- SQL `ROUND` function HOT 1
- Bug in logic for dropping parentheses HOT 16
- Visibility of fields of FunctionCall inadvertently changed to pub(crate) HOT 1
- OnConflict does not support adding a function expression to list of columns HOT 3
- sea-query-postgres support for bind params compile error HOT 3
- Support postgres Array constructor as function
- Escaping causes check statement to fail HOT 5
- Stop using deprecated serial column type
- `BIGINT PRIMARY KEY AUTOINCREMENT` in SQLite HOT 6
- Array type not annotated when array type cannot be inferred in postgres HOT 1
- Escape string \z meaningless for postgres
- Explicitly annotate values in postgres when types cannot be inferred HOT 3
- Do typechecking on postgres value binder (implement `accepts`) HOT 1
- Multiple arguments / multiple parameters on custom postgres function breaking with Func::cust().args()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sea-query.