From a48e5f7f82bb51bd6eea068ff1821b1b04a6ab85 Mon Sep 17 00:00:00 2001 From: Sergey Kurt Date: Tue, 14 Mar 2017 16:52:54 +0300 Subject: [PATCH] MS SQL compatible query for RETURNING clause --- templates/15_insert.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/15_insert.tpl b/templates/15_insert.tpl index 4833bef..4906875 100644 --- a/templates/15_insert.tpl +++ b/templates/15_insert.tpl @@ -79,7 +79,11 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string {{if .UseLastInsertID -}} cache.retQuery = fmt.Sprintf("SELECT {{.LQ}}%s{{.RQ}} FROM {{$schemaTable}} WHERE %s", strings.Join(returnColumns, "{{.RQ}},{{.LQ}}"), strmangle.WhereClause("{{.LQ}}", "{{.RQ}}", {{if .Dialect.IndexPlaceholders}}1{{else}}0{{end}}, {{$varNameSingular}}PrimaryKeyColumns)) {{else -}} + {{if ne .DriverName "mssql" -}} cache.query += fmt.Sprintf(" RETURNING {{.LQ}}%s{{.RQ}}", strings.Join(returnColumns, "{{.RQ}},{{.LQ}}")) + {{- else -}} + cache.query += fmt.Sprintf(" OUTPUT {{.LQ}}%s{{.RQ}}", strings.Join(returnColumns, "{{.RQ}},{{.LQ}}")) + {{- end}} {{end -}} } }