Skip to content

Commit 86fe112

Browse files
committed
Added the IDbSetting and DbSetting a new property named IsSchemaSupported.
1 parent d668b20 commit 86fe112

43 files changed

Lines changed: 314 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/Providers/RepoDb.AuroraDb.MySqlConnector/RepoDb.AuroraDb.MySqlConnector.UnitTests/DbSettingTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public void TestAuroraDbDbSettingIsMultiStatementExecutableProperty()
8383
Assert.IsTrue(setting.IsMultiStatementExecutable);
8484
}
8585

86+
[TestMethod]
87+
public void TestAuroraDbDbSettingIsSchemaSupportedProperty()
88+
{
89+
// Setup
90+
var setting = DbSettingMapper.Get<AuroraDbConnection>();
91+
92+
// Assert
93+
Assert.IsFalse(setting.IsSchemaSupported);
94+
}
95+
8696
[TestMethod]
8797
public void TestAuroraDbDbSettingIsUseUpsertProperty()
8898
{

‎src/Providers/RepoDb.AuroraDb.MySqlConnector/RepoDb.AuroraDb.MySqlConnector/DbSettings/AuroraDbDbSetting.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public AuroraDbDbSetting()
2929
IsMultiStatementExecutable = true;
3030
IsInsertAllBatchable = true;
3131
IsPreparable = false;
32+
IsSchemaSupported = false;
3233
IsTransactionSupported = true;
3334
IsUseUpsert = false;
3435
RequiresDbTypeBeforeValue = false;

‎src/Providers/RepoDb.AuroraDb.PostgreSql/RepoDb.AuroraDb.PostgreSql.UnitTests/DbSettingTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public void TestAuroraDbDbSettingIsMultiStatementExecutableProperty()
8383
Assert.IsTrue(setting.IsMultiStatementExecutable);
8484
}
8585

86+
[TestMethod]
87+
public void TestAuroraDbDbSettingIsSchemaSupportedProperty()
88+
{
89+
// Setup
90+
var setting = DbSettingMapper.Get<AuroraDbConnection>();
91+
92+
// Assert
93+
Assert.IsTrue(setting.IsSchemaSupported);
94+
}
95+
8696
[TestMethod]
8797
public void TestAuroraDbDbSettingIsUseUpsertProperty()
8898
{

‎src/Providers/RepoDb.AuroraDb.PostgreSql/RepoDb.AuroraDb.PostgreSql/DbSettings/AuroraDbDbSetting.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public AuroraDbDbSetting()
2929
IsMultiStatementExecutable = true;
3030
IsInsertAllBatchable = true;
3131
IsPreparable = true;
32+
IsSchemaSupported = true;
3233
IsTransactionSupported = true;
3334
IsUseUpsert = false;
3435
RequiresDbTypeBeforeValue = false;

‎src/Providers/RepoDb.ClickHouse/RepoDb.ClickHouse.UnitTests/DbSettingTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ public void TestClickHouseDbSettingIsMultiStatementExecutableProperty()
8484
Assert.IsFalse(setting.IsMultiStatementExecutable);
8585
}
8686

87+
[TestMethod]
88+
public void TestClickHouseDbSettingIsSchemaSupportedProperty()
89+
{
90+
// Setup
91+
var setting = DbSettingMapper.Get<ClickHouseConnection>();
92+
93+
// Assert
94+
Assert.IsFalse(setting.IsSchemaSupported);
95+
}
96+
8797
[TestMethod]
8898
public void TestClickHouseDbSettingIsUseUpsertProperty()
8999
{

‎src/Providers/RepoDb.ClickHouse/RepoDb.ClickHouse/DbSettings/ClickHouseDbSetting.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public ClickHouseDbSetting()
2929
IsMultiStatementExecutable = false;
3030
IsInsertAllBatchable = false;
3131
IsPreparable = false;
32+
IsSchemaSupported = false;
3233
IsTransactionSupported = false;
3334
IsUseUpsert = false;
3435
RequiresDbTypeBeforeValue = false;

‎src/Providers/RepoDb.CockroachDb/RepoDb.CockroachDb.UnitTests/DbSettingTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public void TestCockroachDbDbSettingIsMultiStatementExecutableProperty()
8383
Assert.IsTrue(setting.IsMultiStatementExecutable);
8484
}
8585

86+
[TestMethod]
87+
public void TestCockroachDbDbSettingIsSchemaSupportedProperty()
88+
{
89+
// Setup
90+
var setting = DbSettingMapper.Get<CockroachDbConnection>();
91+
92+
// Assert
93+
Assert.IsTrue(setting.IsSchemaSupported);
94+
}
95+
8696
[TestMethod]
8797
public void TestCockroachDbDbSettingIsUseUpsertProperty()
8898
{

‎src/Providers/RepoDb.CockroachDb/RepoDb.CockroachDb/DbSettings/CockroachDbDbSetting.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public CockroachDbDbSetting()
2929
IsMultiStatementExecutable = true;
3030
IsInsertAllBatchable = true;
3131
IsPreparable = true;
32+
IsSchemaSupported = true;
3233
IsTransactionSupported = true;
3334
IsUseUpsert = false;
3435
RequiresDbTypeBeforeValue = false;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#region Copyright Attributions
2+
3+
// Copyright (c) 2026 Michael Camara Pendon.
4+
// Licensed under the Apache License, Version 2.0.
5+
// See the LICENSE file in the project root for full license information.
6+
7+
#endregion
8+
9+
using Microsoft.VisualStudio.TestTools.UnitTesting;
10+
using RepoDb.DbSettings;
11+
using RepoDb.Interfaces;
12+
using RepoDb.UnitTests.CustomObjects;
13+
14+
namespace RepoDb.UnitTests
15+
{
16+
[TestClass]
17+
public class DbSettingIsSchemaSupportedTest
18+
{
19+
private sealed class NoSchemaDbSetting : BaseDbSetting
20+
{
21+
public NoSchemaDbSetting()
22+
{
23+
IsSchemaSupported = false;
24+
}
25+
}
26+
27+
[TestMethod]
28+
public void TestBaseDbSettingIsSchemaSupportedByDefault()
29+
{
30+
// Act
31+
var setting = new CustomDbSetting();
32+
33+
// Assert
34+
Assert.IsTrue(setting.IsSchemaSupported);
35+
}
36+
37+
[TestMethod]
38+
public void TestBaseDbSettingIsSchemaSupportedCanBeSetByTheDerivedSetting()
39+
{
40+
// Act
41+
var setting = new NoSchemaDbSetting();
42+
43+
// Assert
44+
Assert.IsFalse(setting.IsSchemaSupported);
45+
}
46+
47+
[TestMethod]
48+
public void TestDbSettingIsSchemaSupportedIsExposedByTheInterface()
49+
{
50+
// Act
51+
IDbSetting supported = new CustomDbSetting();
52+
IDbSetting unsupported = new NoSchemaDbSetting();
53+
54+
// Assert
55+
Assert.IsTrue(supported.IsSchemaSupported);
56+
Assert.IsFalse(unsupported.IsSchemaSupported);
57+
}
58+
59+
[TestMethod]
60+
public void TestBaseDbSettingEqualityTakesIsSchemaSupportedIntoAccount()
61+
{
62+
// Act
63+
var unsupported = new NoSchemaDbSetting();
64+
var sameAsUnsupported = new NoSchemaDbSetting();
65+
var supported = new SchemaDbSetting();
66+
67+
// Assert
68+
Assert.IsTrue(unsupported.Equals(sameAsUnsupported));
69+
Assert.AreEqual(unsupported.GetHashCode(), sameAsUnsupported.GetHashCode());
70+
Assert.IsFalse(unsupported.Equals(supported));
71+
Assert.AreNotEqual(unsupported.GetHashCode(), supported.GetHashCode());
72+
}
73+
74+
private sealed class SchemaDbSetting : BaseDbSetting
75+
{
76+
}
77+
}
78+
}

‎src/Providers/RepoDb.Core/RepoDb/DbSettings/BaseDbSetting.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ protected BaseDbSetting()
3232
IsExecuteReaderDisposable = true;
3333
IsMultiStatementExecutable = true;
3434
IsPreparable = true;
35+
IsSchemaSupported = true;
3536
IsTransactionSupported = true;
3637
IsUseUpsert = false;
3738
RequiresDbTypeBeforeValue = false;
@@ -102,6 +103,12 @@ protected BaseDbSetting()
102103
/// </summary>
103104
public bool IsPreparable { get; protected set; }
104105

106+
/// <summary>
107+
/// Gets a value that indicates whether the current DB Provider supports the schemas (i.e.: <c>dbo</c> or <c>public</c>) that own the tables of a database.
108+
/// When <c>false</c>, a table is only identified by its name (and by the database, if the provider has one).
109+
/// </summary>
110+
public bool IsSchemaSupported { get; protected set; }
111+
105112
/// <summary>
106113
/// Gets the value that indicates whether the current DB Provider's transaction support (e.g. <c>BeginTransaction()</c>)
107114
/// is supported.
@@ -208,6 +215,9 @@ public override int GetHashCode()
208215
// IsPreparable
209216
hashCode = HashCode.Combine(hashCode, IsPreparable);
210217

218+
// IsSchemaSupported
219+
hashCode = HashCode.Combine(hashCode, IsSchemaSupported);
220+
211221
// IsTransactionSupported
212222
hashCode = HashCode.Combine(hashCode, IsTransactionSupported);
213223

0 commit comments

Comments
 (0)