-
Notifications
You must be signed in to change notification settings - Fork 41
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
Unexpected quoted_word
token when performing Nested Join
#153
Comments
quoted_word
token when performing LEFT OUTER JOIN quoted_word
token when performing Nested Join
After doing some digging, I believe the issue is the grammar for I currently have this as the updated select_table_join
-> select_join_op %kw_join select_from_subject select_table_join_clause:? {% x => track(x, {
...unwrap(x[2]),
join: {
type: toStr(x[0], ' '),
...x[3] && unwrap(x[3]),
}
}) %}
# ---- NEW BELOW ----
| select_join_op %kw_join select_from_item_joins select_table_join_clause {% x => {
return track(x, {
...(flatten(x[2]) || [])[0],
join: {
type: toStr(x[0], ' '),
...x[3] && unwrap(x[3]),
}
})
} %} This will enable the parser to recursively pick out the nested joins, but I'm having issues figuring out the function at the end. I came up with this test, which I think has the correct expectation: checkSelect([`SELECT * FROM "ta"
LEFT OUTER JOIN ("tb" INNER JOIN "tc" ON "tc"."id" = "tb"."tc_id")
ON "ta"."id" = "tc->tb"."ta_id"`],
{
type: 'select',
columns: [{ expr: star }],
from: [
tbl('ta'),
{
name: name('tb'),
type: "table",
join: {
type: "LEFT JOIN",
on: {
left: {
name: "id",
table: {
name: "ta"
},
type: "ref"
},
op: "=",
right: {
name: "ta_id",
table: {
name: "tc->tb",
},
type: "ref",
},
type: "binary",
},
},
},
{
name: name("tc"),
type: "table",
join: {
type: "INNER JOIN",
on: {
left: {
name: "id",
table: {
name: "tc"
},
type: "ref",
},
op: "=",
right: {
name: "tc_id",
table: {
name: "tb"
},
type: "ref",
},
type: "binary",
},
}
}
],
}) @oguimbal Can you help confirm if this is the correct AST from that query, and if you have any insights in how to get the function to output this please? |
I'm using
pg-mem@2.8.1
withsequelize@v6
, and I'm getting the following error frompg-mem
(probably bubbled up from this package), when Iinclude
an association via athrough
relationship. Sequelize models it as a parenthetical LEFT OUTER JOIN with a nested INNER JOIN.Given the following query:
I receive this error:
The text was updated successfully, but these errors were encountered: