Scott Woods
2009-Apr-04 23:40 UTC
PostgreSQL schema dumper does not support capitalized table names
We have a legacy database that has been migrated to PostgreSQL and includes camel-case table names. When running migrations, the schema dumper throws an error when it encounters these tables. I believe I''ve created and tested the proper solution to this in the postgresql adapter. Please see the following ticket for details: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2418-postgresql-schema-dumper-does-not-support-capitalized-table-names I would appreciate it if someone could take a look at the patch and tests and see if there should be any other improvements. Thanks! Scott --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Isak Hansen
2009-Apr-05 21:17 UTC
Re: PostgreSQL schema dumper does not support capitalized table names
On Sun, Apr 5, 2009 at 1:40 AM, Scott Woods <scott.a.woods@gmail.com> wrote:> > We have a legacy database that has been migrated to PostgreSQL and > includes camel-case table names. When running migrations, the schema > dumper throws an error when it encounters these tables. I believe I''ve > created and tested the proper solution to this in the postgresql > adapter. Please see the following ticket for details: > > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2418-postgresql-schema-dumper-does-not-support-capitalized-table-names > > I would appreciate it if someone could take a look at the patch and > tests and see if there should be any other improvements. >+ # The name is a string. It could contain a schema, which shouldn''t + # be included in the quotes. + schema, table_name = name.split(''.'') + if schema && table_name + %(#{schema}."#{table_name}") You''re not quoting the schema name? Regards, Isak> Thanks! > Scott > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Woods
2009-Apr-06 01:49 UTC
Re: PostgreSQL schema dumper does not support capitalized table names
On Apr 5, 5:17 pm, Isak Hansen <isak.han...@gmail.com> wrote:> You''re not quoting the schema name?Correct. Apparently the schema name should not be included in the quotes. Here''s an example (PostgreSQL 8.2.11): test=# create schema schema_test create table "CamelCase" (id integer primary key); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "CamelCase_pkey" for table "CamelCase" CREATE SCHEMA test=# select ''schema_test.CamelCase''::regclass; ERROR: relation "schema_test.camelcase" does not exist test=# select ''"schema_test.CamelCase"''::regclass; ERROR: relation "schema_test.CamelCase" does not exist test=# select ''schema_test."CamelCase"''::regclass; regclass ------------------------- schema_test."CamelCase" (1 row) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Woods
2009-Apr-06 02:42 UTC
Re: PostgreSQL schema dumper does not support capitalized table names
Ticket #390 just got resolved and committed, which implements more complete table name quoting than I had: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/390-postgres-adapter-quotes-table-name-breaks-when-non-default-schema-is-used However, that patch still doesn''t quote table names when casting to regclass, so I''ve adjusted my patch so that it uses the new quote_table_name method instead. I also integrated my tests with the new patch. Here''s my new patch: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2418-postgresql-schema-dumper-does-not-support-capitalized-table-names#ticket-2418-3 So to summarize, ticket #390 implemented table quoting to allow non- default schemas to be specified. My ticket #2418 now piggybacks on that to prevent a PGError when capitalized table names are used. I''ve tested this on MacOS 10.5 using PostgreSQL 8.2.11 and each of the "pg" and "postgres" gems. I''d appreciate it if others could verify this (or other platforms) as well. Thanks, Scott --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---