From 9ce937f3060463fafe5523007ee4168ef825d12c Mon Sep 17 00:00:00 2001
From: lukaseder
Date: Wed, 7 Nov 2018 17:17:54 +0100
Subject: [PATCH] [#7968] Document behaviour of unnamed expressions in the
SELECT clause
---
.../resources/org/jooq/web/manual-3.10.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.11.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.12.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.2.xml | 52 +++++++++++++++--
.../resources/org/jooq/web/manual-3.3.xml | 52 +++++++++++++++--
.../resources/org/jooq/web/manual-3.4.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.5.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.6.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.7.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.8.xml | 56 +++++++++++++++++--
.../resources/org/jooq/web/manual-3.9.xml | 56 +++++++++++++++++--
11 files changed, 546 insertions(+), 62 deletions(-)
diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml
index a5fa8ffd76..60efe895e4 100644
--- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml
+++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml
@@ -6814,8 +6814,25 @@ create.select().from(values(
row(1, 2),
row(3, 4)
).as("t", "a", "b"))
-.fetch();]]>
-
+.fetch();]]>
+
+ Unnamed derived tables
+
+
+ The type can reference a :
+
+
+
+
+
+
+
+
+ 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.
+
+
@@ -7309,9 +7326,36 @@ GROUP BY FIRST_NAME, LAST_NAME;
System.out.println("Author : " + record.getValue("author"));
-System.out.println("Books : " + record.getValue("books"));
+System.out.println("Books : " + record.getValue("books"));
-
+ Unnamed column expressions
+
+
+ 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.
+
+
+
+ In a similar fashion, jOOQ will assume an unspecified, generated column name for column expressions, based on their content.
+
+
+
+
+
+
+
+
+
+ These unnamed expressions can be used both in SQL as well as with jOOQ. However, do note that jOOQ will use 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.
+
+
@@ -9716,12 +9760,12 @@ from (
- The permitted characters to be used in "unquoted" names
- The permitted characters to be used in "quoted" names
- - The name quoting characters
+ - The name quoting characters (e.g.
"double quotes", `backticks`, or [brackets])
- The standard case for case-insensitive ("unquoted") names
- 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