Regression: support of non-sequence primary key lost in 0.9.1
-------------------------------------------------------------

                 Key: JRUBY-3616
                 URL: http://jira.codehaus.org/browse/JRUBY-3616
             Project: JRuby
          Issue Type: Bug
          Components: ActiveRecord-JDBC
    Affects Versions: ActiveRecord-JDBC-0.9.1
         Environment: linux x32, java 6
jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
activerecord (2.3.2)
activerecord-jdbc-adapter (0.9.1)
activerecord-jdbcpostgresql-adapter (0.9.1)
activesupport (2.3.2)
jdbc-postgres (8.3.0, 8.2)

            Reporter: David Kellum


Given a postgreSQL schema like this:

                            Table "urls"
      Column       |            Type             |        Modifiers         
-------------------+-----------------------------+--------------------------
 uhash             | text                        | not null
 url               | text                        | not null
Indexes:
    "urls_pkey" PRIMARY KEY, btree (uhash)

Which FWIW, was created from a migration like this:

# Base Urls table schema
  class BaseUrls < ActiveRecord::Migration
    def self.up
      create_table  'urls',  :id => false do |t|
        t.text      'uhash', :null => false  
        t.text      'url',   :null => false 
      end
      execute "ALTER TABLE urls ADD PRIMARY KEY (uhash)"
    end
    def self.down
      drop_table 'urls'
    end
  end

And corresponding class:

  class Url < ActiveRecord::Base
    set_primary_key :uhash
  end

With 0.9.1 the following error occurs on first usage (create!). This does not 
occur if I downgrade the same setup to 0.9 (no other changes):

ActiveRecord::StatementInvalid: ActiveRecord::ActiveRecordError: ERROR: 
relation "urls_uhash_seq" does not exist: SELECT currval('urls_uhash_seq')
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in
 `log'
    
/opt/jruby/gems/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:563:in
 `execute'
    
/opt/jruby/gems/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:623:in
 `select'
    
/opt/jruby/gems/gems/activerecord-jdbc-adapter-0.9.1/lib/active_record/connection_adapters/jdbc_adapter.rb:559:in
 `select_one'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:19:in
 `select_value'
    
/opt/jruby/gems/gems/activerecord-jdbc-adapter-0.9.1/lib/jdbc_adapter/jdbc_postgre.rb:289:in
 `last_insert_id'
    
/opt/jruby/gems/gems/activerecord-jdbc-adapter-0.9.1/lib/jdbc_adapter/jdbc_postgre.rb:240:in
 `insert'
    /opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/base.rb:2902:in 
`create'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/timestamp.rb:29:in 
`create_with_timestamps'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:266:in 
`create_with_callbacks'
    /opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/base.rb:2868:in 
`create_or_update'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:250:in 
`create_or_update_with_callbacks'
    /opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/base.rb:2556:in 
`save!'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/validations.rb:1019:in
 `save_with_validation!'
    /opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/dirty.rb:87:in 
`save_with_dirty!'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/transactions.rb:200:in
 `save_with_transactions!'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in
 `transaction'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/transactions.rb:182:in
 `transaction'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/transactions.rb:200:in
 `save_with_transactions!'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/transactions.rb:208:in
 `rollback_active_record_state!'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/transactions.rb:200:in
 `save_with_transactions!'
    
/opt/jruby/gems/gems/activerecord-2.3.2/lib/active_record/validations.rb:990:in 
`create!'



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to