mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql: append selector alias only if defined (#3399)
This commit is contained in:
@@ -2824,8 +2824,10 @@ func (s *Selector) Query() (string, []any) {
|
||||
b.Wrap(func(b *Builder) {
|
||||
b.Join(t)
|
||||
})
|
||||
b.WriteString(" AS ")
|
||||
b.Ident(t.as)
|
||||
if t.as != "" {
|
||||
b.WriteString(" AS ")
|
||||
b.Ident(t.as)
|
||||
}
|
||||
case *WithBuilder:
|
||||
t.SetDialect(s.dialect)
|
||||
b.Ident(t.Name())
|
||||
|
||||
@@ -1631,6 +1631,11 @@ WHERE (((("users"."id1" = "users"."id2" AND "users"."id1" <> "users"."id2")
|
||||
AND "users"."id1" > "users"."id2") AND "users"."id1" >= "users"."id2")
|
||||
AND "users"."id1" < "users"."id2") AND "users"."id1" <= "users"."id2"`, "\n", ""),
|
||||
},
|
||||
{
|
||||
input: Select("name").
|
||||
From(Select("name", "age").From(Table("users"))),
|
||||
wantQuery: "SELECT `name` FROM (SELECT `name`, `age` FROM `users`)",
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user