-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Given this model:
entity Bar {
key ID : Integer;
baz : Association to Baz;
hurz : Association to Hurz;
}
entity Baz {
key ID : Integer;
}
entity Hurz {
key ID : Integer;
}the where clause of the exists subquery is broken:
> q = SELECT.from('Bar[baz = 1 and baz = ID]:hurz')
Query {
SELECT: {
from: {
ref: [
{
id: 'Bar',
where: [
{ ref: [ 'baz' ] },
'=',
{ val: 1 },
'and',
{ ref: [ 'baz' ] },
'=',
{ ref: [ 'ID' ] }
]
},
'hurz'
]
}
}
}
> q.forSQL()
Query {
SELECT: {
from: { ref: [ 'Hurz' ], as: 'hurz' },
where: [
'exists',
{
SELECT: {
from: { ref: [ 'Bar' ], as: 'Bar' },
columns: [ { val: 1 } ],
where: [
{ ref: [ 'Bar', 'hurz_ID' ] },
'=',
{ ref: [ 'hurz', 'ID' ] },
'and',
{ xpr: [ { ref: [ 'Bar', 'baz_ID' ] }, '=', { val: 1 } ] },
'and', // ❌❌❌❌
'=',
{ ref: [ 'Bar', 'ID' ] }
]
}
}
],
columns: [ { ref: [ 'hurz', 'ID' ] } ]
}
}also broken in a different way if the condition is flipped:
> q = SELECT.from('Bar[baz = 1 and ID = baz]:hurz')
Query {
SELECT: {
from: {
ref: [
{
id: 'Bar',
where: [
{ ref: [ 'baz' ] },
'=',
{ val: 1 },
'and',
{ ref: [ 'ID' ] },
'=',
{ ref: [ 'baz' ] }
]
},
'hurz'
]
}
}
}
> q.forSQL()
Query {
SELECT: {
from: { ref: [ 'Hurz' ], as: 'hurz' },
where: [
'exists',
{
SELECT: {
from: { ref: [ 'Bar' ], as: 'Bar' },
columns: [ { val: 1 } ],
where: [
{ ref: [ 'Bar', 'hurz_ID' ] },
'=',
{ ref: [ 'hurz', 'ID' ] },
'and',
{ xpr: [ { ref: [ 'Bar', 'baz_ID' ] }, '=', { val: 1 } ] },
'and',
{ ref: [ 'Bar', 'ID' ] },
'=',
{ ref: [ 'Bar', 'baz' ] } // ❌❌❌❌
]
}
}
],
columns: [ { ref: [ 'hurz', 'ID' ] } ]
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working