Connection.GetSchema(...) delivers wrong defaultvalue after renaming a defaultvalue of a enum-table column in database
Posted: Mon 17 Jun 2013 15:28
/*
-- Create a type and a table using that type with a defaultvalue in the database:
drop table if exists testtab;
drop type if exists testtype;
drop type if exists new_testtype;
create type testtype as enum
(
'OK',
'NOTOK'
);
create table testtab
(
t testtype default 'OK'
);
*/
PgSqlConnection conn = EdGlobals.Connection;
var v = EdGlobals.Connection.GetSchema("Columns", new string[] { "%", "testtab", "%" }).Rows[0]["defaultvalue"];
// Result is RIGHT:
//'OK'::testtype
/*
-- Now, change the name of the type in the database:
alter type testtype rename to new_testtype;
*/
v = EdGlobals.Connection.GetSchema("Columns", new string[] { "%", "testtab", "%" }).Rows[0]["defaultvalue"];
// Result is WRONG: !!!!!!
//'OK'::testtype
/*
-- Querying the information-schema the following way always delivers the right values:
SELECT column_name, column_default
FROM information_schema.columns
WHERE (table_schema, table_name) = ('public', 'testtab')
ORDER BY ordinal_position;
*/
-- Create a type and a table using that type with a defaultvalue in the database:
drop table if exists testtab;
drop type if exists testtype;
drop type if exists new_testtype;
create type testtype as enum
(
'OK',
'NOTOK'
);
create table testtab
(
t testtype default 'OK'
);
*/
PgSqlConnection conn = EdGlobals.Connection;
var v = EdGlobals.Connection.GetSchema("Columns", new string[] { "%", "testtab", "%" }).Rows[0]["defaultvalue"];
// Result is RIGHT:
//'OK'::testtype
/*
-- Now, change the name of the type in the database:
alter type testtype rename to new_testtype;
*/
v = EdGlobals.Connection.GetSchema("Columns", new string[] { "%", "testtab", "%" }).Rows[0]["defaultvalue"];
// Result is WRONG: !!!!!!
//'OK'::testtype
/*
-- Querying the information-schema the following way always delivers the right values:
SELECT column_name, column_default
FROM information_schema.columns
WHERE (table_schema, table_name) = ('public', 'testtab')
ORDER BY ordinal_position;
*/