Migrating from RoR 3.0.7 to RoR 3.1.0, load fixtures left works #2958

Closed
daniel2d2art opened this Issue Sep 9, 2011 · 5 comments

Projects

None yet

3 participants

@daniel2d2art

Migrating from RoR 3.0.7 to RoR 3.1.0, load fixtures left works

$ rake db:fixtures:load RAILS_ENV=development

rake aborted!
PGError: ERROR: relation "foo" does not exist
LINE 4: WHERE a.attrelid = '"foo"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"foo"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

Attention to simple plus double quotes '"foo"'

Using same 3.0.7 migration scripts, database development is correctly migrated. When try to load mixtures in 3.1.0 obtain upper error, when same mixtures before in 3.0.7 loads correctly.

@daniel2d2art

This query is bad constructed: uses singular form of table name, when in DDBB is in plural. Same query in plural is ok.

-- BAD TABLE NAME IN QUERY --
SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"foo"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

-- CORRECT TABLE NAME IN QUERY --
SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"foos"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

How can solve it?

@daniel2d2art

We test for pluraliza table names and ...
In a rails console:
ActiveRecord::Base.pluralize_table_names
Returns:
true

@daniel2d2art

We solve using custom infections.

But take note for the same code in RoR 3.0.7 runs with no problems and without custom inflections.

@isaacsanders

@daniel2d2art Is this still an issue?

@arunagw
Member
arunagw commented May 14, 2012

Closing this for now. Please reopen this if issue still exists.

Thanks.

@arunagw arunagw closed this May 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment