Skip to content
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

Improve base.rb & update active_hash #254

Merged
merged 8 commits into from
Aug 10, 2021
Merged

Conversation

senhalil
Copy link
Contributor

@senhalil senhalil commented Jul 8, 2021

For has_many and belongs_to

Closes optimizer-api/-/issues/446

@senhalil senhalil requested a review from braktar July 8, 2021 17:05
Copy link
Contributor

@braktar braktar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding this test error : https://github.com/Mapotempo/optimizer-api/pull/254/checks?check_run_id=3021525858#step:5:1659
It seems like the getter for end_point_id may not work as expected

@senhalil
Copy link
Contributor Author

senhalil commented Jul 9, 2021

It turns out this is due to a weird behaviour in active_hash. It is possible to create two Point objects as {id: 1} and {id: "1"} but it is not possible to to get {id: "1"} because there is a to_s in the insert and find methods.

This means if the user defines two points -- one with integer, the other with string -- there is no warning (which is cool) but then start_point_id: "1" and start_point_id: 1 will both point to the Point with id: 1. This is just calling for trouble because "1" and 1 are not the same thing and to_s is not necessary because Hash can handle integer keys. I will open a PR in active_hash repo

@senhalil
Copy link
Contributor Author

senhalil commented Jul 12, 2021

@senhalil senhalil changed the title Improve getter/setter of base.rb Improve getter/setter of base.rb & update active_hash Jul 15, 2021
@senhalil senhalil changed the title Improve getter/setter of base.rb & update active_hash Improve base.rb & update active_hash Jul 15, 2021
Remove dead code
Fix y_ids= operators
Find raises if id does not exists
Add getter for has_many ids
Fix id getter of belongs_to
Functions keep the id(s) up-to-date
Generate only necessary id functions
Generate only correct ids functions
lib/tsp_helper.rb Outdated Show resolved Hide resolved
@fab-girard fab-girard merged commit 721e32b into Mapotempo:dev Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants