aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema
diff options
context:
space:
mode:
authorArturo Pie <arturotd08@yahoo.ca>2012-10-13 23:48:37 -0400
committerArturo Pie <arturotd08@yahoo.ca>2012-10-14 01:07:29 -0400
commit3980465f2651ae2520828d9aec3b310da69521fe (patch)
treeaa40df0021d860c21ebbc8ba97587ad5bed8fb1a /activerecord/test/schema
parent84c37741e005b3ac6807be1caf5255c041f12693 (diff)
downloadrails-3980465f2651ae2520828d9aec3b310da69521fe.tar.gz
rails-3980465f2651ae2520828d9aec3b310da69521fe.tar.bz2
rails-3980465f2651ae2520828d9aec3b310da69521fe.zip
#7914 get default value when type uses schema name
PostgreSQL adapter properly parses default values when using multiple schemas and domains. When using domains across schemas, PostgresSQL prefixes the type of the default value with the name of the schema where that type (or domain) is. For example, this query: ``` SELECT a.attname, d.adsrc FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = "defaults"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum; ``` could return something like "'<default_value>'::pg_catalog.text" or "(''<default_value>'::pg_catalog.text)::text" for the text columns with defaults. I modified the regexp used to parse this value so that it ignores anything between ':: and \b(?:character varying|bpchar|text), and it allows to have optional parens like in the above second example.
Diffstat (limited to 'activerecord/test/schema')
-rw-r--r--activerecord/test/schema/postgresql_specific_schema.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/test/schema/postgresql_specific_schema.rb b/activerecord/test/schema/postgresql_specific_schema.rb
index 5cf9a207f3..34e24b5a2e 100644
--- a/activerecord/test/schema/postgresql_specific_schema.rb
+++ b/activerecord/test/schema/postgresql_specific_schema.rb
@@ -10,6 +10,8 @@ ActiveRecord::Schema.define do
execute "ALTER TABLE companies ALTER COLUMN id SET DEFAULT nextval('companies_nonstd_seq')"
execute 'DROP SEQUENCE IF EXISTS companies_id_seq'
+ execute "DROP SCHEMA IF EXISTS schema_1 CASCADE"
+
%w(accounts_id_seq developers_id_seq projects_id_seq topics_id_seq customers_id_seq orders_id_seq).each do |seq_name|
execute "SELECT setval('#{seq_name}', 100)"
end
@@ -35,7 +37,12 @@ ActiveRecord::Schema.define do
);
_SQL
- execute <<_SQL
+ execute "CREATE SCHEMA schema_1"
+ execute "CREATE DOMAIN schema_1.text AS text"
+ execute "CREATE DOMAIN schema_1.varchar AS varchar"
+ execute "CREATE DOMAIN schema_1.bpchar AS bpchar"
+
+ execute <<_SQL
CREATE TABLE geometrics (
id serial primary key,
a_point point,