-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add composite primary key support #430
Merged
brendon
merged 12 commits into
brendon:master
from
divagueame:Add-composite-primary-key-support
Jun 2, 2024
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f282b8f
Add tests for CompositePrimaryKeyList
divagueame 8971888
Adjust query when instance has a composite primary index
divagueame 39c3e0a
Fix version tested for composite primary key
divagueame 3a6c180
Update primary_key_condition and use like where.not()
divagueame ebdeb62
Add rails_7_1.gemfile + GH Actions Matrix
divagueame 544d855
Update primary_key_condition
divagueame 9aed3f5
Refactor shared_list module
divagueame 1fe83bb
Merge branch 'master' into Add-composite-primary-key-support
divagueame 115ab4b
Remove ci.yml
divagueame 4645acf
Clean previously create rails_7_1.gemfile
divagueame 8ecc8b0
Only create with id if it's composite primary key
divagueame 0d3a71b
Add Changelog entry
divagueame File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "http://rubygems.org" | ||
|
||
gem "rake" | ||
gem "appraisal" | ||
gem "activerecord", "~> 7.1.0" | ||
|
||
group :development do | ||
gem "github_changelog_generator", "1.9.0" | ||
end | ||
|
||
group :test do | ||
gem "minitest", "~> 5.0" | ||
gem "timecop" | ||
gem "mocha" | ||
end | ||
|
||
group :sqlite do | ||
gem "sqlite3", "~> 1.4" | ||
end | ||
|
||
group :postgresql do | ||
gem "pg", "~> 1.2.0" | ||
end | ||
|
||
group :mysql do | ||
gem "mysql2", "~> 0.5.0" | ||
end | ||
|
||
gemspec path: "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this one. I run
bundle exec appraisal install
while using ruby 3.1.5p252 (2024-04-23 revision 1945f8dc0e) [x86_64-linux] and I get gem "pg", "~> 1.2.0"However, on rails_7_0.gemfile, it uses
gem "pg", "~> 1.3.0"
Tried running it with other higher versions of ruby but always get this error:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found that you can use this line to help with that installation:
bundle config build.pg --with-cflags="-Wno-error=implicit-function-declaration"
However, the whole appraisal testing thing is a real pain. I was able to do it a different way with my other gem:
https://github.com/brendon/positioning/blob/main/.github/workflows/main.yml
https://github.com/brendon/positioning/blob/main/Gemfile
It's then easy to set up a matrix of tests across Rails, Ruby, and database libraries and only pick the compatible ones.
The downside is that this doesn't run well locally. If you want to try this way, by all means, but I realise it's quite an extra job in and of itself :) If the compile line above gets things working for you then just carry on I think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I have tried a bit of everything but without much success. I have also tried testing the gem from a clear Dockerfile and also got the same error about installing 'pg' gem. The only solution I can think of is bumping 'pg' version to "~> 1.3.0" but I guess that make the gem not compatible anymore with older versions of Ruby, so that might not be an option in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be time to drop support for older rails/ruby versions. Did you first want me to have a go at getting rid of the appraisals gem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be great. I tried that too but I failed, since I don't know very well how that should be set up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's all good. It's fairly complicated. I've done those changes on
master
not and the tests pass. It just tests Rails 6.1+ and Ruby 3.0+:https://github.com/brendon/acts_as_list/actions/runs/9310848684
Feel free to update from master and then try out the tests. You can control the Rails, Ruby and DB versions via the command line:
RAILS_VERSION=7.1 (for example)
DB=sqlite | mysql | postgresql
Ruby: You just need to use rbenv or something like that and change your
.ruby-version
file.Appraisals was good but a lot of work to maintain and people also used to not understand it and just edit the automatically generated bundler files :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to run bundle for each rails version you want to use:
RAILS_VERSION=7.1 bundle
RAILS_VERSION=7.1 DB=postgresql bundle exec rake
(to run the tests)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! That worked well. I was able to successfully run the tests both locally and through the CI on my fork.