[#7968] Document behaviour of unnamed expressions in the SELECT clause

This commit is contained in:
lukaseder 2018-11-07 17:17:54 +01:00
parent e924faa75c
commit 9ce937f306
11 changed files with 546 additions and 62 deletions

View File

@ -6814,8 +6814,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -7309,9 +7326,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -9716,12 +9760,12 @@ from (
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -6990,8 +6990,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -7485,9 +7502,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -9956,12 +10000,12 @@ select substr('abcde', 2, 3) from dual;]]></text><html>
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -7075,8 +7075,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -7570,9 +7587,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -10083,12 +10127,12 @@ select substr('abcde', 2, 3) from dual;]]></text><html>
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>) (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -4193,8 +4193,25 @@ create.select().from(unnest(myTableFunction()).as("t", "a", "b"));
create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"));]]></java>
</content>
).as("t", "a", "b"));]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -4608,9 +4625,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">

View File

@ -4871,8 +4871,25 @@ create.select().from(unnest(myTableFunction()).as("t", "a", "b"));
create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"));]]></java>
</content>
).as("t", "a", "b"));]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -5286,9 +5303,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">

View File

@ -5751,8 +5751,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -6182,9 +6199,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -8314,12 +8358,12 @@ field("replace(substr(quote(zeroblob(({0} + 1) / 2)), 3, {0}), '0', {1})", Strin
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -6094,8 +6094,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -6566,9 +6583,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -8711,12 +8755,12 @@ field("replace(substr(quote(zeroblob(({0} + 1) / 2)), 3, {0}), '0', {1})", Strin
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -6212,8 +6212,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -6686,9 +6703,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -8877,12 +8921,12 @@ condition("my_column IN ({0})", list(a, b, c)); // Using a single template ar
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -6455,8 +6455,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -6950,9 +6967,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -9149,12 +9193,12 @@ condition("my_column IN ({0})", list(a, b, c)); // Using a single template ar
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -6631,8 +6631,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -7126,9 +7143,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -9373,12 +9417,12 @@ condition("my_column IN ({0})", list(a, b, c)); // Using a single template ar
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name

View File

@ -6766,8 +6766,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
.fetch();]]></java>
</content>
.fetch();]]></java><html>
<h3>Unnamed derived tables</h3>
<p>
The <reference class="org.jooq.Table"/> type can reference a <reference id="nested-selects" title="derived table"/>:
</p>
</html><code-pair>
<sql><![CDATA[-- Derived table
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Derived table
table(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
Most databases do not support unnamed derived tables, they require an explicit alias. If you do not provide jOOQ with such an explicit alias, an alias will be generated based on the derived table's content, to make sure the generated SQL will be syntactically correct. The generated alias is not specified and should not be referenced explicitly.
</p>
</html></content>
</section>
<section id="joined-tables">
@ -7261,9 +7278,36 @@ GROUP BY FIRST_NAME, LAST_NAME;</sql><html>
</p>
</html><java>System.out.println("Author : " + record.getValue("author"));
System.out.println("Books : " + record.getValue("books"));</java>
System.out.println("Books : " + record.getValue("books"));</java><html>
</content>
<h3>Unnamed column expressions</h3>
<p>
In most SQL databases, aliasing of column expressions in top level selects is optional. The database will generate a column name that is roughly based on the expression for documentation purposes (e.g. when running the query in a tool like SQL Developer), but applications cannot rely on the name explicitly. This is not a problem as columns can still be referenced by index.
</p>
<p>
In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
</p>
</html><code-pair>
<sql><![CDATA[-- Arithmetic expression
1 + 2
-- Correlated subquery
(SELECT 1 AS a)]]></sql>
<java><![CDATA[// Arithmetic expression
inline(1).plus(inline(2));
// Correlated subquery
field(select(inline(1).as("a")));]]></java>
</code-pair><html>
<p>
These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use <reference class="org.jooq.Field" anchor="#getName--" title="Field.getName()"/> to extract this column name from the field, when referencing the field or when nesting it in derived tables. In order to stay in full control of any such column names, it is always a good idea to provide explicit aliasing for column expressions, both in SQL as well as in jOOQ.
</p>
</html></content>
</section>
<section id="cast-expressions">
@ -9507,12 +9551,12 @@ condition("my_column IN ({0})", list(a, b, c)); // Using a single template ar
<ul>
<li>The permitted characters to be used in "unquoted" names</li>
<li>The permitted characters to be used in "quoted" names</li>
<li>The name quoting characters</li>
<li>The name quoting characters (e.g. <code>"double quotes"</code>, <code>`backticks`</code>, or <code>[brackets]</code>)</li>
<li>The standard case for case-insensitive ("unquoted") names</li>
</ul>
<p>
For the above reasons, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
For the above reasons, and also to prevent an additional SQL injection risk where names might contain SQL code, jOOQ by default quotes all names in generated SQL to be sure they match what is really contained in your database. This means that the following names will be rendered
</p>
</html><sql><![CDATA[-- Unquoted name