Comments (11)
Hi cleesmith,
Thanks for reporting the issue. Definitely would be better to not have to convert the cpk to a string to then parse it. If you have time, would be good to set this up in the test suite so we can have a test for it. I don't think any of the tables have the set of primary keys, but its worth a look. If not, maybe we should add one.
from composite_primary_keys.
I don't have time this week or next, but I am using my fork of cpk in a project working with the Snort legacy database where almost every table has both of those primary keys.
Also, when I run the tests for MySQL I get a few errors ... it would be nice to start off cleanly, not complaining, just FYI:
rake mysql:build_databases
rake mysql:test
. . .
105 tests, 266 assertions, 5 failures, 1 errors, 0 skips
1) Error:
test_has_many_through_when_not_pre_loaded(TestAssociations):
ActiveRecord::StatementInvalid: Mysql::Error:
Duplicate column name 'dorm_id':
SELECT COUNT(*) FROM (SELECT DISTINCT * FROM `rooms`
INNER JOIN `room_assignments`
ON `rooms`.`dorm_id` = `room_assignments`.`dorm_id`
AND `rooms`.`room_id` = `room_assignments`.`room_id`
WHERE `room_assignments`.`student_id` = 1) subquery_for_count
2) Failure:
test_to_key_with_composite_keys_unsaved(TestAttributeMethods) [/Sites/composite_primary_keys/test/test_attribute_methods.rb:39]:
Expected [0, nil] to be nil.
3) Failure:
test_and(TestEqual) [/Sites/composite_primary_keys/test/test_predicates.rb:32]:
<"\"departments\".\"id\" = 0 AND \"departments\".\"id\" = 1 AND \"departments\".\"id\" = 2"> expected
but was <"`departments`.`id` = 0 AND `departments`.`id` = 1 AND `departments`.`id` = 2">.
4) Failure:
test_or(TestEqual) [/Sites/composite_primary_keys/test/test_predicates.rb:18]:
<"((\"departments\".\"id\" = 0) OR (\"departments\".\"id\" = 1) OR (\"departments\".\"id\" = 2))"> expected
but was <"((`departments`.`id` = 0) OR (`departments`.`id` = 1) OR (`departments`.`id` = 2))">.
5) Failure:
test_not_found(TestFind) [/Sites/composite_primary_keys/test/test_find.rb:53]:
<"Couldn't find ReferenceCode with ID=999,999 WHERE \"reference_codes\".\"reference_type_id\" = 999 AND \"reference_codes\".\"reference_code\" = 999"> expected
but was
<"Couldn't find ReferenceCode with ID=999,999 WHERE `reference_codes`.`reference_type_id` = 999 AND `reference_codes`.`reference_code` = 999">.
6) Failure:
test_assign_ids(TestIds) [/Sites/composite_primary_keys/test/test_ids.rb:86]:
<[nil, nil]> expected but was
<[0, nil]>.
Also, there is an error and some deprecation warnings (activerecord 3.2.0?):
Using native MySQL
DEPRECATION WARNING: Calling set_primary_key is deprecated. Please use `self.primary_key = 'the_name'` instead. (called from set_primary_keys at /Users/cleesmith/Sites/composite_primary_keys/lib/composite_primary_keys/base.rb:14)
DEPRECATION WARNING: Calling set_primary_key is deprecated. Please use `self.primary_key = 'the_name'` instead. (called from <class:ReferenceType> at /Users/cleesmith/Sites/composite_primary_keys/test/fixtures/reference_type.rb:2)
Unable to load restaurants_suburb, underlying cause No such file to load -- restaurants_suburb
. . . but I can't find the reference, but I think that should be restaurants_suburbs instead.
I will look at the tests to see if I can find something similar to the Snort situation.
Thanks.
from composite_primary_keys.
Great - thanks. Do you see failiures on Rails 3.1? Wondering if these are new errors for Rails 3.2 that need solving.
from composite_primary_keys.
Which version of cpk would I need to download to test with Rails 3.1, as doing a git clone is 3.2.0 specific ?
from composite_primary_keys.
The 4.x series. Or in git, look at the ar_3.1x branch.
from composite_primary_keys.
Ok, fixed in master adedcf8, will be in next release. Thanks for finding this bug.
Charlie
from composite_primary_keys.
Thank you very much. I'm sorry I couldn't have been of more help with this issue ... I will try to better open source citizen in the future.
from composite_primary_keys.
FYI, MySql tests now all pass also.
from composite_primary_keys.
Cool, thanks again.
from composite_primary_keys.
No worries - thanks for submitting the bug. New Gem just uploaded to rubygems.org. Give it a try - hope it works!
Charlie
from composite_primary_keys.
Just tried the new cpk gem release with the legacy db project I've been working on and it works great! Thanks, again.
from composite_primary_keys.
Related Issues (20)
- ActiveRecord::StatementInvalid when calling delete_all on composite_primary_keys table HOT 19
- AR#preload doesn't work as expected with duplicated ids in 13.0.3 HOT 2
- Wrong arity for uniqueness validate_each
- arm64-darwin-21 HOT 1
- cpk fails when used with rspec stub_model in rails 6.0 HOT 6
- ActiveStorage Support? HOT 1
- Tracking issue: Rails first class cpk support HOT 3
- Does not work with string primary keys HOT 1
- Improved query for models loaded with eager loading HOT 6
- rubygems report "This gem version has been yanked" HOT 5
- Duplicate order columns on composite keys when reversing HOT 1
- Syntax simplification for mulitenancy / row-level security HOT 1
- TinyTds::Error: Invalid column name 'pk1,pk2'. HOT 3
- Is it possible to add License? HOT 4
- foreign_key and references in migrations does not work HOT 1
- Failure to destroy dependent CPK record causes a TypeError HOT 1
- Saving CPK in a normal PK attribute stopped working after upgrading to Rails 6.1 HOT 3
- Is gem still relevant with Rails 7.1? HOT 14
- Changing PK in existing table HOT 1
- Setting a relationship explicitly to null that uses a CPK triggers odd and incorrect validation error HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composite_primary_keys.