|
|
@@ -985,41 +985,45 @@ func (statement *Statement) Unscoped() *Statement {
|
|
|
}
|
|
|
|
|
|
func (statement *Statement) genColumnStr() string {
|
|
|
- table := statement.RefTable
|
|
|
- var colNames []string
|
|
|
- for _, col := range table.Columns() {
|
|
|
+
|
|
|
+ var buf bytes.Buffer
|
|
|
+
|
|
|
+ columns := statement.RefTable.Columns()
|
|
|
+
|
|
|
+ for _, col := range columns {
|
|
|
+
|
|
|
if statement.OmitStr != "" {
|
|
|
if _, ok := statement.columnMap[strings.ToLower(col.Name)]; ok {
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if col.MapType == core.ONLYTODB {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ if buf.Len() != 0 {
|
|
|
+ buf.WriteString(", ")
|
|
|
+ }
|
|
|
+
|
|
|
+ if col.IsPrimaryKey && statement.Engine.Dialect().DBType() == "ql" {
|
|
|
+ buf.WriteString("id() AS ")
|
|
|
+ }
|
|
|
+
|
|
|
if statement.JoinStr != "" {
|
|
|
- var name string
|
|
|
if statement.TableAlias != "" {
|
|
|
- name = statement.Engine.Quote(statement.TableAlias)
|
|
|
- } else {
|
|
|
- name = statement.Engine.Quote(statement.TableName())
|
|
|
- }
|
|
|
- name += "." + statement.Engine.Quote(col.Name)
|
|
|
- if col.IsPrimaryKey && statement.Engine.Dialect().DBType() == "ql" {
|
|
|
- colNames = append(colNames, "id() AS "+name)
|
|
|
- } else {
|
|
|
- colNames = append(colNames, name)
|
|
|
- }
|
|
|
- } else {
|
|
|
- name := statement.Engine.Quote(col.Name)
|
|
|
- if col.IsPrimaryKey && statement.Engine.Dialect().DBType() == "ql" {
|
|
|
- colNames = append(colNames, "id() AS "+name)
|
|
|
+ buf.WriteString(statement.TableAlias)
|
|
|
} else {
|
|
|
- colNames = append(colNames, name)
|
|
|
+ buf.WriteString(statement.TableName())
|
|
|
}
|
|
|
+
|
|
|
+ buf.WriteString(".")
|
|
|
}
|
|
|
+
|
|
|
+ statement.Engine.QuoteTo(&buf, col.Name)
|
|
|
}
|
|
|
- return strings.Join(colNames, ", ")
|
|
|
+
|
|
|
+ return buf.String()
|
|
|
}
|
|
|
|
|
|
func (statement *Statement) genCreateTableSQL() string {
|