public void DataTypeName_is_populated()
{
// On reading the source code for PostgreSQL9.3beta1, the only time that the
// datatypename field is populated is when using domain types. So here we'll
// create a domain that simply does not allow NULLs then try and cast NULL
// to it.
const string dropDomain = @"DROP DOMAIN IF EXISTS public.intnotnull";
const string createDomain = @"CREATE DOMAIN public.intnotnull AS INT NOT NULL";
const string castStatement = @"SELECT CAST(NULL AS public.intnotnull)";
using var conn = OpenConnection();
TestUtil.MinimumPgVersion(conn, "9.3.0", "5 error fields haven't been added yet");
try
{
var command = new NpgsqlCommand(dropDomain, conn);
command.ExecuteNonQuery();
command = new NpgsqlCommand(createDomain, conn);
command.ExecuteNonQuery();
command = new NpgsqlCommand(castStatement, conn);
//Cause the NOT NULL violation
command.ExecuteNonQuery();
}
catch (PostgresException ex)
{
Assert.AreEqual("public", ex.SchemaName);
Assert.AreEqual("intnotnull", ex.DataTypeName);
}
}