Skip to content

Commit

Permalink
Fix SQL Server state store not working with case-sensitive collations (
Browse files Browse the repository at this point in the history
…#3272)

Signed-off-by: ItalyPaleAle <[email protected]>
  • Loading branch information
ItalyPaleAle authored Dec 14, 2023
1 parent a6710b9 commit 3dc465e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions state/sqlserver/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func newMigration(metadata *sqlServerMetadata) migrator {
func (m *migration) newMigrationResult() migrationResult {
r := migrationResult{
itemRefTableTypeName: fmt.Sprintf("[%s].%s_Table", m.metadata.Schema, m.metadata.TableName),
upsertProcName: fmt.Sprintf("sp_Upsert_v4_%s", m.metadata.TableName),
upsertProcName: fmt.Sprintf("sp_Upsert_v5_%s", m.metadata.TableName),
getCommand: fmt.Sprintf("SELECT [Data], [RowVersion], [ExpireDate] FROM [%s].[%s] WHERE [Key] = @Key AND ([ExpireDate] IS NULL OR [ExpireDate] > GETDATE())", m.metadata.Schema, m.metadata.TableName),
deleteWithETagCommand: fmt.Sprintf(`DELETE [%s].[%s] WHERE [Key]=@Key AND [RowVersion]=@RowVersion`, m.metadata.Schema, m.metadata.TableName),
deleteWithoutETagCommand: fmt.Sprintf(`DELETE [%s].[%s] WHERE [Key]=@Key`, m.metadata.Schema, m.metadata.TableName),
Expand Down Expand Up @@ -289,7 +289,7 @@ func (m *migration) ensureUpsertStoredProcedureExists(ctx context.Context, db *s
IF (@RowVersion IS NOT NULL)
BEGIN
BEGIN TRANSACTION;
IF NOT EXISTS (SELECT * FROM [%[3]s] WHERE [KEY]=@KEY AND RowVersion = @RowVersion)
IF NOT EXISTS (SELECT * FROM [%[3]s] WHERE [Key]=@KEY AND RowVersion = @RowVersion)
BEGIN
THROW 2601, ''FIRST-WRITE: COMPETING RECORD ALREADY WRITTEN.'', 1
END
Expand All @@ -303,7 +303,7 @@ func (m *migration) ensureUpsertStoredProcedureExists(ctx context.Context, db *s
ELSE
BEGIN
BEGIN TRANSACTION;
IF EXISTS (SELECT * FROM [%[3]s] WHERE [KEY]=@KEY)
IF EXISTS (SELECT * FROM [%[3]s] WHERE [Key]=@KEY)
BEGIN
THROW 2601, ''FIRST-WRITE: COMPETING RECORD ALREADY WRITTEN.'', 1
END
Expand Down

0 comments on commit 3dc465e

Please sign in to comment.