Fix order by primary key if it is not defined
This commit is contained in:
parent
64ed645e4d
commit
669ce48f19
@ -90,6 +90,8 @@ func (stmt Statement) QuoteTo(writer clause.Writer, field interface{}) {
|
|||||||
if v.Name == clause.PrimaryKey {
|
if v.Name == clause.PrimaryKey {
|
||||||
if stmt.Schema != nil && stmt.Schema.PrioritizedPrimaryField != nil {
|
if stmt.Schema != nil && stmt.Schema.PrioritizedPrimaryField != nil {
|
||||||
stmt.DB.Dialector.QuoteTo(writer, stmt.Schema.PrioritizedPrimaryField.DBName)
|
stmt.DB.Dialector.QuoteTo(writer, stmt.Schema.PrioritizedPrimaryField.DBName)
|
||||||
|
} else if len(stmt.Schema.DBNames) > 0 {
|
||||||
|
stmt.DB.Dialector.QuoteTo(writer, stmt.Schema.DBNames[0])
|
||||||
}
|
}
|
||||||
} else if v.Raw {
|
} else if v.Raw {
|
||||||
writer.WriteString(v.Name)
|
writer.WriteString(v.Name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user