Skip to content

Commit

Permalink
Improve schema missing columns logging (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead authored Sep 1, 2023
1 parent cf71ed6 commit 6664cd6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/SqlBulkSyncFunction/Helpers/SqlStatementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ CONSTRAINT [PK_{2}] PRIMARY KEY CLUSTERED
public static string GetDeletedAtSourceSelectStatement(this TableSchema tableSchema)
{
if (tableSchema.Columns == null || tableSchema.Columns.Length == 0)
throw new Exception("Columns missing");
{
throw new Exception(
$"Columns for table {tableSchema.SourceTableName} missing ({tableSchema.Columns?.Length ?? -1})."
);
}

var primaryKeyColumns = tableSchema.Columns
.Where(column => column.IsPrimary)
Expand Down Expand Up @@ -299,7 +303,11 @@ public static string GetSourceSelectAllStatement(this TableSchema tableSchema)
public static string GetNewOrUpdatedAtSourceSelectStatement(this TableSchema tableSchema)
{
if (tableSchema.Columns == null || tableSchema.Columns.Length == 0)
throw new Exception("Columns missing");
{
throw new Exception(
$"Columns for table {tableSchema.SourceTableName} missing ({tableSchema.Columns?.Length ?? -1})."
);
}

var statement = (tableSchema.TargetVersion.CurrentVersion <= 1)
// ReSharper disable once UseStringInterpolation
Expand Down

0 comments on commit 6664cd6

Please sign in to comment.