Support for ActiveRecord 4.0.x #149

wants to merge 19 commits into


None yet

3 participants


🎆 🎆 🎆 🎆 🎆 🎆 🎆 🎆

The tests are 💚 for mysql, postgresql, and sqlite3. Someone else will need to check the other adapters.

Since I'm just a 👶 in CPK land, I do encourage you to review my work! In particular, see commit: codeodor@4c731ef where I changed the test. Because of changes in Rails which broke some unstated assumptions in the code, I think it was OK to do that. However, I'd like you to review that one in detail to be sure!

I now consider this pull request ready to be merged into the main repo, though if you wish to maintain backward compatibility, you may consider not merging it directly into master, since I made no effort to keep it working with Rails 3.2.x.

The original PR message follows:

⚠️ This is not a complete pull request, and it should not be merged into the master branch! ⚠️

I chose master as the base branch because there is not an "ar_4.0.x" branch in the CPK repository like there is for Rails 3.1 and 3.2.

I'm starting an incomplete pull request because I would not be shocked to learn that a lot of people are already working on compatibility with Rails 4.0, and we are working in isolation instead of having a central body of knowledge.

So far, I've added a few of the obvious cases which I needed to get all of my own app's tests passing. There is a little I've left out, because for the moment they are horrible kludges, but I will fix them and include them too!

After that, I'll begin focusing on the MySQL tests, then Postgres, then whatever other DBs are supported.

Someone else feel free to join in. I guess fork my ar_4.0.x branch and make pull requests there? Or get with me and I'll assign you collaborator access to commit directly.

Once we get far enough, we'll update this Pull Request for review by the CPK team.

👍 ?

codeodor added some commits Mar 20, 2013
@codeodor codeodor change AR dependency 0976c66
@codeodor codeodor tell CPK to use Rails 4.0 beta1 28431b2
@codeodor codeodor change referenced of #scoped to #scope 8d582e5
@codeodor codeodor new namespace for ConnectionSpecification::Resolver cf14706
@codeodor codeodor new initialize method for Relation 2d4152f
@codeodor codeodor change Dirty implementation to match Rails 4 855e00a
@codeodor codeodor use the loaded Rails' implementation of the method unless it applies …
…to CPK
@codeodor codeodor use Rails' version unless it applies to CPK 430d6a2
@codeodor codeodor updates to look like Rails AssociationScope 90bf124
@codeodor codeodor fix for default ordering by primary key 1bdf251
@codeodor codeodor fix CPK update, switch to including CPK persistence as a module to ga…
…in access to `super` in Rails
@codeodor codeodor fix for removal of `in?` method 4fe1b55
@codeodor codeodor fix nil scope 74010dd
@codeodor codeodor fix for default ordering by PK when column names are ambiguous due to…
… being present in multiple tables in the query
@codeodor codeodor fix for destroy 14f7899
@codeodor codeodor change back to following Rails to fix #changes on composite_belongs_to 2b504ce
@codeodor codeodor Fix test for bracket assignment (see description)
Rails 4 has a commit (see rails/rails@522c0fd) that ensures the PK is always present in the @attributes hash, which was causing this test to break when attempting to assign values to that key in the hash (since it just loops over them).

Given there was no expectation the key existed in the prior versions, a valid fix seemed to me to be to do not test assignment in this version.

However, I'm not sure if that's a valid assumption or not, so please review / consider that carefully.

MySQL tests are 💚 as of this comment!

@codeodor codeodor 💚 for mysql: move initialize_dupe into new core file so `super` does …
…not end up calling the Rails version of the method

No commits needed for postgresql, it's a 💚 too.


sqlite3 gets the 💚

That's all I can do. Someone else will need to test ibmdb, oracle, and oracle_enhanced.

cfis commented Apr 14, 2013

HI codeodor - thanks for the patch and AR 4.0 support. We aren't planning on switching soon to Rails 4 though, so I'm happy to go with what you have done for now.

We'll want to up the major version number of CPK I think and create a new branch for AR 4.0. Then make a pre-release gem. So I can setup a branch and then i'll see if I can merge this pull request into it.


Sure, that makes sense. Once you create the branch, I can resubmit the pull request to the correct branch (or maybe modify it using the API, if possible) if you'd like.

Let me know how else I can be of help!

wogg commented Apr 24, 2013

We over at RescueTime are very interested in getting this branch created as well.
Can assist with real-world testing.

cfis commented Apr 28, 2013

Applied - thanks!

Definitely submit patches as you find stuff.

@cfis cfis closed this Apr 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment