Skip to content

Commit

Permalink
Use coalesce instead of iif (fixes #77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Feb 10, 2021
1 parent 78c21cb commit 266cc2f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions SyncChanges.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private static void CreateDatabase(string name)
using (var db = GetDatabase())
{
db.Execute($"create database [{name}]");
db.Execute($"alter database [{name}] set COMPATIBILITY_LEVEL = 100");
db.Execute($"alter database [{name}] set CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)");
if ((string)TestContext.CurrentContext.Test.Properties.Get("snapshot") != "off")
{
Expand Down
2 changes: 1 addition & 1 deletion SyncChanges/Synchronizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private IList<TableInfo> GetTables(DatabaseInfo dbInfo)
{
using (var db = GetDatabase(dbInfo.ConnectionString, DatabaseType.SqlServer2008))
{
var sql = @"select TableName, ColumnName, iif(max(cast(is_primary_key as tinyint)) = 1, 1, 0) PrimaryKey from
var sql = @"select TableName, ColumnName, coalesce(max(cast(is_primary_key as tinyint)), 0) PrimaryKey from
(
select ('[' + s.name + '].[' + t.name + ']') TableName, ('[' + COL_NAME(t.object_id, a.column_id) + ']') ColumnName,
i.is_primary_key
Expand Down

0 comments on commit 266cc2f

Please sign in to comment.