Fix test
This commit is contained in:
parent
074ade75c2
commit
69ff215387
|
@ -353,7 +353,7 @@ func TestJoinWithSubQuery(t *testing.T) {
|
|||
assert.EqualValues(t, q, querys[0])
|
||||
|
||||
querys = make([]JoinWithSubQuery1, 0, 1)
|
||||
err = testEngine.Join("INNER", "(SELECT `id` FROM `"+tbName+"`) join_with_sub_query_depart", "`join_with_sub_query_depart`.`id` = `join_with_sub_query1`.`depart_id`").
|
||||
err = testEngine.Join("INNER", "(SELECT `id` FROM "+tbName+") `a`", "`a`.`id` = `join_with_sub_query1`.`depart_id`").
|
||||
Find(&querys)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, len(querys))
|
||||
|
|
|
@ -539,7 +539,7 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
|
|||
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
|
||||
aliasName = schemas.CommonQuoter.Trim(aliasName)
|
||||
|
||||
fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), aliasName, statement.ReplaceQuote(condition))
|
||||
fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), statement.quote(aliasName), statement.ReplaceQuote(condition))
|
||||
statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
|
||||
case *builder.Builder:
|
||||
subSQL, subQueryArgs, err := tp.ToSQL()
|
||||
|
@ -552,7 +552,7 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
|
|||
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
|
||||
aliasName = schemas.CommonQuoter.Trim(aliasName)
|
||||
|
||||
fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), aliasName, statement.ReplaceQuote(condition))
|
||||
fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), statement.quote(aliasName), statement.ReplaceQuote(condition))
|
||||
statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
|
||||
default:
|
||||
tbName := dialects.FullTableName(statement.dialect, statement.tagParser.GetTableMapper(), tablename, true)
|
||||
|
@ -560,6 +560,8 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
|
|||
var buf strings.Builder
|
||||
statement.dialect.Quoter().QuoteTo(&buf, tbName)
|
||||
tbName = buf.String()
|
||||
} else {
|
||||
tbName = statement.ReplaceQuote(tbName)
|
||||
}
|
||||
fmt.Fprintf(&buf, "%s ON %v", tbName, statement.ReplaceQuote(condition))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue