François Beausoleil
2007-Mar-19 03:47 UTC
PGError "unknown column" on polymorphic association column
Hi all ! This is very strange. I am attempting to get my application running on PostgreSQL (from MySQL), and I get this error: ActiveRecord::StatementInvalid: PGError: ERREUR: la colonne «Party» n'existe pas : SELECT * FROM contact_routes WHERE (routable_type = "Party" AND routable_id = 1000013) ORDER BY position DESC LIMIT 1 /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:128:in `log' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:152:in `execute' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:433:in `select' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/base.rb:427:in `find_by_sql' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/base.rb:997:in `find_every' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/base.rb:991:in `find_initial' /home/francois/src/xlsuite.org/vendor/rails/activerecord/lib/active_record/base.rb:417:in `find' It translates to "The Party column does not exist". I ran the statement in psql, and sure enough, I get the same error. If I quote the routable_type column's value using single-quotes, I get the expected results. My models look like this: class Party < AR::B has_many :contact_routes, :as => :routable end class ContactRoute < AR::B acts_as_list belongs_to :routable, :polymorphic => true end I'm on the 1.2 stable branch, using Ruby 1.8.4 and PostgreSQL 8.1. Thanks ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---