This project is archived and is in readonly mode.
Arel 0.3.2 broke non-standard column types
Reported by Tuxie | March 25th, 2010 @ 10:15 PM | in 3.0.2
I have smallint and UUID columns in my PostgreSQL database.
After ActiveRecord bumped the Arel dependency today, all of my unit
test started to fail like this:
<ActiveRecord::RecordInvalid> exception expected but was
Class: < NotImplementedError >
Message: <"Column type `` is not currently handled">
---Backtrace---
/Users/perw/.bundle/ruby/1.8/bundler/gems/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b-master/lib/arel/engines/sql/attributes.rb:18:in `for'
/Users/perw/.bundle/ruby/1.8/bundler/gems/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b-master/lib/arel/engines/sql/relations/table.rb:46:in `attributes'
/Users/perw/.bundle/ruby/1.8/bundler/gems/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b-master/lib/arel/engines/sql/relations/table.rb:45:in `collect'
/Users/perw/.bundle/ruby/1.8/bundler/gems/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b-master/lib/arel/engines/sql/relations/table.rb:45:in `attributes'
/Users/perw/.bundle/ruby/1.8/bundler/gems/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b-master/lib/arel/algebra/relations/relation.rb:100:in `find_attribute_matching_name'
I guess the problem is here:
http://github.com/rails/arel/commit/83c27c0b5e2e341307b7a160d831fb9...
Maybe it should default to cast to String instead of raising an exeption?
Comments and changes to this ticket
-
José Valim March 27th, 2010 @ 12:09 PM
- Assigned user set to Emilio Tagua
- Milestone cleared.
-
Ernie Miller March 31st, 2010 @ 08:54 PM
- Tag changed from arel to arel, patch, postgresql
The types that Arel handles are the only ones that should ever show up based on a call to Column#type or a subclass because of the simplified_types call in ActiveRecord::ConnectionAdapters::Column.initialize.
Based on the simplified_types method in active_record/connection_adapters/postgresql_adapter.rb it looks like the problem is that no mapping exists for those column types. This seems to be a problem with the PostgreSQL adapter, not Arel. Can you try the attached patch and see if the problem goes away? I don't run PostgreSQL here, so I haven't tested it, but I think it should do the trick.
-
Emilio Tagua March 31st, 2010 @ 09:35 PM
- State changed from new to incomplete
Ernie, the patch looks good can you add tests?
-
Ernie Miller March 31st, 2010 @ 10:07 PM
- Tag changed from arel, patch, postgresql to arel, patch, postgresql, tests
Sure. Here you go.
-
Ernie Miller March 31st, 2010 @ 10:09 PM
Adding the file. Was showing the old one for me. Probably just caching on my end but want to be sure.
-
Ernie Miller March 31st, 2010 @ 10:10 PM
Adding the file. Was showing the old one for me. Probably just caching on my end but want to be sure.
-
Ernie Miller March 31st, 2010 @ 10:10 PM
Adding the file. Was showing the old one for me. Probably just caching on my end but want to be sure.
-
Ernie Miller March 31st, 2010 @ 10:11 PM
- no changes were found...
-
Repository March 31st, 2010 @ 11:16 PM
- State changed from incomplete to resolved
(from [98bf00d50d81c522f747131da7071d02815652f3]) Add tests for postgresql column type mapping updates [#4270 state:resolved]
Signed-off-by: Emilio Tagua miloops@gmail.com
http://github.com/rails/rails/commit/98bf00d50d81c522f747131da7071d... -
garrett April 21st, 2010 @ 02:46 AM
I'm getting this error now also. Trying to save PostGIS geometry types back to the database. String would be the correct way to handle these columns as they get shuffled in and out normally as Hex.
NotImplementedError: Column type
is not currently handled<br/>
from /Users/garrett/.rvm/gems/ruby-1.9.2-head/gems/arel-0.3.3/lib/arel/engines/sql/attributes.rb:18:in `for' from /Users/garrett/.rvm/gems/ruby-1.9.2-head/gems/arel-0.3.3/lib/arel/engines/sql/relations/table.rb:46:in `block in attributes'
-
gucki May 15th, 2010 @ 05:20 PM
The problems still occurs when using custom data types, which is quite common when using pgsql.
Either there should be a way to easily add custom datatypes with their mapping or the adapter should fallback to :string for unknown types.
-
jdguyot June 23rd, 2010 @ 09:54 PM
Same problem here. I'm currently migrating our app from Rails 2.3.5 to 3.0b4. We use custom pgsql types which is a really common thing.
class CreateModel < ActiveRecord::Migration def self.up # Create a custom column type execute %{ CREATE TYPE custom_column_type AS ENUM ('item1', 'item2'); } create_table :models do |t| t.column :custom_column, :custom_column_type t.timestamps end end def self.down drop_table :models execute %{ DROP TYPE custom_column_type; } end end
I see the same stack than above:
NotImplementedError: Column type `` is not currently handled vendor/gems/arel-0.4.0/lib/arel/engines/sql/attributes.rb:18:in `for' vendor/gems/arel-0.4.0/lib/arel/engines/sql/relations/table.rb:47:in `attributes' vendor/gems/arel-0.4.0/lib/arel/engines/sql/relations/table.rb:46:in `collect' vendor/gems/arel-0.4.0/lib/arel/engines/sql/relations/table.rb:46:in `attributes' vendor/gems/arel-0.4.0/lib/arel/algebra/relations/relation.rb:87:in `[]' vendor/gems/activerecord-3.0.0.beta4/lib/active_record/base.rb:1776:in `arel_attributes_values' ...
-
Mordekai July 15th, 2010 @ 06:23 PM
- Importance changed from to High
I've got the same problem with Postgres's tsvector type, which is now a standard data type. This issue seems to be as marked resolved prematurely: Some way to add new data types without patching postgresql_adapter.rb is needed, perhaps using a hash added to /config/initializers/postgres_init.rb.
-
Steve Madsen August 10th, 2010 @ 04:04 AM
- State changed from resolved to incomplete
Adding to the chorus, I see the same behavior with a column of type "earth", from the earthdistance contrib module. I don't actually care about updating this column from within the Rails app, but I do need access to the other columns in the table. [state:incomplete]
-
Emilio Tagua September 21st, 2010 @ 08:19 PM
- State changed from incomplete to resolved
Hey,
I think this was solved here:
https://rails.lighthouseapp.com/projects/8994/tickets/5477
Commit here:
http://github.com/rails/arel/commit/33445ba4c7729970ff8840634c92009...
I'm closing the ticket, feel free to reopen it you find it's still not working.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 4447 Column.simplified_type defaults This relates over to ticket #4270 where I've submitted a ...
- 5194 ActiveRecord Beta 4 does not understand most postgres data types This ticket sounds very similar to #4270.
- 5194 ActiveRecord Beta 4 does not understand most postgres data types I'm happy to work up patches for both of these one-liners...
- 4270 Arel 0.3.2 broke non-standard column types (from [98bf00d50d81c522f747131da7071d02815652f3]) Add tes...