This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 2c633eb40b329dfbb94cf0a1765dfb195ad3188f
Author: Daniel Sun <[email protected]>
AuthorDate: Fri Nov 27 12:36:29 2020 +0800

    Tweak doco
---
 subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc    |  9 +++++++--
 .../src/spec/test/org/apache/groovy/ginq/GinqTest.groovy    | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc 
b/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
index fad1ec0..fb5e0fc 100644
--- a/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
+++ b/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
@@ -120,11 +120,16 @@ 
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_datasource_04,
 The column names could be renamed with `as` clause:
 [source, groovy]
 ----
-include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_projection_01,indent=0]
+include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_projection_03,indent=0]
 ----
 [NOTE]
-The renamed column could be referenced by its new name, e.g. `v.powerOfN`
+The renamed column could be referenced by its new name, e.g. `r.powerOfN`.
+Also, it could be referenced by its index, e.g. `r[0]`
 
+[source, groovy]
+----
+include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_projection_01,indent=0]
+----
 
 Construct new objects as column values:
 
diff --git 
a/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy 
b/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy
index 04175de..e93987b 100644
--- 
a/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy
+++ 
b/subprojects/groovy-ginq/src/spec/test/org/apache/groovy/ginq/GinqTest.groovy
@@ -195,6 +195,19 @@ class GinqTest {
     }
 
     @Test
+    void "testGinq - from select - 11"() {
+        assertScript '''
+// tag::ginq_projection_03[]
+            def result = GQ {
+                from n in [1, 2, 3]
+                select Math.pow(n, 2) as powerOfN
+            }
+            assert [[1, 1], [4, 4], [9, 9]] == result.stream().map(r -> [r[0], 
r.powerOfN]).toList()
+// end::ginq_projection_03[]
+        '''
+    }
+
+    @Test
     void "testGinq - from where select - 1"() {
         assertScript '''
             def numbers = [0, 1, 2, 3, 4, 5]

Reply via email to