mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Implement returning clause
This commit is contained in:
@@ -227,6 +227,18 @@ func (q *Query) EndGroup() *Query {
|
|||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returning adds a RETURNING clause for both PostgreSQL and SQLite (3.35.0+)
|
||||||
|
func (q *Query) Returning(columns ...string) *Query {
|
||||||
|
q.Write(" RETURNING ")
|
||||||
|
if len(columns) == 1 && columns[0] == "*" {
|
||||||
|
q.Write("*")
|
||||||
|
} else {
|
||||||
|
q.Write(strings.Join(columns, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
return q
|
||||||
|
}
|
||||||
|
|
||||||
// Write adds a string to the query
|
// Write adds a string to the query
|
||||||
func (q *Query) Write(s string) *Query {
|
func (q *Query) Write(s string) *Query {
|
||||||
q.builder.WriteString(s)
|
q.builder.WriteString(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user