[jOOQ/jOOQ#10804] NullPointerException when calling MetaImpl.snapshot() on a PostgreSQL schema with function based indexes

This commit is contained in:
Lukas Eder 2021-01-20 09:37:58 +01:00
parent e23f6b2a43
commit 331bed7a19

View File

@ -207,7 +207,12 @@ final class Snapshot extends AbstractMeta {
for (int i = 0; i < indexFields.size(); i++) {
SortField<?> field = indexFields.get(i);
copiedFields[i] = field(field.getName()).sort(field.getOrder());
// [#10804] Use this table's field reference if possible.
// Otherwise (e.g. for function based indexes), use the actual field expression
Field<?> f = field(field.getName());
copiedFields[i] = f != null ? f.sort(field.getOrder()) : field;
// [#9009] TODO NULLS FIRST / NULLS LAST
}