[#3886] Add Field<Record[N]<T1, ..., T[N]>> DSL.field(Row[N]) to allow for nesting rows in SELECT clauses - Implementation draft

This commit is contained in:
Lukas Eder 2014-12-29 15:42:10 +01:00
parent b213c20b75
commit 2fc4b3e2c6
3 changed files with 370 additions and 2 deletions

View File

@ -6544,11 +6544,304 @@ public class DSL {
// XXX Global Field and Function factory
// -------------------------------------------------------------------------
/**
* Wrap a {@link SelectField} in a general-purpose {@link Field}
*/
@Support
public static <T> Field<T> field(SelectField<T> field) {
return field instanceof Field ? (Field<T>) field : field("{0}", field.getDataType(), field);
}
// [jooq-tools] START [row-field]
/**
* Turn a row value expression of degree <code>1</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1> Field<Record1<T1>> field(Row1<T1> row) {
return new RowField<Row1<T1>, Record1<T1>>(row);
}
/**
* Turn a row value expression of degree <code>2</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2> Field<Record2<T1, T2>> field(Row2<T1, T2> row) {
return new RowField<Row2<T1, T2>, Record2<T1, T2>>(row);
}
/**
* Turn a row value expression of degree <code>3</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3> Field<Record3<T1, T2, T3>> field(Row3<T1, T2, T3> row) {
return new RowField<Row3<T1, T2, T3>, Record3<T1, T2, T3>>(row);
}
/**
* Turn a row value expression of degree <code>4</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4> Field<Record4<T1, T2, T3, T4>> field(Row4<T1, T2, T3, T4> row) {
return new RowField<Row4<T1, T2, T3, T4>, Record4<T1, T2, T3, T4>>(row);
}
/**
* Turn a row value expression of degree <code>5</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5> Field<Record5<T1, T2, T3, T4, T5>> field(Row5<T1, T2, T3, T4, T5> row) {
return new RowField<Row5<T1, T2, T3, T4, T5>, Record5<T1, T2, T3, T4, T5>>(row);
}
/**
* Turn a row value expression of degree <code>6</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6> Field<Record6<T1, T2, T3, T4, T5, T6>> field(Row6<T1, T2, T3, T4, T5, T6> row) {
return new RowField<Row6<T1, T2, T3, T4, T5, T6>, Record6<T1, T2, T3, T4, T5, T6>>(row);
}
/**
* Turn a row value expression of degree <code>7</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7> Field<Record7<T1, T2, T3, T4, T5, T6, T7>> field(Row7<T1, T2, T3, T4, T5, T6, T7> row) {
return new RowField<Row7<T1, T2, T3, T4, T5, T6, T7>, Record7<T1, T2, T3, T4, T5, T6, T7>>(row);
}
/**
* Turn a row value expression of degree <code>8</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8> Field<Record8<T1, T2, T3, T4, T5, T6, T7, T8>> field(Row8<T1, T2, T3, T4, T5, T6, T7, T8> row) {
return new RowField<Row8<T1, T2, T3, T4, T5, T6, T7, T8>, Record8<T1, T2, T3, T4, T5, T6, T7, T8>>(row);
}
/**
* Turn a row value expression of degree <code>9</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9> Field<Record9<T1, T2, T3, T4, T5, T6, T7, T8, T9>> field(Row9<T1, T2, T3, T4, T5, T6, T7, T8, T9> row) {
return new RowField<Row9<T1, T2, T3, T4, T5, T6, T7, T8, T9>, Record9<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(row);
}
/**
* Turn a row value expression of degree <code>10</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Field<Record10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>> field(Row10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> row) {
return new RowField<Row10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, Record10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(row);
}
/**
* Turn a row value expression of degree <code>11</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Field<Record11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>> field(Row11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> row) {
return new RowField<Row11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>, Record11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(row);
}
/**
* Turn a row value expression of degree <code>12</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Field<Record12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>> field(Row12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> row) {
return new RowField<Row12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>, Record12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(row);
}
/**
* Turn a row value expression of degree <code>13</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Field<Record13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>> field(Row13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> row) {
return new RowField<Row13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>, Record13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>>(row);
}
/**
* Turn a row value expression of degree <code>14</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Field<Record14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>> field(Row14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> row) {
return new RowField<Row14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>, Record14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>>(row);
}
/**
* Turn a row value expression of degree <code>15</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Field<Record15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>> field(Row15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> row) {
return new RowField<Row15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>, Record15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>(row);
}
/**
* Turn a row value expression of degree <code>16</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Field<Record16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>> field(Row16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> row) {
return new RowField<Row16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>, Record16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>>(row);
}
/**
* Turn a row value expression of degree <code>17</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> Field<Record17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>> field(Row17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> row) {
return new RowField<Row17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>, Record17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17>>(row);
}
/**
* Turn a row value expression of degree <code>18</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> Field<Record18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>> field(Row18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18> row) {
return new RowField<Row18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>, Record18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18>>(row);
}
/**
* Turn a row value expression of degree <code>19</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> Field<Record19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>> field(Row19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19> row) {
return new RowField<Row19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>, Record19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>>(row);
}
/**
* Turn a row value expression of degree <code>20</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> Field<Record20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>> field(Row20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20> row) {
return new RowField<Row20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>, Record20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>>(row);
}
/**
* Turn a row value expression of degree <code>21</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> Field<Record21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>> field(Row21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21> row) {
return new RowField<Row21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>, Record21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>>(row);
}
/**
* Turn a row value expression of degree <code>22</code> into a {@code Field}.
* <p>
* Note: Not all databases support row value expressions, but many row value
* expression operations can be simulated on all databases. See relevant row
* value expression method Javadocs for details.
*/
@Generated("This method was generated using jOOQ-tools")
@Support({ POSTGRES })
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> Field<Record22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>> field(Row22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> row) {
return new RowField<Row22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>, Record22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>>(row);
}
// [jooq-tools] END [row-field]
/**
* Transform a subquery into a correlated subquery.
*/
@ -11511,7 +11804,7 @@ public class DSL {
return row(Utils.fields(values).toArray(new Field[0]));
}
// [jooq-tools] START [row-field]
// [jooq-tools] START [row-expression]
/**
* Create a row value expression of degree <code>1</code>.
@ -11799,7 +12092,7 @@ public class DSL {
return new RowImpl(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22);
}
// [jooq-tools] END [row-field]
// [jooq-tools] END [row-expression]
/**
* Create a row value expression of degree <code>N > 22</code>.

View File

@ -0,0 +1,70 @@
/**
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must
* choose jOOQ License
*
* For more information, please visit http://www.jooq.org/licenses
*
* Apache Software License 2.0:
* -----------------------------------------------------------------------------
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* jOOQ License and Maintenance Agreement:
* -----------------------------------------------------------------------------
* Data Geekery grants the Customer the non-exclusive, timely limited and
* non-transferable license to install and use the Software under the terms of
* the jOOQ License and Maintenance Agreement.
*
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
*/
package org.jooq.impl;
import org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Record;
import org.jooq.Row;
/**
* @author Lukas Eder
*/
class RowField<R1 extends Row, R2 extends Record> extends AbstractField<R2> {
/**
* Generated UID
*/
private static final long serialVersionUID = -2065258332642911588L;
private final R1 row;
RowField(R1 row) {
super("row", (DataType) SQLDataType.RECORD);
this.row = row;
}
@Override
public final void accept(Context<?> ctx) {
ctx.visit(row);
}
}

View File

@ -297,6 +297,11 @@ public final class SQLDataType {
*/
public static final DataType<Object> OTHER = new DefaultDataType<Object>(null, Object.class, "other");
/**
* The {@link Types#STRUCT} type.
*/
public static final DataType<Record> RECORD = new DefaultDataType<Record>(null, Record.class, "record");
/**
* The {@link ResultSet} type.
* <p>