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
object.$relatedQuery('relation') builds incorrect query when object's 'join: { from: 'something.id' } has value 0 #228
Comments
Could you paste the code that produces the error? There must be something else wrong with the code. There is no way objection has a bug in such basic level. The test suite has tens of tests that run that exact code.
ID of a row should never be zero. Why do your sequences start with zero? |
The value 0 is no valid value for an |
It's totally possible that something's wrong with my table, but I might suggest ensuring that the value 0 does not break $relatedQuery |
As I said |
And by test case I mean any code I can easily run that reproduces the bug. |
And even if a zero id doesn't work, I'm not sure it's a bug as identifier should never be |
Indeed, an index should never be 0. I believe some other issue with an earlier version of my code inserted a 0 index user. That said, there may be situations where a user needs to join on a value 0. I'm very new to node.js so please forgive the very rough nature of this test. I'm still seeing repeatable results:
/******** index.js *********/
/******** models/User.js *********/
/******** models/GPSLocations.js *********/
Output:
|
Thank you for the test case! It indeed appears to fail as you said. I have absolutely no idea where the if (id) {
hasIds = true;
break;
} into if (id !== null && id !== undefined) {
hasIds = true;
break;
} in |
Unfortunately, there is the same output. |
This is truly weird.. I'll write some tests and fix this. |
Fixed in 0.7.0-rc.1. |
With a fresh table, user.id is starting with value 0. I ran into this issue with MySQL 5 when using the statement:
user.$relatedQuery('locations').then( ... )
knex debugging yields:
...sql: 'select * from
GPSLocation
where 1 = ?'Here is my relationshipMappings:
The text was updated successfully, but these errors were encountered: