Skip to content

Support SQL Server XML modify() #6

Open
@tvedtorama

Description

@tvedtorama

I'm trying to do a:

UPDATE ball SET [cmdList].modify('insert <val>1030</val> into (/cmdList)[1]'), ogga.modify('insert <val>30</val> into (/ogga)[1]') WHERE [ballId] = @param3"

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:

const nastyModifyRegex = /\[modify\((.+?)\[1\]\]?\)\]\s?=\s?@param\d+/g

const correctNastyModifyFunction = (output: ISQLlyThings) => ({...output, sql: output.sql.replace(nastyModifyRegex, "modify($1[1])")})

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions