From: Dagfinn Ilmari Mannsåker Date: Tue, 10 Oct 2017 12:47:26 +0000 (+0100) Subject: Fix for PostgreSQL enums not in the schema search path (RT#123234) X-Git-Tag: 0.07048~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a07eab0a070a742540c0cf432c651c0be0a3b9e7;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Fix for PostgreSQL enums not in the schema search path (RT#123234) Cast the data type name to regtype instead of comparing it directly to pg_catalog.pg_type.typname, so that schema-qualified type names are interpreted correctly. In passing, change the queries to use $data_type instead of $info->{data_type}, for consistency. --- diff --git a/Changes b/Changes index a34ba1c..ba6ff49 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - Fix for PostgreSQL enums not in the schema search path (RT#123234) + 0.07047 2017-05-26 - Avoid upcoming DBIC warning on implicit SELECT * invocation (RT#118178) diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 2a95245..f701e36 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -286,22 +286,21 @@ EOF ->selectrow_array(<dbh->{pg_server_version} >= 90100 ? 'enumsortorder' : 'oid'; $info->{extra}{list} = $self->dbh - ->selectcol_arrayref(<{data_type}); + ->selectcol_arrayref(<{extra}{custom_type_name} = $info->{data_type}; + $info->{extra}{custom_type_name} = $data_type; $info->{data_type} = 'enum'; diff --git a/t/10_03pg_common.t b/t/10_03pg_common.t index b1ab020..2fe5fc9 100644 --- a/t/10_03pg_common.t +++ b/t/10_03pg_common.t @@ -226,9 +226,12 @@ dbixcsl_common_tests->new( ) }, q{ + CREATE TYPE "dbicsl.test".pg_loader_test_enum2 AS ENUM ('wibble','wobble') + }, + q{ CREATE TABLE "dbicsl.test".pg_loader_test7 ( id SERIAL PRIMARY KEY, - value VARCHAR(100), + value "dbicsl.test".pg_loader_test_enum2, six_id INTEGER UNIQUE REFERENCES "dbicsl.test".pg_loader_test6 (id) ) }, @@ -294,7 +297,7 @@ dbixcsl_common_tests->new( 'DROP VIEW pg_loader_test11', ], drop => [ qw/pg_loader_test1 pg_loader_test2 pg_loader_test9 pg_loader_test10 pg_loader_test12/ ], - count => 11 + 30 * 2, # regular + multi-schema * 2 + count => 11 + 33 * 2, # regular + multi-schema * 2 run => sub { my ($schema, $monikers, $classes) = @_; @@ -454,6 +457,13 @@ dbixcsl_common_tests->new( lives_and { ok $rsrc = $test_schema->source('PgLoaderTest7'); + my $col_info = $rsrc->column_info('value'); + is $col_info->{data_type}, 'enum', + 'enum column in schema name with dot'; + is $col_info->{extra}{custom_type_name}, '"dbicsl.test".pg_loader_test_enum2', + 'original data type for enum in schema name with dot'; + is_deeply $col_info->{extra}{list}, [qw(wibble wobble)], + 'value list for for enum in schema name with dot'; } 'got source for table in schema name with dot'; %uniqs = try { $rsrc->unique_constraints };