Giter Club home page Giter Club logo

Comments (10)

nyabutid avatar nyabutid commented on July 18, 2024

Current workaround:

Replace

// node_modules/loopback-connector-mssql/lib/mssql.js:157
var sql = "INSERT INTO " + tblName + " (" + fieldsAndData.fields + ")" + MsSQL.newline;
  sql += "OUTPUT INSERTED." + modelPKID + " AS insertId" + MsSQL.newline;
  sql += "VALUES (" + fieldsAndData.paramPlaceholders + ");";

with (use select scope_identity() instead of OUTPUT INSERTED)

// node_modules/loopback-connector-mssql/lib/mssql.js:157
var sql = "INSERT INTO " + tblName + " (" + fieldsAndData.fields + ")" + MsSQL.newline;
  sql += MsSQL.newline;
  sql += "VALUES (" + fieldsAndData.paramPlaceholders + ");SELECT SCOPE_IDENTITY() AS insertId;";

from loopback-connector-mssql.

raymondfeng avatar raymondfeng commented on July 18, 2024

What's going to happen if the PK is not an identity, for example, some sort of uuid?

from loopback-connector-mssql.

nyabutid avatar nyabutid commented on July 18, 2024

In my schema the IDENTITY is always the ID. Can this be provided as a configuration option instead to handle these caveats: when triggers are enabled on a table or when your PK is not the IDENTITY on the table? Or can you extend the SCOPE_IDENTITY to return the PK by selecting the row with that ID after an insert (I'd be concerned about performance on this option)?

from loopback-connector-mssql.

idoshamun avatar idoshamun commented on July 18, 2024

+1

from loopback-connector-mssql.

tuomastanner avatar tuomastanner commented on July 18, 2024

+1 Switched to @idosh s fork for the time being and all seems to work perfectly. Big thumbs up!

from loopback-connector-mssql.

SandeshSarfare avatar SandeshSarfare commented on July 18, 2024

Hello All,

I have the same issue however mssql.js which I have seems to be completely different and I am not sure how resolve error "The target table 'dbo.Test' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause".......

For an instance I've below code in my mssql.js where Output is inserted

MsSQL.prototype.buildInsertInto = function(model, fields, options,callback) {
var stmt = this.invokeSuper('buildInsertInto', model, fields, options);
var idName = this.idName(model);
if (idName) {
stmt.merge(MsSQL.newline + 'OUTPUT INSERTED.' +
this.columnEscaped(model, idName) + ' AS insertId');
}
return stmt;
};

from loopback-connector-mssql.

SandeshSarfare avatar SandeshSarfare commented on July 18, 2024

mssql.js which i have is different than one in this repo.....please suggest a workaround......otherwise we can not go live on production......Thanks in advance

from loopback-connector-mssql.

FoysalOsmany avatar FoysalOsmany commented on July 18, 2024

@raymondfeng Can you do the code review and merge?

#70

from loopback-connector-mssql.

stale avatar stale commented on July 18, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from loopback-connector-mssql.

stale avatar stale commented on July 18, 2024

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

from loopback-connector-mssql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.