Masterminds / squirrel

Fluent SQL generation for golang
Other
6.67k stars 458 forks source link

No way to add options between INTO and VALUES on INSERT (likely MS SQL specific) #348

Open dmakushin opened 1 year ago

dmakushin commented 1 year ago

MS SQL has a specific way for definition of returning values. It is similar to Postgres' RETURNING ID but should be placed in the middle of the query, so suffix is not applicable.

Example (from stackoverflow):

INSERT INTO MyTable(Name, Address, PhoneNo)
OUTPUT INSERTED.ID
VALUES ('Yatrix', '1234 Address Stuff', '1112223333')
dmakushin commented 1 year ago

What about adding of some generic method which can be used for specification of returning value for all kind of drivers? It could be complex since the query clause which specifies it can be related to different parts of the query depending on SQL dialect.

DrBlury commented 1 year ago

Any update on this? Is this planned? I would really love to see a returning or output for the ID of the inserted dataset.