-
Notifications
You must be signed in to change notification settings - Fork 20
Support SQL Server XML modify() #6
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
You are right. There is no plugin-system, because I would have all changes done by the community should end up in a pull request. So feel free to fork this repo and add a new helper "modify" for SQL-Server and make a pull request. If you need some help creating new operators and helper pleas let me know. |
I would love to do so if I find the time. I believe this library serves an important purpose, especially if it has wide support for the various SQL-dialects. Do you see any fundamental problems building support for the |
There should be no problem writing the new modify-helper class. For Inline-SQL use the Helper "__" https://github.com/planetarydev/json-sql-builder2/tree/master/sql/helpers/misc/__. |
I would suggest some usage like this: sql.$update({
$table: "ball",
$setXML: {
cmdList: { $modifyXML: { __: "insert <val>1030</val> into (/cmdList)[1]" } }
},
$where: {
ballId: 1234
}
} In this case you need to write the $setXML helper and $modifyXML helper. You can't use the "normal" $set helper because this will assign a new value to a identifier. But you need a method-call like ".modify(...)" |
Thanks, this makes sense. I look into it when if I get a chance. |
I'm trying to do a:
Or actually, I wanted the inserts to be sql arguments as well, but that does not seem to fit very well with SQL server rigid regime.
I ended up assigning the modify string to the json key in the $set, and setting the value (sql argument) to null. Then I had to do a nasty regex to ret rid of the argument part and some misplaced brackets:
It would be nice to have support for
modify
in the library. I tried to read up on operators, but it seems this needs to be built into the library, no plugin-system available.The text was updated successfully, but these errors were encountered: