-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
parser cache and nestTables issue #1142
Comments
is this what you expect as correct result for the second query? {
"serverRole": {
"role_id": 1,
"name": "Guest"
},
//...
} |
Should be [{
"serverRole": {
"role_id": 1,
"name": "Guest"
},
"bm_web_player_roles": {
"player_id": {
"type": "Buffer",
"data": [
83,
69,
142,
157,
181,
81,
78,
115,
167,
178,
211,
250,
200,
212,
29,
103
]
}
}
}
] |
not sure why key is the same, usually alias is what field.name returns. Could you log what's passed to node-mysql2/lib/parsers/parser_cache.js Line 10 in ecfd554
|
> con.query({ nestTables: true, sql: 'select `role`.`role_id`, `role`.`name`, `bm_web_player_roles`.`player_id` from `bm_web_player_roles` inner join `bm_web_roles` as `role` on `bm_web_player_roles`.`role_id` = `role`.`role_id` where `bm_web_player_roles`.`player_id` in (X\'53458e9db5514e73a7b2d3fac8d41d67\', X\'1e14467b1013458fa3a1af3fce1eb29f\', X\'d5918acd7ebb43d8ac42b358f64c5309\')' }, () => {})
> con.query({ nestTables: true, sql: 'select `serverRole`.`role_id`, `serverRole`.`name`, `bm_web_player_server_roles`.`player_id` from `bm_web_player_server_roles` inner join `bm_web_roles` as `serverRole` on `bm_web_player_server_roles`.`role_id` = `serverRole`.`role_id` where `bm_web_player_server_roles`.`player_id` in (X\'53458e9db5514e73a7b2d3fac8d41d67\', X\'1e14467b1013458fa3a1af3fce1eb29f\', X\'d5918acd7ebb43d8ac42b358f64c5309\')' }, () => {})
Diff of |
oh, |
node-mysql2/lib/packets/column_definition.js Line 125 in ecfd554
|
Add table to parser cache key #1142
Using Knex, the following two queries are built
When executed with mysql2 with the
nestTables
option set to true, they appear to provide the same key for the joined value despite different aliases.1st query result:
2nd query result:
Note the second query references 'role' instead of 'serverRole' as defined in the query. If the second query is instead executed first, the key is serverRole for both.
On the surface, this seems to be caused by
keyFromFields
within parser cache returning the same value for both, and therefore reusing the same parser. Not leveraging the cached parser returns the expected result.I'm aware this may be an edge case and the queries without context may seem odd. I'm trying to dynamically build queries for a GraphQL server to ensure only requested fields are selected from the database, using the graphql schema object name for the join alias.
Not sure what the best way around this is?
The text was updated successfully, but these errors were encountered: