fix(sql): Test Connect must construct Postgres and Oracle dialects too
SqlDriverProbe.DefaultDialectFor was left SqlServer-only when the provider gates were widened, so AdminUI Test Connect failed for both new providers with InvalidOperationException while Deploy and browse worked. Found by the live chrome/AdminUI gate the plan deferred, not by any test: every case in SqlDriverProbeTests builds its probe through ForTest(), which injects the dialect and never reaches the production switch. Widen the switch arm-for-arm with SqlDriverFactoryExtensions.CreateDialect, and cover the gate directly via an internal seam — plus a reserved-provider falsification control and an end-to-end production-constructor case.
This commit is contained in:
@@ -164,11 +164,37 @@ public sealed class SqlDriverProbe : IDriverProbe
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Constructs the production dialect for a provider; v1 supports SQL Server only.</summary>
|
||||
/// <summary>
|
||||
/// Test seam over <see cref="DefaultDialectFor"/>. The parameterless constructor is the only
|
||||
/// production path into that switch, and <see cref="ForTest"/> deliberately bypasses it — so without
|
||||
/// this seam the gate has no direct coverage at all, which is how it kept a SqlServer-only switch
|
||||
/// after the factory and browser were widened.
|
||||
/// </summary>
|
||||
/// <param name="provider">The provider whose dialect to construct.</param>
|
||||
/// <returns>The dialect this build constructs for <paramref name="provider"/>.</returns>
|
||||
/// <exception cref="InvalidOperationException">The provider is reserved and not constructed.</exception>
|
||||
internal static ISqlDialect DefaultDialectForTest(SqlProvider provider) => DefaultDialectFor(provider);
|
||||
|
||||
/// <summary>
|
||||
/// Constructs the production dialect for a provider — <b>the same set
|
||||
/// <see cref="SqlDriverFactoryExtensions"/> constructs</b>, because Test Connect must exercise the
|
||||
/// backend a Deploy would actually use. This build constructs <see cref="SqlProvider.SqlServer"/>,
|
||||
/// <see cref="SqlProvider.Postgres"/> and <see cref="SqlProvider.Oracle"/>;
|
||||
/// <see cref="SqlProvider.MySql"/> and <see cref="SqlProvider.Odbc"/> stay reserved.
|
||||
/// <para><b>Keep this arm-for-arm with the factory's <c>CreateDialect</c>.</b> When the factory and the
|
||||
/// browser were widened to Postgres + Oracle this switch was left SqlServer-only, so a config that
|
||||
/// deployed and browsed fine failed Test Connect with an <see cref="InvalidOperationException"/> — and
|
||||
/// no test noticed, because every probe test injects its dialect through <see cref="ForTest"/>.</para>
|
||||
/// </summary>
|
||||
private static ISqlDialect DefaultDialectFor(SqlProvider provider) => provider switch
|
||||
{
|
||||
SqlProvider.SqlServer => new SqlServerDialect(),
|
||||
SqlProvider.Postgres => new PostgresDialect(),
|
||||
SqlProvider.Oracle => new OracleDialect(),
|
||||
_ => throw new InvalidOperationException(
|
||||
$"provider '{provider}' is not available in this build (only SqlServer is supported)."),
|
||||
$"provider '{provider}' is not available in this build. Supported: " +
|
||||
$"'{nameof(SqlProvider.SqlServer)}', '{nameof(SqlProvider.Postgres)}', " +
|
||||
$"'{nameof(SqlProvider.Oracle)}'. Reserved (declared on the enum but not implemented): " +
|
||||
$"'{nameof(SqlProvider.MySql)}', '{nameof(SqlProvider.Odbc)}'."),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user