NoMethodError: undefined method `type' for "character varying(255)":String with ActiveRecord 4.2.0.beta1
Closed this issue · 27 comments
Starting my Rails 4.1 app with Rails 4.2.0.beta1 gives this error:
NoMethodError: undefined method `type' for "character varying(255)":String
Looks like the column type is now an object of class ActiveRecord::Type::Value instead of a String.
@donv yep 4.2 a minor release seems as yet another major for us ... I'm stucked as I am with optimizations for the "next" generation of AR-JDBC and would like to spend quality oss time on a few others. so if you're counting on me I'm not sure when 4.2 compatibility will happen ... sorry ;(
Fair enough @kares 😄
Maybe another contributor can look at it? Are there any?
Otherwise, I should take a look, but I will need some moral support. Are you up for that?
well some names on the team https://github.com/orgs/jruby/teams/ar-jdbc + each morning I hope for a PR that merges us into Rails :) ... until than I have very little moral when it comes to AR + JDBC it's all yours!
Thought I'd drop a note to say I'd been looking at this over the weekend. I'm making (slow) progress but I'm getting there now.
@benlovell great! ... @prathamesh-sonpatki just showed me some code this morning (mostly Sqlite3) - maybe you guys can align for what you'll be working on
@benlovell I just sent an email to you about the sqlite code that i added. Please check.
Any progress? Just now got next error with sqlite:
Failure/Error: require 'spec_helper'
NoMethodError:
undefined method `type_cast_from_database' for "integer":String
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute.rb:86:in `type_cast'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute.rb:38:in `original_value'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute.rb:33:in `value'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute.rb:50:in `changed_in_place_from?'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:146:in `changed_in_place?'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:140:in `changed_in_place'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:139:in `changed_in_place'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:132:in `attributes_changed_in_place'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:65:in `changed_attributes'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activemodel-4.2.0.beta1/lib/active_model/dirty.rb:172:in `attribute_changed?'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:106:in `old_attribute_value'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/dirty.rb:81:in `write_attribute'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_methods/write.rb:50:in `__temp__e616d656='
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_assignment.rb:41:in `assign_attributes'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/core.rb:543:in `init_attributes'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/core.rb:264:in `initialize'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/inheritance.rb:61:in `new'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activerecord-4.2.0.beta1/lib/active_record/persistence.rb:33:in `create'
# ./spec/support/data.rb:1:in `(root)'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:248:in `require'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:233:in `load_dependency'
# /Users/devil/.rvm/gems/jruby-1.7.12/gems/activesupport-4.2.0.beta1/lib/active_support/dependencies.rb:248:in `require'
# ./spec/lib/amoeba_spec.rb:1:in `(root)'
# ./spec/lib/amoeba_spec.rb:6:in `(root)'
@simonoff Sorry. I have started work on it but it got delayed. You can see my changes here - https://github.com/prathamesh-sonpatki/activerecord-jdbc-adapter/tree/rails-42. I have fixed the above error but all tests are not still passing. Hope to fix it soon.
@prathamesh-sonpatki if you need my help you can tell me. Thx for reply!
This might be fixed in jruby-head.
I develop some gem which extends ActiveRecord and have found failed Travis builds for JRuby + Rails 4.2.beta1 combination. The error is NoMethodError: undefined method 'type_cast_from_database' for "varchar(255)":String
, like in @simonoff's case. However builds for JRuby-head + Rails 4.2.beta1 combination do pass.
Anyone else confirm / deny? I can't imagine it being the case since activerecord-jdbc-adapter hasn't been updated with a fix.
I tried it in jruby-head and I'm still seeing the same errors.
Here's my travis build https://travis-ci.org/zooniverse/Panoptes/jobs/36594073#L288
please, just read the full comments ... upgrading jruby won't solve this - it's an AR compatibility issue!
... there's some initial work at #587 for SQLite3 ... also anyone can support this at bountysource
Can anyone give a comment on wheter rails 4.2b2 jdbc active record is working again? what gems should I use, what git path?
I tried looking at this for PostgreSQL, but it is extremely slow going. Any help is appreciated.
@edpaget @prathamesh-sonpatki do you have any changes that are not merged with master?
@donv No. All my commits are in the master.
I need to chat with someone to get any progress. What channel are you guys on? IRC #jruby ?
master is far from a release ... maybe a pre. this in particular might end up beinghandled differently on master than it would on 1.3 as we tend to do our (very-own) JDBC type-casts. all the code done by Prathamesh should be on 1-3-stable (as well) ...
Thanks for looking into this guys :)
.. this has changed since 4.2 beta1 - 1-3-stable now handles type-casting smh better aligned with Rails
Does that mean 1-3-stable shouldn't have this problem anymore? I checked it out and the tests are still failing with the same error so I think I'm misunderstanding.
my bad - thought this to be SQLite3 adapter specific - in general no, type support is not finished (in 1.3.16) and requires more work to support all adapters available with AR-JDBC as well as "generic" type resolution for adapter: jdbc ... MySQL and SQLite might be working at this point - could use more real-world testing
should be fixed now (feel free to try out 1-3-stable or 1.3.18 when its released) thanks to @donv
I'm seeing something I think is this error. activerecord-jdbc-adapter 1.3.18, activerecord 4.2.4 or 4.1.13. rake db:schema:dump
results in:
Could not dump table "[tablename]" because of following NoMethodError
undefined method `type' for "int(10) unsigned":String
for each of my tables.
(Hadn't previously been using AR in this project, so I don't have a known-good version to provide yet.)
Hmm, and today I can't repro that - it seems to work. Sorry - will keep an eye out for it.