SqlServer not support OUTPUT with INSERT and triggers
还没有人认领这个 Issue。
评估
调研方向
从 Providers.MsSqlServer.fs 开始,尤其是第 302-307 行,并沿着堆栈跟踪中显示的 ProcessUpdates 路径进行调查。在启用 trigger 的 SQL Server 表上复现该 insert,然后确定 provider 应如何处理 OUTPUT 子句,以及提议的配置选项应如何影响它;对于此 schema,SubmitUpdates 成功且不影响正常 insert 即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hi,
Description
On SqlServer, I cannot insert if my table has trigger.
SqlServer don't allow OUTPUT in INSERT request if the table has trigger
Repro steps
Create table with trigger :
CREATE TABLE [dbo].[TableWithTrigger](
[Id] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF_TableWithTrigger_Id] DEFAULT (newid()),
[Text1] [nvarchar](50) NULL,
[Text2] [nvarchar](50) NULL,
CONSTRAINT [PK_TableWithTrigger] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Try to insert
type Sql = SqlDataProvider<Common.DatabaseProviderTypes.MSSQLSERVER, connStr>
let ctx = Sql.GetDataContext()
let row = ctx.Dbo.TableWithTrigger.Create()
row.Id <- Guid.NewGuid()
row.Text1 <- "Essai"
ctx.SubmitUpdates()
Expected behavior
Insert new row
Actual behavior
I have sql error :
System.Data.SqlClient.SqlException: The target table 'dbo.TableWithTrigger' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteScalar()
at <StartupCode$FSharp-Data-SqlProvider>.$Providers.MsSqlServer.FSharp-Data-Sql-Common-ISqlProvider-ProcessUpdates@716.Invoke(SqlEntity e)
at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
at FSharp.Data.Sql.Providers.MSSqlServerProvider.FSharp-Data-Sql-Common-ISqlProvider-ProcessUpdates(IDbConnection con, ConcurrentDictionary`2 entities)
at <StartupCode$FSharp-Data-SqlProvider>.$SqlRuntime.DataContext.f@1-28(SqlDataContext __, IDbConnection con, Unit unitVar0)
at FSharp.Data.Sql.Runtime.SqlDataContext.FSharp-Data-Sql-Common-ISqlDataContext-SubmitPendingChanges()
Known workarounds
A create a fork and remove line 302-307 of Providers.MsSqlServer.fs
I propose to add config key to disable this behavior
Related information
- .Net 4.6.2
- Version 1.0.28
- 主要语言
- F#
- 星标
- 627
- 派生
- 147
- 平均合并
- 2 小时 2 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fsprojects/SQLProvider 的其他 Issue
-
enhancement
难度 3/5 1-2 天 新手友好度 55/100
fsprojects/SQLProvider#872 · 2 条评论 ·
-
Repo Assist? 未关闭enhancement
难度 5/5 一周以上 新手友好度 10/100
fsprojects/SQLProvider#870 · 1 条评论 ·
-
postgresql
难度 4/5 3-5 天 新手友好度 58/100
fsprojects/SQLProvider#869 · 2 条评论 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 42/100
fsprojects/SQLProvider#868 · 2 条评论 ·
-
sql server
难度 4/5 3-5 天 新手友好度 45/100
fsprojects/SQLProvider#851 · 1 条评论 ·
查看 fsprojects/SQLProvider 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
Business User Story
难度 2/5 1-3 小时 新手友好度 75/100
-
[Documentation Request] vLLM kv_load_failure_policy doesn't apply to load failures in L2 adapters 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
0. Needs triage bug
难度 2/5 1-3 小时 新手友好度 75/100