(Context<?> ctx)
| 108 | } |
| 109 | |
| 110 | private final QueryPart delegate(Context<?> ctx) { |
| 111 | if (array instanceof QOM.Array<T> a) { |
| 112 | switch (ctx.family()) { |
| 113 | |
| 114 | // [#869] Postgres supports this syntax natively |
| 115 | |
| 116 | |
| 117 | case POSTGRES: |
| 118 | case YUGABYTEDB: |
| 119 | return array; |
| 120 | |
| 121 | default: { |
| 122 | Select<Record1<T>> select = null; |
| 123 | |
| 124 | for (Field<T> value : a.$elements()) |
| 125 | if (select == null) |
| 126 | select = select(value); |
| 127 | else |
| 128 | select = select.unionAll(select(value)); |
| 129 | |
| 130 | return select; |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | else { |
| 135 | switch (ctx.family()) { |
| 136 | |
| 137 | // [#869] Postgres supports this syntax natively |
| 138 | |
| 139 | |
| 140 | case POSTGRES: |
| 141 | case YUGABYTEDB: |
| 142 | if (array instanceof Param && array.getDataType().getArrayBaseDataType().isEmbeddable()) |
| 143 | return paramToSelect((Param<? extends Object[]>) array); |
| 144 | else |
| 145 | return array; |
| 146 | |
| 147 | // [#869] H2 and HSQLDB can emulate this syntax by unnesting |
| 148 | // the array in a subselect |
| 149 | case H2: |
| 150 | case HSQLDB: |
| 151 | if (array instanceof Param && array.getDataType().getArrayBaseDataType().isEmbeddable()) |
| 152 | return paramToSelect((Param<? extends Object[]>) array); |
| 153 | else |
| 154 | return select().from(table(array)); |
| 155 | |
| 156 | // [#1048] All other dialects emulate unnesting of arrays using |
| 157 | // UNION ALL-connected subselects |
| 158 | default: { |
| 159 | |
| 160 | // The Informix database has an interesting bug when quantified comparison predicates |
| 161 | // use nested derived tables with UNION ALL |
| 162 | if (array instanceof Param) |
| 163 | return paramToSelect((Param<? extends Object[]>) array); |
| 164 | else |
| 165 | return select().from(table(array)); |
| 166 | } |
| 167 | } |
no test coverage detected