mongify icon indicating copy to clipboard operation
mongify copied to clipboard

Oracle 11g LIMIT 10000 OFFSET 0 (ActiveRecord::StatementInvalid)

Open sanjusoftware opened this issue 8 years ago • 1 comments

Trying to connect to Oracle 11g database using following Gemfile:

source 'https://rubygems.org'

gem 'mongify', '~> 1.3.1'
gem 'ruby-oci8'
gem 'activerecord-oracle_enhanced-adapter'

My translation looks like following:

table "pcm_customer" do
  column "id", :key
  column "customerid", :key
  column "customertype", :string
  column "created_at", :datetime
  column "updated_at", :datetime
end

table "pcm_custidcard", :embed_in => :customers, :on => :customerid do
  column "id", :key
  column "customerid", :integer, :references => :customers
  column "published_at", :datetime
  column "created_at", :datetime
  column "updated_at", :datetime
end

Running the following command:

mongify pr database.config translation.rb

and I get the following error:

stmt.c:243:in oci8lib_230.bundle: OCIError: ORA-00933: SQL command not properly ended: SELECT * FROM pcm_customer LIMIT 10000 OFFSET 0 (ActiveRecord::StatementInvalid)

Oracle 11g does not support LIMIT / OFFSET like above, so the error is understandable. However, I looked a lot suspecting that I was using some wrong version of the oracle-enhanced-adapter or something. But turns out, its hardcoded here: in mongify-1.3.1/lib/mongify/database/sql_connection.rb:103

Since you are using ActiveRecord to handle database queries etc, is there a particular reason why you are not letting ActiveRecord to also make the statement as well? Because this implementation is very specific and will not work in situations like this.

Also, in the meanwhile, is there a way that I can override it?

sanjusoftware avatar Jul 26 '17 03:07 sanjusoftware

@sanjusoftware Currently you'd have to fork the project, modify the code and run it from your own fork.

anlek avatar Aug 28 '17 02:08 anlek