This project is archived and is in readonly mode.

#5322 ✓resolved
jpfuentes2 (at gmail)

Rails3 RC - AREL does not work with multiple schemas using MySQL

Reported by jpfuentes2 (at gmail) | August 6th, 2010 @ 09:00 PM

gem 'rails', '3.0.0.rc'
gem 'mysql'

When using multiple schemas in AR models, AREL throws an error whenever I try to use a schema other than the one specified in db.yml

undefined method `name' for #<Arel::Value:0x000000036b9c90>
/home/jfuentes/.rvm/gems/ruby-1.9.2-rc2/gems/arel-0.4.0/lib/arel/engines/sql/engine.rb:32:in `block in create'

Basically, my models declare which schema to access via set_table_name

class User < ActiveRecord::Base
end
class Post < ActiveRecord::Base set_table_name 'schema_two.posts' end

AR/AREL can only operate on the schema declared in db.yml as the database. If code uses another schema at all, it will throw the above error. This error occurs in all environments regardless if I try to access the secondary schema first or not. This behavior works fine in my rails 2.3.2 app. What's interesting to note is that rails console allows me to query both w/o any errors.

Here is the repo with a basic test app using the two models above: git@github.com:jpfuentes2/arel-multi-schema.git

Create schemas:

create database schema_one;
create database schema_two;

After creating the schemas and configuring the app/models - I migrated (which works) and then a rake db:seed which fails. I've attached the trace for db:seed and the proof that rails console cooperates w/ multiple schemas.

Comments and changes to this ticket

  • jpfuentes2 (at gmail)

    jpfuentes2 (at gmail) August 6th, 2010 @ 09:59 PM

    Update: apparently the issue is with creating records. I can issue a find for either model on both schemas:

    When I put in this test.rb

    p User.columns
    p Post.columns
    p Post.first
    

    rails runner test.rb

    [#<ActiveRecord::ConnectionAdapters::MysqlColumn:0x000000020aece8 @null=false, @sql_type="int(11)", @name="id", @scale=nil, @precision=nil, @limit=4, @type=:integer, @default=nil, @primary=true>, #<ActiveRecord::ConnectionAdapters::MysqlColumn:0x000000020ae6f8 @null=true, @sql_type="varchar(255)", @name="name", @scale=nil, @precision=nil, @limit=255, @type=:string, @default=nil, @primary=false>] 
    [#<ActiveRecord::ConnectionAdapters::MysqlColumn:0x00000002090d38 @null=false, @sql_type="int(11)", @name="id", @scale=nil, @precision=nil, @limit=4, @type=:integer, @default=nil, @primary=true>, #<ActiveRecord::ConnectionAdapters::MysqlColumn:0x000000020909f0 @null=true, @sql_type="varchar(255)", @name="title", @scale=nil, @precision=nil, @limit=255, @type=:string, @default=nil, @primary=false>] 
    nil
    

    I get the AREL error again when I add a create to test.rb

    Post.create(:title => 'test')
    
  • keeran

    keeran September 8th, 2010 @ 08:11 PM

    Can confirm this issue...almost. We just had the same error after forgetting to restart the servers after a migration (so our model schema was different to the db schema.. I guess?).

  • tispratik

    tispratik November 28th, 2010 @ 10:58 AM

    • Tag changed from arel, mysql2, rails3.0rc to arel, mysql2, rails3.0.1, rails3.0.3, rails3.0rc

    I too got the same issue with rails 3.0.0 RC2.

    I have two database schema's. One is bs_development and the other is va_development.
    The Project and ProjectRole model lies in bs_development schema and User model lies in va_development schema.

      Project.rb
      has_many :project_roles, :dependent => :destroy
      has_many :users, :through => :project_roles
      alias :roles :project_roles
      after_create :run_after_create
    
      def run_after_create
       #Make owner of project when created
       roles.create(:user => User.curr_user)
      end
    
      ProjectRole.rb
      set_table_name "bs_#{Rails.env}" + ".project_roles"
      belongs_to :project
      belongs_to :user
    
      User.rb
      establish_connection "va_#{Rails.env}"
      has_many :project_roles
      has_many :projects, :through => :project_roles
      alias :roles :project_roles
    

    When i try to do:

    Project.first.roles.create(:name => "Owner", :user => User.first), i get the following error:
    
    undefined method name' for #&lt;Arel::Value:0x000000043f77e0&gt;
    arel (1.0.1) lib/arel/engines/sql/engine.rb:26:inblock in create'
    arel (1.0.1) lib/arel/engines/sql/engine.rb:26:in each'
    arel (1.0.1) lib/arel/engines/sql/engine.rb:26:indetect'
    arel (1.0.1) lib/arel/engines/sql/engine.rb:26:in create'
    arel (1.0.1) lib/arel/algebra/relations/writes.rb:24:incall'
    arel (1.0.1) lib/arel/session.rb:17:in create'
    arel (1.0.1) lib/arel/algebra/relations/relation.rb:159:ininsert'
    activerecord (3.0.0.rc2) lib/active_record/relation.rb:14:in insert'
    activerecord (3.0.0.rc2) lib/active_record/persistence.rb:258:increate'
    activerecord (3.0.0.rc2) lib/active_record/timestamp.rb:47:in create'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:281:inblock in create'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:413:in _run_create_callbacks'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:281:increate'
    activerecord (3.0.0.rc2) lib/active_record/persistence.rb:234:in create_or_update'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:277:inblock in create_or_update'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:423:in _run_save_callbacks'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:277:increate_or_update'
    activerecord (3.0.0.rc2) lib/active_record/persistence.rb:39:in save'
    activerecord (3.0.0.rc2) lib/active_record/validations.rb:43:insave'
    activerecord (3.0.0.rc2) lib/active_record/attribute_methods/dirty.rb:21:in save'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:237:inblock (2 levels) in save'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:289:in block in with_transaction_returning_status'
    activerecord (3.0.0.rc2) lib/active_record/connection_adapters/abstract/database_statements.rb:139:intransaction'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:204:in transaction'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:287:inwith_transaction_returning_status'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:237:in block in save'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:248:inrollback_active_record_state!'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:236:in save'
    activerecord (3.0.0.rc2) lib/active_record/associations/association_collection.rb:271:inblock in create'
    activerecord (3.0.0.rc2) lib/active_record/associations/association_collection.rb:504:in block in create_record'
    activerecord (3.0.0.rc2) lib/active_record/associations/association_collection.rb:479:inadd_record_to_target_with_callbacks'
    activerecord (3.0.0.rc2) lib/active_record/associations/association_collection.rb:504:in create_record'
    activerecord (3.0.0.rc2) lib/active_record/associations/association_collection.rb:269:increate'
    app/models/project.rb:70:in run_after_create'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:463:inrun_create_callbacks'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:281:in create'
    activerecord (3.0.0.rc2) lib/active_record/persistence.rb:234:increate_or_update'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:277:in block in create_or_update'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:428:inrun_save_callbacks'
    activerecord (3.0.0.rc2) lib/active_record/callbacks.rb:277:in create_or_update'
    activerecord (3.0.0.rc2) lib/active_record/persistence.rb:39:insave'
    activerecord (3.0.0.rc2) lib/active_record/validations.rb:43:in save'
    activerecord (3.0.0.rc2) lib/active_record/attribute_methods/dirty.rb:21:insave'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:237:in block (2 levels) in save'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:289:inblock in with_transaction_returning_status'
    activerecord (3.0.0.rc2) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in transaction'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:204:intransaction'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:287:in with_transaction_returning_status'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:237:inblock in save'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:248:in rollback_active_record_state!'
    activerecord (3.0.0.rc2) lib/active_record/transactions.rb:236:insave'
    app/controllers/projects_controller.rb:34:in create'
    actionpack (3.0.0.rc2) lib/action_controller/metal/implicit_render.rb:4:insend_action'
    actionpack (3.0.0.rc2) lib/abstract_controller/base.rb:148:in process_action'
    actionpack (3.0.0.rc2) lib/action_controller/metal/rendering.rb:11:inprocess_action'
    actionpack (3.0.0.rc2) lib/abstract_controller/callbacks.rb:18:in block in process_action'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:460:inrun100660723245084705process_action3862972158326372300callbacks'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:409:in _run_process_action_callbacks'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:93:inrun_callbacks'
    actionpack (3.0.0.rc2) lib/abstract_controller/callbacks.rb:17:in process_action'
    actionpack (3.0.0.rc2) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action'
    activesupport (3.0.0.rc2) lib/active_support/notifications.rb:52:in block in instrument'
    activesupport (3.0.0.rc2) lib/active_support/notifications/instrumenter.rb:21:ininstrument'
    activesupport (3.0.0.rc2) lib/active_support/notifications.rb:52:in instrument'
    actionpack (3.0.0.rc2) lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
    actionpack (3.0.0.rc2) lib/action_controller/metal/rescue.rb:17:in process_action'
    actionpack (3.0.0.rc2) lib/abstract_controller/base.rb:117:inprocess'
    actionpack (3.0.0.rc2) lib/abstract_controller/rendering.rb:40:in process'
    actionpack (3.0.0.rc2) lib/action_controller/metal.rb:133:indispatch'
    actionpack (3.0.0.rc2) lib/action_controller/metal/rack_delegation.rb:14:in dispatch'
    actionpack (3.0.0.rc2) lib/action_controller/metal.rb:173:inblock in action'
    actionpack (3.0.0.rc2) lib/action_dispatch/routing/route_set.rb:62:in call'
    actionpack (3.0.0.rc2) lib/action_dispatch/routing/route_set.rb:62:indispatch'
    actionpack (3.0.0.rc2) lib/action_dispatch/routing/route_set.rb:27:in call'
    rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:inblock in call'
    rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in block in recognize'
    rack-mount (0.6.13) lib/rack/mount/code_generation.rb:75:inoptimized_each'
    rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in recognize'
    rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/routing/route_set.rb:492:in call'
    haml (3.0.24) lib/sass/plugin/rack.rb:41:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/best_standards_support.rb:17:in call'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/head.rb:14:incall'
    rack (1.2.1) lib/rack/methodoverride.rb:24:in call'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/params_parser.rb:21:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/flash.rb:177:in call'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/session/abstract_store.rb:149:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/cookies.rb:278:in call'
    activerecord (3.0.0.rc2) lib/active_record/query_cache.rb:32:inblock in call'
    activerecord (3.0.0.rc2) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in cache'
    activerecord (3.0.0.rc2) lib/active_record/query_cache.rb:12:incache'
    activerecord (3.0.0.rc2) lib/active_record/query_cache.rb:31:in call'
    activerecord (3.0.0.rc2) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/callbacks.rb:46:in block in call'
    activesupport (3.0.0.rc2) lib/active_support/callbacks.rb:415:inrun_call_callbacks'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/callbacks.rb:44:in call'
    rack (1.2.1) lib/rack/sendfile.rb:107:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/remote_ip.rb:48:in call'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/show_exceptions.rb:46:incall'
    railties (3.0.0.rc2) lib/rails/rack/logger.rb:13:in call'
    rack (1.2.1) lib/rack/runtime.rb:17:incall'
    activesupport (3.0.0.rc2) lib/active_support/cache/strategy/local_cache.rb:72:in call'
    rack (1.2.1) lib/rack/lock.rb:11:inblock in call'
    <internal:prelude>:10:in synchronize'
    rack (1.2.1) lib/rack/lock.rb:11:incall'
    actionpack (3.0.0.rc2) lib/action_dispatch/middleware/static.rb:30:in call'
    railties (3.0.0.rc2) lib/rails/application.rb:168:incall'
    railties (3.0.0.rc2) lib/rails/application.rb:77:in method_missing'
    railties (3.0.0.rc2) lib/rails/rack/log_tailer.rb:14:incall'
    rack (1.2.1) lib/rack/content_length.rb:13:in call'
    rack (1.2.1) lib/rack/handler/webrick.rb:52:inservice'
    /home/pratik/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:111:in service'
    /home/pratik/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:70:inrun'
    /home/pratik/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in block in start_thread'</code>
    </pre>
    
    
    For Rails 3.0.1 and 3.0.2, the problem persists, but the error is different and stack trace is:
    NoMethodError: undefined method name' for nil:NilClass<br/>
     from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:inmethod_missing'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:57:in block in visit_Arel_Nodes_InsertStatement'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:56:inmap'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:56:in visit_Arel_Nodes_InsertStatement'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:invisit'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:5:in accept'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:19:inblock in accept'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:110:in with_connection'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:17:inaccept'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/tree_manager.rb:19:in to_sql'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/select_manager.rb:191:ininsert'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/relation.rb:14:in insert'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/persistence.rb:270:increate'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/timestamp.rb:47:in create'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/callbacks.rb:281:inblock in create'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:413:in _run_create_callbacks'<br/> ... 30 levels... from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:21:insave'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:in block (2 levels) in save'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:289:inblock in with_transaction_returning_status'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in transaction'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:intransaction'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:287:in with_transaction_returning_status'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:inblock in save'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:248:in rollback_active_record_state!'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:236:insave'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/base.rb:498:in create'<br/> from (irb):2<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/console.rb:44:instart'
    from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in start'<br/> from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:23:in<top (required)>'
    from script/rails:6:in require'<br/> from script/rails:6:in<main>'
    
    
    
    Please refer to my StackOverFlow issue for details:
    http://stackoverflow.com/questions/4284043/rails2-to-rails3-upgrade...
    Thanks!
  • jpfuentes2 (at gmail)

    jpfuentes2 (at gmail) December 6th, 2010 @ 03:23 PM

    FYI, when I last looked into this problem, the issue is that AREL doesn't think the table exists when you do a create - for some reason it does not have the other schema's tables in the list of tables.

    I've been using the following @ work to circumvent this problem. Telling AREL that a table always exists solves the issue.

    module ActiveRecord
    module ConnectionAdapters

    module SchemaStatements
      def table_exists?(table_name)
        tables.include?(table_name)
        true
      end
    end
    

    end end

  • kmunteanu

    kmunteanu February 26th, 2011 @ 09:51 AM

    I can confirm this bug still exists in 3.0.3. You can also see some other weird behaviour with associations when you use database name prefixes in set_table_name:

    class Car < ActiveRecord::Base
      set_table_name "multidb1.cars"
      belongs_to :manufacturer
    end
    
    class Manufacturer < ActiveRecord::Base
      has_many :cars
    end
    

    Then using a query like Car.includes(:manufacturer).first produces SQL:

    SELECT multidb1.cars.id AS t0_r0, multidb1.cars.manufacturer_id AS t0_r1, multidb1.cars.name AS t0_r2, manufacturers.id AS t1_r0, manufacturers.name AS t1_r1 FROM multidb1.cars LEFT OUTER JOIN manufacturers ON manufacturers.id IS NULL LIMIT 1
    SELECT manufacturers.* FROM manufacturers WHERE manufacturers.id = 1 LIMIT 1

    Maybe it is just not intended to crossreference other databases by changing table names.

  • Tyler Broadbent

    Tyler Broadbent March 4th, 2011 @ 07:15 PM

    This is a MAJOR pitfall of Rails at the moment and needs to be a top priority for the Rails/AREL developers. We have created multiple web applications using Rails and have, for the most part, enjoyed the framework. As the applications gain popularity, scaling becomes a major issue.

    Our largest application is spread across multiple database servers (with identical schemas) and collects millions of new entries per day. As our needs grow, we expand horizontally. Database.yml has entries for each database server and during boot we setup abstract classes to get a connection, then use a single abstract class to switch between connections while performing a set_table_name.

    This worked without a problem for Rails 2.3.x but is now broken in Rails 3.x with the addition of AREL. We thought that by adding some monkey patches to AREL we had made a work-around, but the problem still exists for creating new records.

    We were hasty to upgrade to Rails3 and are unable to easily roll back. As a result, a large portion of our code will now be using direct database queries on the abstract model connection. Simply put, the beautiful ActiveRecord layer that originally made Rails attractive is now unusable in a large application.

    FIX IT! Add beautiful built-in support for storing data in different databases with the same schema either on the same or different database server. Data_Fabric and DB_Charmer worked well for Rails 2.x support for some, but are broken as well for Rails 3.

  • Blue Box Jesse

    Blue Box Jesse March 5th, 2011 @ 08:37 AM

    We're seeing this same issue during a Rails 2.3.11 -> 3.0.5 upgrade.

  • Peter Liu

    Peter Liu March 10th, 2011 @ 03:21 AM

    I'm having an issue with simple find. For example, if do:

    class Customer
      set_table_name "legacy.customers"
      set_primary_key "legacy_id"
    end
    
    customer = Customer.find(1)
    

    I will get

    undefined method `eq' for nil:NilClass
    

    I agree that this should be a high priority as Rails 2.3.x was handling this correctly. This essentially makes Rails 3 unusable for any apps that needs to connects to tables out of the original schema. I have seen this issue brought up multiple times on different web sites.

  • Blue Box Jesse

    Blue Box Jesse March 10th, 2011 @ 05:19 PM

    The monkey patch I used to bypass this issue is attached. Not happy w/ it as a long term fix, but it works to get you started for now.

  • Dan Pickett

    Dan Pickett March 13th, 2011 @ 03:42 PM

    • State changed from “new” to “open”
    • Assigned user set to “Aaron Patterson”
    • Importance changed from “” to “Low”
  • Repository

    Repository March 21st, 2011 @ 06:48 PM

    • State changed from “open” to “resolved”

    (from [eb1eac93151c1d45c3ef292d99bfcf74799185ea]) schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved] https://github.com/rails/rails/commit/eb1eac93151c1d45c3ef292d99bfc...

  • Repository
  • Repository

    Repository March 22nd, 2011 @ 05:11 PM

    (from [2ef6270f8fbbefba8d4f10504497e198d8e7deea]) Merge branch 'master' into fuuu

    • master: Do not show optional (.:format) block for wildcard route [#6605 state:resolved] pushing id insertion and prefetch primary keys down to Relation#insert use prepared statements to fetch the last insert id escaping binary data encoding when inserting to sqlite3. Thanks Naruse! [#6559 state:resolved] schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved] Reapply extensions when using except and only SJIS is an alias to Windows-31J in ruby trunk. Use SHIFT_JIS for this test Improved resolver docs a bit [action_view] docs for FileSystemResolver [action_view] added custom patterns to template resolver https://github.com/rails/rails/commit/2ef6270f8fbbefba8d4f10504497e...
  • Joe Goggins

    Joe Goggins April 1st, 2011 @ 11:12 PM

    • Tag changed from arel, mysql2, rails3.0.1, rails3.0.3, rails3.0rc to arel, mysql2, rails3.0.1, rails3.0.3, rails3.0.6.rc2, rails3.0rc

    Hi Aaron,

    This problem does not seem fixed, even with your change as is committed in 3.0.6.rc2 commit =ea8fcfb729c0bca528d2e8522585cd6d0e98ebc7

    A class defined like such:

    class T1 < ActiveRecord::Base
      set_table_name 'bla.t1s'
    end
    

    Doing:

    T1.find(1)
    

    still yields

    NoMethodError: undefined method `eq' for nil:NilClass

        from /Users/goggins/.rvm/gems/ruby-1.8.7-p334@rails3/gems/activesupport-3.0.6.rc2/lib/active_support/whiny_nil.rb:48:in `method_missing'
        from /Users/goggins/.rvm/gems/ruby-1.8.7-p334@rails3/gems/activerecord-3.0.6.rc2/lib/active_record/relation/finder_methods.rb:291:in `find_one'
        from /Users/goggins/.rvm/gems/ruby-1.8.7-p334@rails3/gems/activerecord-3.0.6.rc2/lib/active_record/relation/finder_methods.rb:281:in `find_with_ids'
        from /Users/goggins/.rvm/gems/ruby-1.8.7-p334@rails3/gems/activerecord-3.0.6.rc2/lib/active_record/relation/finder_methods.rb:107:in `find'
        from /Users/goggins/.rvm/gems/ruby-1.8.7-p334@rails3/gems/activerecord-3.0.6.rc2/lib/active_record/base.rb:439:in `__send__'
        from /Users/goggins/.rvm/gems/ruby-1.8.7-p334@rails3/gems/activerecord-3.0.6.rc2/lib/active_record/base.rb:439:in `find'
    

    Both Blue Box Jesse and Peter Liu's problem described above still exist and the patch at:

    https://rails.lighthouseapp.com/projects/8994/tickets/5322/a/952829... still need to be manually applied to make this problem go away.

    Please let me know if there is anything I can do to help resolve this issue.

  • kmunteanu

    kmunteanu April 7th, 2011 @ 07:49 PM

    I can confirm this issue does indeed still exist in 3.0.6

  • kmunteanu

    kmunteanu April 16th, 2011 @ 09:58 AM

    also with the patch mentioned above reading associations will work, but if you try to save a model instance to the database that has a database prefix in set_table_name you will get a NoMethodError: undefined method `name' for nil:NilClass error.

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>

Referenced by

Pages