Search code examples
sqlruby-on-railsruby-on-rails-4arelwith-clause

Rails 4 AR `from` different than rails 3?


In rails 3 if I write: Model.from('models') arel generates the following sql:

select "models".* from models

In rails 4 the same arel generates the following sql:

select "models".* from 'models', NULL

The table name is wrapped in quotes and ', NULL' is appended. How do I use arel to give me the same results as in rails 3?

I was leveraging the original behavior so I could run a fairly complex with recursive query against postgres. In rails4, postgres is choking when it gets to the single quote preceding value I give from.

Is there a better way to do a with recursive query? Or, is there a way to query with arel so it works as before?


Solution

  • This appears to be an incompatibility with the squeel gem (the master branch as of today).

    EDIT I've sent a pull request to squeel's master branch. Fixes the issue for me.

    EDIT 2: Merged into master