Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update with returning does not work on MSSQL. Wrong placement for OUTPUT. #287

Open
Vintic opened this issue Aug 13, 2024 · 0 comments
Open

Comments

@Vintic
Copy link

Vintic commented Aug 13, 2024

Error: Incorrect syntax near 'OUTPUT'.
This code: ```
<cfset LOCAL.result = common.model.BaseModel::qb()
.from("zzz")
.returning("xxx")
.join("aaa", function(j){
j.on("aaa.ddd", "zzz.ddd")
})
.whereIn("aaa.id", [1,2,3])
.update({
"zzz.user_id": 1,
"zzz.created": NOW()
})
/>

returns this: ```
UPDATE [zzz]
SET [created] = {ts '2024-08-13 15:56:05'},
    [user_id] = 1
FROM [zzz]
         INNER JOIN [aaa] ON [aaa].[ddd] = [zzz].[ddd] OUTPUT INSERTED.[xxx]
WHERE [aaa].[id] IN (1, 2, 3)

Problem is that QB, place OUTPUT clause after WHERE, but it should be placed after SET clause.
In docs https://qb.ortusbooks.com/query-builder/executing-queries/inserts-updates-deletes#update
is placed correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant