fix(sql): bind string keys untyped on Postgres so integer key columns compare (#602 STAB-24)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -24,6 +24,26 @@ public class PostgresDialectTests
|
||||
d.QuoteIdentifier("a\"b").ShouldBe("\"a\"\"b\"");
|
||||
}
|
||||
|
||||
/// <summary>STAB-24: a string bind is untyped so Postgres infers it against an integer key column.</summary>
|
||||
[Fact]
|
||||
public void ConfigureParameter_sendsStringBindsAsUnknownType_soIntegerKeysCompare()
|
||||
{
|
||||
var p = new Npgsql.NpgsqlParameter("@k0", "3") { NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text };
|
||||
new PostgresDialect().ConfigureParameter(p, "3");
|
||||
p.NpgsqlDbType.ShouldBe(NpgsqlTypes.NpgsqlDbType.Unknown);
|
||||
}
|
||||
|
||||
/// <summary>Non-string values keep their natural type, and a foreign parameter type is tolerated.</summary>
|
||||
[Fact]
|
||||
public void ConfigureParameter_leavesNonStringsAndForeignParametersAlone()
|
||||
{
|
||||
var d = new PostgresDialect();
|
||||
var n = new Npgsql.NpgsqlParameter("@k0", 3) { NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer };
|
||||
d.ConfigureParameter(n, 3);
|
||||
n.NpgsqlDbType.ShouldBe(NpgsqlTypes.NpgsqlDbType.Integer);
|
||||
Should.NotThrow(() => d.ConfigureParameter(new SqliteParameter("@k0", "3"), "3"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void QuoteIdentifier_rejectsControlCharsAndNul()
|
||||
=> Should.Throw<ArgumentException>(() => new PostgresDialect().QuoteIdentifier("x\0y"));
|
||||
|
||||
Reference in New Issue
Block a user