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