Skip to content

The target table of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. #4535

@ajfleming1

Description

@ajfleming1

Bug description

When executing the prisma.create() statement on a SQL Server table that contains a trigger, the following error message is presented and no rows are created.

(node:37320) UnhandledPromiseRejectionWarning: Error:
Invalid `prisma.formSets.create()` invocation:


  Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(TokenError { code: 334, state: 1, class: 16, message: "The target table \'dbo.FormSetSequence\' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.", server: "dev-dfleming", procedure: "", line: 1 }) })
    at PrismaClientFetcher.request (C:\dev\graph-ql-prisma-ta\node_modules\@prisma\client\runtime\index.js:78786:15)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37320) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:37320) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How to reproduce

  1. Data setup. Create a valid Prisma / TypeScript project. Using SQL Server create a table with a trigger. An example trigger used for this test is below. Configure schema.prisma and prisma.yml to connect to the SQL Server instance.
CREATE OR ALTER TRIGGER [dbo].[FormSetSequence_InsertUpdateDelete]
				ON [dbo].[FormSetSequence]
				FOR INSERT, UPDATE, DELETE
				AS 
				SET NOCOUNT ON
			
				UPDATE LastChanges
				SET LastChanged = GetUtcDate()
				WHERE TrackedTable = 'LastDynamicFormChange';

				Update LastChanges
				SET LastChanged = GetUtcDate()
				WHERE TrackedTable = 'LastDynamicFormRuleChange';
  1. Create a schema using prisma introspect and prisma generate.
  2. Create a file index.ts and use the prisma client to call prisma.{tableWithTrigger}.create(data).
  3. Run npx ts-node index.ts.
  4. The error message should be presented to the user.

Expected behavior

The row should be inserted without error.

Prisma information

Environment & setup

  • OS: Windows 10
  • Database: SQL Server 15.0.4063.15
  • Node.js version: v14.8.0
  • Prisma version:
@prisma/cli          : 2.11.0
@prisma/client       : 2.11.0
Current platform     : windows
Query Engine         : query-engine 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ..\..\..\Users\dfleming-local\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ..\..\..\Users\dfleming-local\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ..\..\..\Users\dfleming-local\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary        : prisma-fmt 58369335532e47bdcec77a2f1e7c1fb83a463918 (at ..\..\..\Users\dfleming-local\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\prisma-fmt-windows.exe)
Studio               : 0.311.0
Preview Features     : microsoftSqlServer

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions