Skip to content

Commit f6bd5b1

Browse files
Merge pull request #130 from dotnetprojects/remove-all-constraints
Renamings
2 parents 120a1ad + b6b289d commit f6bd5b1

File tree

11 files changed

+54
-41
lines changed

11 files changed

+54
-41
lines changed

.editorconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,16 @@ dotnet_naming_style.interface_style.required_prefix = I
8989
dotnet_naming_style.async_method_style.capitalization = pascal_case
9090
dotnet_naming_style.async_method_style.required_suffix = Async
9191

92+
dotnet_naming_style.underscore_pascalcase.capitalization = pascal_case
93+
dotnet_naming_style.underscore_pascalcase.required_prefix = _
94+
9295
# === Symbols ===
9396
dotnet_naming_symbols.public_api_symbols.applicable_kinds = class, struct, enum, property, method, event, field, delegate, namespace
9497
dotnet_naming_symbols.public_api_symbols.applicable_accessibilities = public, protected, protected_internal
9598

99+
dotnet_naming_symbols.protected_fields.applicable_kinds = field
100+
dotnet_naming_symbols.protected_fields.applicable_accessibilities = protected
101+
96102
dotnet_naming_symbols.private_fields.applicable_kinds = field
97103
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
98104

@@ -113,6 +119,10 @@ dotnet_naming_rule.public_api_should_be_pascal_case.symbols = public_api_symbols
113119
dotnet_naming_rule.public_api_should_be_pascal_case.style = pascal_case_style
114120
dotnet_naming_rule.public_api_should_be_pascal_case.severity = warning
115121

122+
dotnet_naming_rule.protected_fields_should_be_prefixed_with_underscore_and_pascalcase.symbols = protected_fields
123+
dotnet_naming_rule.protected_fields_should_be_prefixed_with_underscore_and_pascalcase.style = underscore_pascalcase
124+
dotnet_naming_rule.protected_fields_should_be_prefixed_with_underscore_and_pascalcase.severity = warning
125+
116126
dotnet_naming_rule.private_fields_should_be_underscore_camel.symbols = private_fields
117127
dotnet_naming_rule.private_fields_should_be_underscore_camel.style = underscore_camel_case_style
118128
dotnet_naming_rule.private_fields_should_be_underscore_camel.severity = warning
@@ -167,7 +177,7 @@ csharp_new_line_between_query_expression_clauses = true
167177
csharp_indent_block_contents = true
168178
csharp_indent_braces = false
169179
csharp_indent_case_contents = true
170-
csharp_indent_case_contents_when_block = true
180+
csharp_indent_case_contents_when_block = false
171181
csharp_indent_switch_labels = true
172182
csharp_indent_labels = flush_left
173183

@@ -229,6 +239,7 @@ dotnet_diagnostic.SA1600.severity = suggestion # Elements must be documented
229239
dotnet_diagnostic.SA1623.severity = suggestion # Property summary must match accessor
230240

231241
# Code quality
242+
dotnet_diagnostic.IDE0005.severity = error # Unused usings
232243
dotnet_diagnostic.IDE0040.severity = warning # Accessibility modifiers
233244
dotnet_diagnostic.IDE0052.severity = warning # Remove unread private members
234245
dotnet_diagnostic.IDE0059.severity = warning # Unused assignment

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.wordWrapColumn": 230
3+
}

src/Migrator.Tests/Providers/Generic/Generic_UpdateFromTableToTableTestsBase.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ public void UpdateFromTableToTable_Success()
5656
Provider.Insert(tableNameTarget, [columnName1Target, columnName2Target, columnName3Target, columnName4Target, columnName5Target], [1, 3, "target no update", "target no update", "target no update"]);
5757

5858
// Act
59-
Provider.UpdateFromTableToTable(
59+
Provider.UpdateTargetFromSource(
6060
tableNameSource,
6161
tableNameTarget,
6262
[
63-
new ColumnPair { ColumnNameSourceNotQuoted = columnName3Source, ColumnNameTargetNotQuoted = columnName3Target },
64-
new ColumnPair { ColumnNameSourceNotQuoted = columnName4Source, ColumnNameTargetNotQuoted = columnName4Target },
65-
new ColumnPair { ColumnNameSourceNotQuoted = columnName5Source, ColumnNameTargetNotQuoted = columnName5Target }
63+
new () { ColumnNameSource = columnName3Source, ColumnNameTarget = columnName3Target },
64+
new () { ColumnNameSource = columnName4Source, ColumnNameTarget = columnName4Target },
65+
new () { ColumnNameSource = columnName5Source, ColumnNameTarget = columnName5Target }
6666
],
6767
[
68-
new ColumnPair { ColumnNameSourceNotQuoted = columnName1Source, ColumnNameTargetNotQuoted = columnName1Target },
69-
new ColumnPair { ColumnNameSourceNotQuoted = columnName2Source, ColumnNameTargetNotQuoted = columnName2Target }
70-
]
71-
);
68+
new () { ColumnNameSource = columnName1Source, ColumnNameTarget = columnName1Target },
69+
new () { ColumnNameSource = columnName2Source, ColumnNameTarget = columnName2Target }
70+
]);
7271

7372
// Assert
7473
List<UpdateFromTableToTableModel> targetRows = [];

src/Migrator/Framework/ITransformationProvider.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,13 @@ IDataReader SelectComplex(IDbCommand cmd, string table, string[] columns, string
647647
int Update(string table, string[] columns, object[] values, string[] whereColumns, object[] whereValues);
648648

649649
/// <summary>
650-
/// Updates the target table using data from the source table updating the target table. Make sure to only use primary keys or unique columns in <paramref name="conditionColumnPairs"/>
650+
/// Updates the target table with data from the source table. Make sure to use primary key or unique columns in <paramref name="matchColumnPairs"/>
651651
/// </summary>
652-
/// <param name="tableSourceNotQuoted"></param>
653-
/// <param name="tableTargetNotQuoted"></param>
654-
/// <param name="fromSourceToTargetColumnPairs">Pairs that represent the name of the source column and the column in the target table to be updated.</param>
655-
/// <param name="conditionColumnPairs">Pairs that represent the name of the source column and the name of the target tabel used to match the rows.</param>
656-
void UpdateFromTableToTable(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs);
652+
/// <param name="tableNameSource">Source table name (unquoted).</param>
653+
/// <param name="tableNameTarget">Target table name (unquoted).</param>
654+
/// <param name="copyColumnPairs">Pairs of columns that are used to copy data from column in source table to column in target table.</param>
655+
/// <param name="matchColumnPairs">Pairs of columns that are used to match rows in source and target table.</param>
656+
void UpdateTargetFromSource(string tableNameSource, string tableNameTarget, ColumnPair[] copyColumnPairs, ColumnPair[] matchColumnPairs);
657657

658658
/// <summary>
659659
/// Get a command instance

src/Migrator/Providers/Impl/Oracle/OracleTransformationProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public override bool IndexExists(string table, string name)
908908
return Convert.ToInt32(scalar) == 1;
909909
}
910910

911-
public override void UpdateFromTableToTable(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
911+
public override void UpdateTargetFromSource(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
912912
{
913913
if (!TableExists(tableSourceNotQuoted))
914914
{
@@ -925,7 +925,7 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
925925
throw new Exception($"{nameof(fromSourceToTargetColumnPairs)} is empty.");
926926
}
927927

928-
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
928+
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
929929
{
930930
throw new Exception($"One of the strings in {nameof(fromSourceToTargetColumnPairs)} is null or empty");
931931
}
@@ -935,17 +935,17 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
935935
throw new Exception($"{nameof(conditionColumnPairs)} is empty.");
936936
}
937937

938-
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
938+
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
939939
{
940940
throw new Exception($"One of the strings in {nameof(conditionColumnPairs)} is null or empty");
941941
}
942942

943943
var tableNameSource = QuoteTableNameIfRequired(tableSourceNotQuoted);
944944
var tableNameTarget = QuoteTableNameIfRequired(tableTargetNotQuoted);
945945

946-
var conditionStrings = conditionColumnPairs.Select(x => $"t.{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)}");
946+
var conditionStrings = conditionColumnPairs.Select(x => $"t.{QuoteColumnNameIfRequired(x.ColumnNameTarget)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSource)}");
947947

948-
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)}").ToList();
948+
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTarget)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSource)}").ToList();
949949

950950
var conditionStringsJoined = string.Join(" AND ", conditionStrings);
951951
var assignStringsJoined = string.Join(", ", assignStrings);

src/Migrator/Providers/Impl/PostgreSQL/PostgreSQLTransformationProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ public override bool IndexExists(string table, string name)
816816
return reader.Read();
817817
}
818818

819-
public override void UpdateFromTableToTable(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
819+
public override void UpdateTargetFromSource(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
820820
{
821821
if (!TableExists(tableSourceNotQuoted))
822822
{
@@ -833,7 +833,7 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
833833
throw new Exception($"{nameof(fromSourceToTargetColumnPairs)} is empty.");
834834
}
835835

836-
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
836+
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
837837
{
838838
throw new Exception($"One of the strings in {nameof(fromSourceToTargetColumnPairs)} is null or empty");
839839
}
@@ -843,17 +843,17 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
843843
throw new Exception($"{nameof(conditionColumnPairs)} is empty.");
844844
}
845845

846-
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
846+
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
847847
{
848848
throw new Exception($"One of the strings in {nameof(conditionColumnPairs)} is null or empty");
849849
}
850850

851851
var tableNameSource = QuoteTableNameIfRequired(tableSourceNotQuoted);
852852
var tableNameTarget = QuoteTableNameIfRequired(tableTargetNotQuoted);
853853

854-
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)} = {tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)}").ToList();
854+
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTarget)} = {tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSource)}").ToList();
855855

856-
var conditionStrings = conditionColumnPairs.Select(x => $"{tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)} = {tableNameTarget}.{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)}");
856+
var conditionStrings = conditionColumnPairs.Select(x => $"{tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSource)} = {tableNameTarget}.{QuoteColumnNameIfRequired(x.ColumnNameTarget)}");
857857

858858
var assignStringsJoined = string.Join(", ", assignStrings);
859859
var conditionStringsJoined = string.Join(" AND ", conditionStrings);

src/Migrator/Providers/Impl/SQLite/SQLiteTransformationProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public override ForeignKeyConstraint[] GetForeignKeyConstraints(string tableName
210210
return foreignKeyConstraints.ToArray();
211211
}
212212

213-
public override void UpdateFromTableToTable(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
213+
public override void UpdateTargetFromSource(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
214214
{
215215
if (!TableExists(tableSourceNotQuoted))
216216
{
@@ -227,7 +227,7 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
227227
throw new Exception($"{nameof(fromSourceToTargetColumnPairs)} is empty.");
228228
}
229229

230-
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
230+
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
231231
{
232232
throw new Exception($"One of the strings in {nameof(fromSourceToTargetColumnPairs)} is null or empty");
233233
}
@@ -237,17 +237,17 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
237237
throw new Exception($"{nameof(conditionColumnPairs)} is empty.");
238238
}
239239

240-
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
240+
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
241241
{
242242
throw new Exception($"One of the strings in {nameof(conditionColumnPairs)} is null or empty");
243243
}
244244

245245
var tableNameSource = QuoteTableNameIfRequired(tableSourceNotQuoted);
246246
var tableNameTarget = QuoteTableNameIfRequired(tableTargetNotQuoted);
247247

248-
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)} = {tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)}").ToList();
248+
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTarget)} = {tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSource)}").ToList();
249249

250-
var conditionStrings = conditionColumnPairs.Select(x => $"{tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)} = {tableNameTarget}.{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)}");
250+
var conditionStrings = conditionColumnPairs.Select(x => $"{tableNameSource}.{QuoteColumnNameIfRequired(x.ColumnNameSource)} = {tableNameTarget}.{QuoteColumnNameIfRequired(x.ColumnNameTarget)}");
251251

252252
var assignStringsJoined = string.Join(", ", assignStrings);
253253
var conditionStringsJoined = string.Join(" AND ", conditionStrings);

src/Migrator/Providers/Impl/SqlServer/SqlServerTransformationProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ public override void RenameTable(string oldName, string newName)
801801
ExecuteNonQuery(string.Format("EXEC sp_rename '{0}', '{1}'", oldName, newName));
802802
}
803803

804-
public override void UpdateFromTableToTable(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
804+
public override void UpdateTargetFromSource(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
805805
{
806806
if (!TableExists(tableSourceNotQuoted))
807807
{
@@ -818,7 +818,7 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
818818
throw new Exception($"{nameof(fromSourceToTargetColumnPairs)} is empty.");
819819
}
820820

821-
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
821+
if (fromSourceToTargetColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
822822
{
823823
throw new Exception($"One of the strings in {nameof(fromSourceToTargetColumnPairs)} is null or empty");
824824
}
@@ -828,17 +828,17 @@ public override void UpdateFromTableToTable(string tableSourceNotQuoted, string
828828
throw new Exception($"{nameof(conditionColumnPairs)} is empty.");
829829
}
830830

831-
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSourceNotQuoted) || string.IsNullOrWhiteSpace(x.ColumnNameTargetNotQuoted)))
831+
if (conditionColumnPairs.Any(x => string.IsNullOrWhiteSpace(x.ColumnNameSource) || string.IsNullOrWhiteSpace(x.ColumnNameTarget)))
832832
{
833833
throw new Exception($"One of the strings in {nameof(conditionColumnPairs)} is null or empty");
834834
}
835835

836836
var tableNameSource = QuoteTableNameIfRequired(tableSourceNotQuoted);
837837
var tableNameTarget = QuoteTableNameIfRequired(tableTargetNotQuoted);
838838

839-
var conditionStrings = conditionColumnPairs.Select(x => $"t.{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)}");
839+
var conditionStrings = conditionColumnPairs.Select(x => $"t.{QuoteColumnNameIfRequired(x.ColumnNameTarget)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSource)}");
840840

841-
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTargetNotQuoted)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSourceNotQuoted)}").ToList();
841+
var assignStrings = fromSourceToTargetColumnPairs.Select(x => $"{QuoteColumnNameIfRequired(x.ColumnNameTarget)} = s.{QuoteColumnNameIfRequired(x.ColumnNameSource)}").ToList();
842842

843843
var conditionStringsJoined = string.Join(" AND ", conditionStrings);
844844
var assignStringsJoined = string.Join(", ", assignStrings);

src/Migrator/Providers/Models/ColumnPair.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ namespace DotNetProjects.Migrator.Framework.Models;
66
public class ColumnPair
77
{
88
/// <summary>
9-
/// Gets or sets the column name of the source table. Use the not quoted column name.
9+
/// Gets or sets the column name of the source table. Use the unquoted column name.
1010
/// </summary>
11-
public string ColumnNameSourceNotQuoted { get; set; }
11+
public string ColumnNameSource { get; set; }
1212

1313
/// <summary>
14-
/// Gets or sets the column name of the target table. Use the not quoted column name.
14+
/// Gets or sets the column name of the target table. Use the unquoted column name.
1515
/// </summary>
16-
public string ColumnNameTargetNotQuoted { get; set; }
16+
public string ColumnNameTarget { get; set; }
1717
}

src/Migrator/Providers/NoOpTransformationProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ public void AddColumn(string table, string column, MigratorDbType type, object d
593593
throw new NotImplementedException();
594594
}
595595

596-
public void UpdateFromTableToTable(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
596+
public void UpdateTargetFromSource(string tableSourceNotQuoted, string tableTargetNotQuoted, ColumnPair[] fromSourceToTargetColumnPairs, ColumnPair[] conditionColumnPairs)
597597
{
598598
throw new NotImplementedException();
599599
}

0 commit comments

Comments
 (0)