mirror of
https://github.com/ent/ent.git
synced 2026-05-05 00:50:54 +03:00
dialect/sql: add support for setting the table_schema in select_table (#1001)
This commit is contained in:
@@ -680,8 +680,8 @@ func TestBuilder(t *testing.T) {
|
||||
return Select(t1.C("id"), As(Count("`*`"), "group_count")).
|
||||
From(t1).
|
||||
LeftJoin(t2).
|
||||
OnP(P(func(builder *Builder) {
|
||||
builder.Ident(t1.C("id")).WriteOp(OpEQ).Ident(t2.C("user_id"))
|
||||
OnP(P(func(b *Builder) {
|
||||
b.Ident(t1.C("id")).WriteOp(OpEQ).Ident(t2.C("user_id"))
|
||||
})).
|
||||
GroupBy(t1.C("id")).Clone()
|
||||
}(),
|
||||
@@ -1271,6 +1271,19 @@ WHERE
|
||||
wantQuery: `SELECT * FROM "test" WHERE nlevel("path") > $1`,
|
||||
wantArgs: []interface{}{1},
|
||||
},
|
||||
{
|
||||
input: func() Querier {
|
||||
t1, t2 := Table("users").Schema("s1"), Table("pets").Schema("s2")
|
||||
return Select("*").
|
||||
From(t1).Join(t2).
|
||||
OnP(P(func(b *Builder) {
|
||||
b.Ident(t1.C("id")).WriteOp(OpEQ).Ident(t2.C("owner_id"))
|
||||
})).
|
||||
Where(EQ(t2.C("name"), "pedro"))
|
||||
}(),
|
||||
wantQuery: "SELECT * FROM `s1`.`users` JOIN `s2`.`pets` AS `t0` ON `s1`.`users`.`id` = `t0`.`owner_id` WHERE `t0`.`name` = ?",
|
||||
wantArgs: []interface{}{"pedro"},
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user