[jOOQ/jOOQ#14372] Parser reports wrong Ambiguous field identifier error when derived tables share column names

This commit is contained in:
Lukas Eder 2022-12-06 14:59:10 +01:00
parent 0da4dea7cb
commit ca5fb47c5b
2 changed files with 6 additions and 1 deletions

View File

@ -14703,7 +14703,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
private final void scopeEnd(Query scopeOwner) {
List<FieldProxy<?>> retain = new ArrayList<>();
for (FieldProxy<?> lookup : scope.lookupFields) {
// [#14372] Avoid looking up fields at a higher scope level
for (FieldProxy<?> lookup : scope.lookupFields.iterableAtScopeLevel()) {
Value<Field<?>> found = null;
for (Field<?> f : scope.fieldScope) {

View File

@ -110,6 +110,10 @@ final class ScopeStack<K, V> implements Iterable<V> {
return iterable(e -> true).iterator();
}
final Iterable<V> iterableAtScopeLevel() {
return () -> new ScopeStackIterator<>(list -> list.size() == scopeLevel + 1 ? list.get(scopeLevel) : null, e -> true);
}
final Iterable<V> iterable(Predicate<? super V> filter) {
return () -> new ScopeStackIterator<>(list -> list.get(list.size() - 1), filter);
}