Coder Social home page Coder Social logo

Comments (11)

cfis avatar cfis commented on August 31, 2024

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.

cleesmith avatar cleesmith commented on August 31, 2024

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.

cfis avatar cfis commented on August 31, 2024

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.

cleesmith avatar cleesmith commented on August 31, 2024

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.

cfis avatar cfis commented on August 31, 2024

The 4.x series. Or in git, look at the ar_3.1x branch.

from composite_primary_keys.

cfis avatar cfis commented on August 31, 2024

Ok, fixed in master adedcf8, will be in next release. Thanks for finding this bug.

Charlie

from composite_primary_keys.

cleesmith avatar cleesmith commented on August 31, 2024

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.

cfis avatar cfis commented on August 31, 2024

FYI, MySql tests now all pass also.

from composite_primary_keys.

cleesmith avatar cleesmith commented on August 31, 2024

Cool, thanks again.

from composite_primary_keys.

cfis avatar cfis commented on August 31, 2024

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.

cleesmith avatar cleesmith commented on August 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.