improve code

This commit is contained in:
Lunny Xiao 2020-03-08 20:29:29 +08:00
parent f0d8606d44
commit a7b1c34dba
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 3 additions and 3 deletions

View File

@ -562,7 +562,7 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1]) aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
aliasName = schemas.CommonQuoter.Trim(aliasName) aliasName = schemas.CommonQuoter.Trim(aliasName)
fmt.Fprintf(&buf, "(%s) %s ON %v", subSQL, aliasName, condition) fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), aliasName, statement.ReplaceQuote(condition))
statement.joinArgs = append(statement.joinArgs, subQueryArgs...) statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
case *builder.Builder: case *builder.Builder:
subSQL, subQueryArgs, err := tp.ToSQL() subSQL, subQueryArgs, err := tp.ToSQL()
@ -575,7 +575,7 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1]) aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
aliasName = schemas.CommonQuoter.Trim(aliasName) aliasName = schemas.CommonQuoter.Trim(aliasName)
fmt.Fprintf(&buf, "(%s) %s ON %v", subSQL, aliasName, condition) fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), aliasName, statement.ReplaceQuote(condition))
statement.joinArgs = append(statement.joinArgs, subQueryArgs...) statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
default: default:
tbName := dialects.FullTableName(statement.dialect, statement.tagParser.GetTableMapper(), tablename, true) tbName := dialects.FullTableName(statement.dialect, statement.tagParser.GetTableMapper(), tablename, true)
@ -584,7 +584,7 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
statement.dialect.Quoter().QuoteTo(&buf, tbName) statement.dialect.Quoter().QuoteTo(&buf, tbName)
tbName = buf.String() tbName = buf.String()
} }
fmt.Fprintf(&buf, "%s ON %v", tbName, condition) fmt.Fprintf(&buf, "%s ON %v", tbName, statement.ReplaceQuote(condition))
} }
statement.JoinStr = buf.String() statement.JoinStr = buf.String()