@@ -120,29 +120,29 @@ func processTableSQLBuilder(fileTypes, dirPath string,
120120
121121 for _ , tableMetaData := range tablesMetaData {
122122
123- var tableSQLBuilderTemplate TableSQLBuilder
123+ var tableSQLBuilder TableSQLBuilder
124124
125125 if fileTypes == "view" {
126- tableSQLBuilderTemplate = sqlBuilderTemplate .View (tableMetaData )
126+ tableSQLBuilder = sqlBuilderTemplate .View (tableMetaData )
127127 } else {
128- tableSQLBuilderTemplate = sqlBuilderTemplate .Table (tableMetaData )
128+ tableSQLBuilder = sqlBuilderTemplate .Table (tableMetaData )
129129 }
130130
131- if tableSQLBuilderTemplate .Skip {
131+ if tableSQLBuilder .Skip {
132132 continue
133133 }
134134
135- tableSQLBuilderPath := path .Join (dirPath , tableSQLBuilderTemplate .Path )
135+ tableSQLBuilderPath := path .Join (dirPath , tableSQLBuilder .Path )
136136
137137 err := utils .EnsureDirPath (tableSQLBuilderPath )
138138 throw .OnError (err )
139139
140140 text , err := generateTemplate (
141- autoGenWarningTemplate + getTableSQLBuilderTemplate ( dialect ) ,
141+ autoGenWarningTemplate + tableSQLBuilderTemplate ,
142142 tableMetaData ,
143143 template.FuncMap {
144144 "package" : func () string {
145- return tableSQLBuilderTemplate .PackageName ()
145+ return tableSQLBuilder .PackageName ()
146146 },
147147 "dialect" : func () jet.Dialect {
148148 return dialect
@@ -151,29 +151,33 @@ func processTableSQLBuilder(fileTypes, dirPath string,
151151 return schemaMetaData .Name
152152 },
153153 "tableTemplate" : func () TableSQLBuilder {
154- return tableSQLBuilderTemplate
154+ return tableSQLBuilder
155155 },
156156 "structImplName" : func () string { // postgres only
157- structName := tableSQLBuilderTemplate .TypeName
157+ structName := tableSQLBuilder .TypeName
158158 return string (strings .ToLower (structName )[0 ]) + structName [1 :]
159159 },
160160 "columnField" : func (columnMetaData metadata.Column ) TableSQLBuilderColumn {
161- return tableSQLBuilderTemplate .Column (columnMetaData )
161+ return tableSQLBuilder .Column (columnMetaData )
162+ },
163+ "toUpper" : strings .ToUpper ,
164+ "insertedRowAlias" : func () string {
165+ return insertedRowAlias (dialect )
162166 },
163167 })
164168 throw .OnError (err )
165169
166- err = utils .SaveGoFile (tableSQLBuilderPath , tableSQLBuilderTemplate .FileName , text )
170+ err = utils .SaveGoFile (tableSQLBuilderPath , tableSQLBuilder .FileName , text )
167171 throw .OnError (err )
168172 }
169173}
170174
171- func getTableSQLBuilderTemplate (dialect jet.Dialect ) string {
172- if dialect .Name () == "PostgreSQL" || dialect . Name () == "SQLite " {
173- return tableSQLBuilderTemplateWithEXCLUDED
175+ func insertedRowAlias (dialect jet.Dialect ) string {
176+ if dialect .Name () == "MySQL " {
177+ return "new"
174178 }
175179
176- return tableSQLBuilderTemplate
180+ return "excluded"
177181}
178182
179183func processTableModels (fileTypes , modelDirPath string , tablesMetaData []metadata.Table , modelTemplate Model ) {
0 commit comments