Skip to content

Commit 425f9fc

Browse files
committed
Fix SQL Server state store not working with case-sensitive collations (dapr#3272)
Signed-off-by: ItalyPaleAle <[email protected]>
1 parent 7c80133 commit 425f9fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

state/sqlserver/migration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func newMigration(metadata *sqlServerMetadata) migrator {
4646
func (m *migration) newMigrationResult() migrationResult {
4747
r := migrationResult{
4848
itemRefTableTypeName: fmt.Sprintf("[%s].%s_Table", m.metadata.Schema, m.metadata.TableName),
49-
upsertProcName: fmt.Sprintf("sp_Upsert_v4_%s", m.metadata.TableName),
49+
upsertProcName: fmt.Sprintf("sp_Upsert_v5_%s", m.metadata.TableName),
5050
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),
5151
deleteWithETagCommand: fmt.Sprintf(`DELETE [%s].[%s] WHERE [Key]=@Key AND [RowVersion]=@RowVersion`, m.metadata.Schema, m.metadata.TableName),
5252
deleteWithoutETagCommand: fmt.Sprintf(`DELETE [%s].[%s] WHERE [Key]=@Key`, m.metadata.Schema, m.metadata.TableName),
@@ -289,7 +289,7 @@ func (m *migration) ensureUpsertStoredProcedureExists(ctx context.Context, db *s
289289
IF (@RowVersion IS NOT NULL)
290290
BEGIN
291291
BEGIN TRANSACTION;
292-
IF NOT EXISTS (SELECT * FROM [%[3]s] WHERE [KEY]=@KEY AND RowVersion = @RowVersion)
292+
IF NOT EXISTS (SELECT * FROM [%[3]s] WHERE [Key]=@KEY AND RowVersion = @RowVersion)
293293
BEGIN
294294
THROW 2601, ''FIRST-WRITE: COMPETING RECORD ALREADY WRITTEN.'', 1
295295
END
@@ -303,7 +303,7 @@ func (m *migration) ensureUpsertStoredProcedureExists(ctx context.Context, db *s
303303
ELSE
304304
BEGIN
305305
BEGIN TRANSACTION;
306-
IF EXISTS (SELECT * FROM [%[3]s] WHERE [KEY]=@KEY)
306+
IF EXISTS (SELECT * FROM [%[3]s] WHERE [Key]=@KEY)
307307
BEGIN
308308
THROW 2601, ''FIRST-WRITE: COMPETING RECORD ALREADY WRITTEN.'', 1
309309
END

0 commit comments

Comments
 (0)