SQL Server insert - erroneous table name in OUTPUT clause
SQL Server insert - erroneous table name in OUTPUT clause
Hi,
I'm running Editor using Node.js to create a simple table of data. SQL Server (Azure) is the database. Editing works fine, but when I use the Create functionality, I get an error as below.
insert into [Member] ([Address1], [Address2], [Address3], <snip>) output inserted.[Member].[MemberID] values (@p0, @p1, @p2, @p3, <snip>) - Invalid column name 'Member'.
app.js:98
stack: RequestError: Invalid column name 'Member'.
The [Member] part of inserted.[Member].[MemberID] should not be there - any ideas what I'm doing wrong? There is a join to another table but that displays fine and works no problem when editing.
Thanks!
This question has an accepted answers - jump to answer
Answers
Hi @grapefruitmoon ,
Could you post your PHP and Editor/DataTables JS and config, please.
Cheers,
Colin
Sure!
DataTables JS -
Node.js -
Could you try:
please?
Thanks,
Allan
Hi Allan - I just tried that and I get the same error. The MemberID column is an Identity column on that table. I'm wondering if I'm doing something wrong with the aliasing that is causing the erroneous table name to appear.
I've cut the code down to a very simple example with just a few columns and still getting that error. If I remove the join it works fine, but when I add it in and pre-pend the column names with the relevant table name the insert fails. Stumped! Is there another way of joining without having to use the table name?
I'm with you now. This is an error in the Editor NodeJS libraries. I've used Knex as the database abstraction layer there and it doesn't automatically handle this case, so I've committed a fix for it now.
If you update to the master version from that repo that should resolve the issue!
Regards,
Allan
Sorry - this is the fixing commit - realised I committed a test change first...
Allan
Allan - amazing, this works perfectly! Thank you so much.
I'll take this opportunity to also say how much I'm loving DataTables and Editor, great product.