Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Problem with base.rb and postgresdb

#1420

A sample test program : main.rb

require 'rubygems' require 'active_record'

class TransactionMGT < ActiveRecord::Base set_table_name('transaction_mgt'); end

ActiveRecord::Base.establish_connection( :adapter => 'postgresql',

                                      :host => '80.13.207.231',
                                      :port => 44000,
                                      :username => 'hipaydbuser',
                                      :password => 'hipaydbuser',
                                      :database => 'hipay_db',
                                      :schema_search_path => 'mgt_db'
                                    );

allTransactionMGT = TransactionMGT::find(:all); allTransactionMGT.each do |aTransaction| print " #{aTransaction.id} #{aTransaction.issuer_user_account_id} \n " end


the real structure of the table :

CREATE TABLE mgt_db.transaction_mgt ( id integer NOT NULL, issuer_user_account_id integer NOT NULL, recipient_user_account_id integer NOT NULL, fees_id integer NOT NULL, card_id integer, web_id character varying(23) NOT NULL, libelle_code integer NOT NULL, montant numeric(10,2) NOT NULL, fee numeric(10,2), devise character(3) NOT NULL, type_src integer NOT NULL, libelle character varying(255) NOT NULL DEFAULT 'None'::character varying, date_insert timestamp with time zone NOT NULL DEFAULT now(), status_code character varying(5) NOT NULL DEFAULT 'NEW'::character varying, max_date_cancel date, amount_refunded numeric(10,2) DEFAULT 0.00, amount_cancelled numeric(10,2) DEFAULT 0.00, amount_captured numeric(10,2) DEFAULT 0.00, reject_code integer, "type" integer NOT NULL, max_date_refund date, tsdate_last_capture integer DEFAULT 0, tsdate_last_cancel integer DEFAULT 0, tsdate_last_refund integer DEFAULT 0, tsdate_auth integer DEFAULT 0, warning_level integer DEFAULT 0, faf_returns text DEFAULT ''::text, dispatched integer NOT NULL DEFAULT 0, mp_acqueror_id integer NOT NULL DEFAULT 0, CONSTRAINT transaction_mgt_pkey PRIMARY KEY (id), CONSTRAINT transaction_mgt_card_id_fkey FOREIGN KEY (card_id)

  REFERENCES hipay_db.cbs (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_devise_fkey FOREIGN KEY (devise)

  REFERENCES mgt_db.devise (code) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_fees_id_fkey FOREIGN KEY (fees_id)

  REFERENCES mgt_db.transaction_fees (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_issuer_user_account_id_fkey FOREIGN KEY (issuer_user_account_id)

  REFERENCES hipay_db.compte (account_id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_libelle_code_fkey FOREIGN KEY (libelle_code)

  REFERENCES mgt_db.libelle_transaction (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_mp_acqueror_id_fkey FOREIGN KEY (mp_acqueror_id)

  REFERENCES mp_db.mp_acqueror (id_acq) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_recipient_user_account_id_fkey FOREIGN KEY (recipient_user_account_id)

  REFERENCES hipay_db.compte (account_id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_reject_code_fkey FOREIGN KEY (reject_code)

  REFERENCES mgt_db.reject_code (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_status_code_fkey FOREIGN KEY (status_code)

  REFERENCES mgt_db.transaction_status_code (code) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_type_fkey FOREIGN KEY ("type")

  REFERENCES mgt_db.type_transaction (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,

CONSTRAINT transaction_mgt_type_src_fkey FOREIGN KEY (type_src)

  REFERENCES mgt_db.type_src_dst (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION

) WITH (OIDS=FALSE); ALTER TABLE mgt_db.transaction_mgt OWNER TO hipaydbuser; GRANT ALL ON TABLE mgt_db.transaction_mgt TO hipaydbuser;


I don' think constraints are responsible of the problem. So it should be ok to recreate the table without constraints.

And the error is :

/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:1912:in compute_type': compile error (SyntaxError) /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:1912: syntax error, unexpected tINTEGER Object::2

     ^
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:1432:in `instantiate'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:586:in `find_by_sql'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:586:in `collect!'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:586:in `find_by_sql'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:1345:in `find_every'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:540:in `find'
    from /home/thierry/NetBeansProjects/BOAutodisable/lib/main.rb:21


my gem env : RubyGems Environment: - RUBYGEMS VERSION: 1.3.1 - RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /usr/bin - RUBYGEMS PLATFORMS:

- ruby
- x86-linux

  • GEM PATHS:
    • /usr/lib/ruby/gems/1.8
    • /home/thierry/.gem/ruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

Gem packages :

LOCAL GEMS

actionmailer (2.1.2, 2.1.1) actionpack (2.1.2, 2.1.1) activerecord (2.1.2, 2.1.1) activeresource (2.1.2, 2.1.1) activesupport (2.1.2, 2.1.1) linecache (0.43) rails (2.1.2, 2.1.1) rake (0.8.3) ruby-debug-base (0.10.3, 0.10.2) ruby-debug-ide (0.4.1, 0.3.1) rubygems-update (1.3.1, 1.3.0)

--- Postgres postgresql-8.3 (8.3.4-2.2) on Ubuntu 8.10

Reported by Thierry DELHAISE · November 20th, 2008 @ 02:37 AM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Frederick Cheung
    Frederick Cheung
    • State changed from new to invalid

    You table has a column called type, which ActiveRecord assumes is for single type inheritance (ie contains the name of the class to instantiate).

    Either rename that column or use set_inheritance_column to tell ActiveRecord not to use the type column for that purpose for this specific class.

    December 14th, 2008 @ 05:55 PM