anlek / mongify

Mongify allows you to map your data from a sql database and into a mongodb document database.
http://github.com/anlek/mongify
MIT License
317 stars 82 forks source link

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

Open sanjusoftware opened 7 years ago

sanjusoftware commented 7 years ago

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?

anlek commented 7 years ago

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