Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

ActiveRecord 4.1 support #307

Closed
chewi opened this issue Feb 4, 2014 · 23 comments
Closed

ActiveRecord 4.1 support #307

chewi opened this issue Feb 4, 2014 · 23 comments

Comments

@chewi
Copy link

chewi commented Feb 4, 2014

Beta1 has been out a while so I thought I'd give it a try. After scratching my head for a while, I realised that I needed to create a squeel/adapters/active_record/4.1 directory but that wasn't enough. The preloading stuff has changed quite a lot. In particular, rails/rails@6e5a2cb removed the run method that we have been applying alias_method_chain to. I'm afraid I am quite lost at this point.

@saki7
Copy link

saki7 commented Feb 12, 2014

+1, I tried to inspect it but I stuck at the same line.

@trestrantham
Copy link

I think was able to chain onto ActiveRecord::Associations::Preloader::Association rather than ActiveRecord::Associations::Preloader to get around the removal of run in the rails change above. However, now I'm stuck on an issue where Squeel::Adapters::ActiveRecord::JoinDependencyExtensions is passing an invalid argument via build_with_squeel (https://github.com/activerecord-hackery/squeel/blob/master/lib/squeel/adapters/active_record/join_dependency_extensions.rb#L29) to polyamourous (https://github.com/activerecord-hackery/polyamorous/blob/master/lib/polyamorous/activerecord_4.1/join_dependency.rb#L18). Removing the erroneous parameter seems to ignore squeel but I think that is probably another issue. I ran out of time but I wanted to report my findings here.

@spiffistan
Copy link

+1, support would be great

@randomor
Copy link

Having the same issue with activerecord-hackery/polyamorous#9, the build_with_polymorphism is taking 2 arguments instead of 3 in activerecord_4.1.

@ernie
Copy link
Contributor

ernie commented Mar 10, 2014

+1

@vipulnsward
Copy link

@ernie :)
I have been lazy for the past month, I had tried to bring AR 4.1 compat support, and had started to push some of the work at https://github.com/vipulnsward/squeel/tree/ar-master-compat
I hope to complete this sometime soon.

@pcriv
Copy link

pcriv commented Apr 9, 2014

+1

1 similar comment
@hasghari
Copy link

👍

@ben-moxon
Copy link

I would quite like to get this working and having taken a look at the above link, the first thing I'm running into is that in the Preloader Extensions we have lost Preloader.run, so that method chain won't run any more. Apparently it's all "internal to rails" and "low level" so we shouldn't be using it anyway, but if anyone has any suggestions about what it is being used for I might be able to put together a fix.

@chewi
Copy link
Author

chewi commented Apr 22, 2014

Unfortunately the nature of Squeel requires it to be quite tightly integrated with Rails, which can mean that we have no choice but to use those internal things that we shouldn't be using. Fixing compatibility with 4.1 is an interesting challenge that I wouldn't mind having a shot at but it's a fairly long way down my priority list.

@kakubei
Copy link

kakubei commented May 8, 2014

I'm sorry but what's the solution to this then? I'm getting the same error with Polyamorous from the activerecord-hackery repo and ActiveRecord 4.1.

Is it either stay on AR 4.0.4 or remove all traces of Squeel from our app?

@gamov
Copy link

gamov commented May 8, 2014

@kakubei Ah! Sounds familiar. I'm stuck on Rails 3.0.x because of meta_where dependency. I'm in the mist of converting all meta_where code to pure arel.

@chewi
Copy link
Author

chewi commented May 8, 2014

@kakubei Yes. Or fix it. =P

@kakubei
Copy link

kakubei commented May 8, 2014

@chewi If I could fix it, believe me I would but that's beyond my current knowledge.

@ressu
Copy link

ressu commented May 9, 2014

I ended up ripping out squeel completely. The query interface in Rails has matured quite a bit and the more complex queries I had were quite easy to rewrite to use arel or regular queries.

The biggest advantage of squeel, which is the fact that you can easily refer to columns in different tables turned out to promote misplaced code (queries in wrong models etc), so rewriting helped in spotting those problems.

Squeel definitely has its uses. But for someone like me, who uses it just for the convenience, it just guides you to use wrong coding practices.

@kakubei
Copy link

kakubei commented May 9, 2014

Well, I loved squeel. It allowed me to write much more elegant and readable queries, but now I'm in the process of removing it from all my code since I can't upgrade AR. It does give you pause when you rely on gems which you don't know if they'll be around next week.

@gamov
Copy link

gamov commented May 9, 2014

Have a look here, it might be the perfect balance between removing the 'magic' of squeel and keep the arel verbosity down: https://github.com/camertron/arel-helpers

@chewi
Copy link
Author

chewi commented May 9, 2014

@gamov Thanks! It can't do everything I use Squeel for but it's certainly not a bad compromise.

@CyborgMaster
Copy link

Squeel is central to our product design and I love it!! Does anyone know how hard it would be to upgrade? I want to help!

@nguyenchiencong
Copy link

+1

@Loremaster
Copy link

+1, we need someone to fix it!

@bigxiang
Copy link
Contributor

bigxiang commented Jul 1, 2014

I created a fork at https://github.com/bigxiang/squeel and tried to make Squeel compatible with Rails 4.1 and Rails 4.2, but I can't promise all features are well even I had passed all tests under Rails 4.1 and 4.2 ( includes multiple associations maybe works unexpectedly ) . you can try it. make sure using ruby-2-rails-edge branch.

Gemfile:

gem 'polyamorous', git: 'git://github.com/activerecord-hackery/polyamorous.git'
gem 'squeel', git: 'git://github.com/bigxiang/squeel.git', branch: 'ruby-2-rails-edge'

By the way, AR 4+ has improved a lot, I think it's good enough for common cases.

@bigxiang
Copy link
Contributor

I think it could be closed after the branch was merged, Thank you very one :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests