Skip to content

Commit 2d10124

Browse files
committed
IgnoreRulesValidateTest: handled some particularities of RDBMSs
1 parent af6524c commit 2d10124

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

Orm/Xtensive.Orm.Tests/Storage/IgnoreRulesValidateTest.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public class MyEntity1 : Entity
233233
[Field, Key]
234234
public long Id { get; private set; }
235235

236-
[Field]
236+
[Field(Length = 50)]
237237
public string FirstColumn { get; set; }
238238

239239
[Field]
@@ -246,7 +246,7 @@ public class MyEntity2 : Entity
246246
[Field, Key]
247247
public long Id { get; private set; }
248248

249-
[Field]
249+
[Field(Length = 50)]
250250
public string FirstColumn { get; set; }
251251

252252
[Field]
@@ -262,7 +262,7 @@ public class MyEntity1 : Entity
262262
[Field, Key]
263263
public long Id { get; private set; }
264264

265-
[Field]
265+
[Field(Length = 50)]
266266
public string FirstColumn { get; set; }
267267

268268
[Field]
@@ -278,7 +278,7 @@ public class MyEntity1 : Entity
278278
[Field, Key]
279279
public long Id { get; private set; }
280280

281-
[Field]
281+
[Field(Length = 50)]
282282
public string FirstColumn { get; set; }
283283

284284
[Field]
@@ -304,7 +304,7 @@ public class MyEntity1 : Entity
304304
[Field, Key]
305305
public long Id { get; private set; }
306306

307-
[Field]
307+
[Field(Length = 50)]
308308
public string FirstColumn { get; set; }
309309

310310
[Field]
@@ -317,7 +317,7 @@ public class MyEntity2 : Entity
317317
[Field, Key]
318318
public long Id { get; private set; }
319319

320-
[Field]
320+
[Field(Length = 50)]
321321
public string FirstColumn { get; set; }
322322
}
323323
}
@@ -343,6 +343,7 @@ public class IgnoreRulesValidateTest
343343
typeof(ignorablePart.IgnoredTable), typeof(ignorablePart.FieldInjector) };
344344

345345
private readonly bool createConstraintsWithTable = StorageProviderInfo.Instance.Provider == StorageProvider.Sqlite;
346+
private readonly bool dropIndexOnKeyColumnDelete = StorageProviderInfo.Instance.Provider== StorageProvider.PostgreSql;
346347
private readonly SqlDriver sqlDriver = TestSqlDriver.Create(GetConnectionInfo());
347348

348349
private Key changedOrderKey;
@@ -629,6 +630,8 @@ public void DropTableWithIgnoredIndexTest()
629630
[Test]
630631
public void DropIncludedColumnOfIgnoredIndexTest()
631632
{
633+
Require.AllFeaturesSupported(ProviderFeatures.IncludedColumns);
634+
632635
BuildDomain(DomainUpgradeMode.Recreate, null, model3Types).Dispose();
633636

634637
var schema = GetCatalog().DefaultSchema;
@@ -650,16 +653,25 @@ public void DropKeyColumnOfIgnoredIndexTest()
650653
BuildDomain(DomainUpgradeMode.Recreate, null, model3Types).Dispose();
651654

652655
var schema = GetCatalog().DefaultSchema;
653-
var keyColumns = new string[] { "IndexedValue" };
654-
var includedColimns = new string[] { "FirstColumn" };
656+
var keyColumns = new string[] { "IndexedValue", "FirstColumn" };
655657

656-
CreateIndex(schema, "MyEntity2", "IX_Ignored_Index", keyColumns, includedColimns);
658+
CreateIndex(schema, "MyEntity2", "IX_Ignored_Index", keyColumns, null);
657659

658660
var ignoreRuleCollection = new IgnoreRuleCollection();
659661
_ = ignoreRuleCollection.IgnoreIndex("IX_Ignored_Index").WhenTable("MyEntity2");
660-
661-
_ = Assert.Throws<StorageException>(
662-
() => BuildDomain(DomainUpgradeMode.Perform, ignoreRuleCollection, model6Types).Dispose());
662+
if (dropIndexOnKeyColumnDelete) {
663+
BuildDomain(DomainUpgradeMode.Perform, ignoreRuleCollection, model6Types).Dispose();
664+
}
665+
else {
666+
if (createConstraintsWithTable) {
667+
_ = Assert.Throws<SchemaSynchronizationException>(
668+
() => BuildDomain(DomainUpgradeMode.Perform, ignoreRuleCollection, model6Types).Dispose());
669+
}
670+
else {
671+
_ = Assert.Throws<StorageException>(
672+
() => BuildDomain(DomainUpgradeMode.Perform, ignoreRuleCollection, model6Types).Dispose());
673+
}
674+
}
663675
}
664676

665677
[Test]

0 commit comments

Comments
 (0)