Fix use hint with join bug
This commit is contained in:
parent
bdd8787d84
commit
529b8c66e9
|
@ -184,6 +184,7 @@ func (statement *Statement) writeFrom(w *builder.BytesWriter) error {
|
|||
statement.writeStrings(" FROM "),
|
||||
statement.writeTableName,
|
||||
statement.writeAlias,
|
||||
statement.writeIndexHints,
|
||||
statement.writeJoins,
|
||||
)
|
||||
}
|
||||
|
@ -254,7 +255,6 @@ func (statement *Statement) writeSelect(buf *builder.BytesWriter, columnStr stri
|
|||
return statement.writeMultiple(buf,
|
||||
statement.writeSelectColumns(columnStr),
|
||||
statement.writeFrom,
|
||||
statement.writeIndexHints,
|
||||
statement.writeWhere,
|
||||
statement.writeGroupBy,
|
||||
statement.writeHaving,
|
||||
|
|
|
@ -78,4 +78,11 @@ func TestIndexHint(t *testing.T) {
|
|||
|
||||
_, err = testEngine.Table("userinfo").IndexHint("USE", "GROUP BY", "UQE_userinfo_username").Get(new(Userinfo))
|
||||
assert.NoError(t, err)
|
||||
|
||||
// with join
|
||||
_, err = testEngine.Table("userinfo").
|
||||
Join("LEFT", "userdetail", "userinfo.id = userdetail.id").
|
||||
IndexHint("USE", "", "UQE_userinfo_username").
|
||||
Get(new(Userinfo))
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue