Feature model postgresql (#842)
* Support postgresql generate * Update template Var * Support to generate postgresql model * Support to generate postgresql model * Update template Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package gen
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/collection"
|
||||
@@ -9,7 +10,7 @@ import (
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
|
||||
)
|
||||
|
||||
func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
func genInsert(table Table, withCache, postgreSql bool) (string, string, error) {
|
||||
keySet := collection.NewSet()
|
||||
keyVariableSet := collection.NewSet()
|
||||
for _, key := range table.UniqueCacheKey {
|
||||
@@ -19,6 +20,7 @@ func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
|
||||
expressions := make([]string, 0)
|
||||
expressionValues := make([]string, 0)
|
||||
var count int
|
||||
for _, field := range table.Fields {
|
||||
camel := field.Name.ToCamel()
|
||||
if camel == "CreateTime" || camel == "UpdateTime" {
|
||||
@@ -31,7 +33,12 @@ func genInsert(table Table, withCache bool) (string, string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
expressions = append(expressions, "?")
|
||||
count += 1
|
||||
if postgreSql {
|
||||
expressions = append(expressions, fmt.Sprintf("$%d", count))
|
||||
} else {
|
||||
expressions = append(expressions, "?")
|
||||
}
|
||||
expressionValues = append(expressionValues, "data."+camel)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user