You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If left expression refers to main table and right refers to joined table, keep as is
151
+
if(
152
+
leftTableAlias===mainTableAlias&&
153
+
rightTableAlias===joinedTableAlias
154
+
){
155
+
return{mainExpr: left,joinedExpr: right}
156
+
}
157
+
158
+
// If left expression refers to joined table and right refers to main table, swap them
159
+
if(
160
+
leftTableAlias===joinedTableAlias&&
161
+
rightTableAlias===mainTableAlias
162
+
){
163
+
return{mainExpr: right,joinedExpr: left}
164
+
}
165
+
166
+
// If both expressions refer to the same alias, this is an invalid join
167
+
if(leftTableAlias===rightTableAlias){
168
+
thrownewError(
169
+
`Invalid join condition: both expressions refer to the same table "${leftTableAlias}"`
170
+
)
171
+
}
172
+
173
+
// If one expression doesn't refer to either table, this is an invalid join
174
+
if(!leftTableAlias||!rightTableAlias){
175
+
thrownewError(
176
+
`Invalid join condition: expressions must reference table aliases "${mainTableAlias}" and "${joinedTableAlias}"`
177
+
)
178
+
}
179
+
180
+
// If expressions refer to tables not involved in this join, this is an invalid join
181
+
thrownewError(
182
+
`Invalid join condition: expressions reference tables "${leftTableAlias}" and "${rightTableAlias}" but join is between "${mainTableAlias}" and "${joinedTableAlias}"`
0 commit comments