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


The following commit(s) were added to refs/heads/master by this push:
     new aba530e  Tweak GINQ user guide
aba530e is described below

commit aba530ea93c02063fac713dd177388d88ec156de
Author: Daniel Sun <[email protected]>
AuthorDate: Sun Jul 18 18:43:14 2021 +0800

    Tweak GINQ user guide
---
 subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc    |  9 ++++++++-
 .../src/spec/test/org/apache/groovy/ginq/GinqTest.groovy    | 13 +++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc 
b/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
index dc86bb5..7c19105 100644
--- a/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
+++ b/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
@@ -875,6 +875,13 @@ 
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_winfunction_38
 
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_05,indent=0]
 ----
 
+==== Distinct
+GINQ does not support `distinct` of SQL for now, but we could invoke 
`distinct()` method to workaround:
+[source, groovy]
+----
+include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_14,indent=0]
+----
+
 ==== List Comprehension
 
 List comprehension is an elegant way to define and create lists based on 
existing lists:
@@ -909,7 +916,7 @@ 
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_07,indent
 ----
 
 ==== Alternative for `with` clause
-GINQ does not support `with` clause for now. We could define a temporary 
variable to workaround:
+GINQ does not support `with` clause for now, but we could define a temporary 
variable to workaround:
 [source, groovy]
 ----
 
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_12,indent=0]
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 18182f1..91c0d21 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
@@ -222,6 +222,19 @@ class GinqTest {
     }
 
     @Test
+    void "testGinq - from select - 12"() {
+        assertGinqScript '''
+// tag::ginq_tips_14[]
+            def result = GQ {
+                from n in [1, 2, 2, 3, 3, 3]
+                select n
+            }.distinct()
+            assert [1, 2, 3] == result.toList()
+// end::ginq_tips_14[]
+        '''
+    }
+
+    @Test
     void "testGinq - from where select - 1"() {
         assertGinqScript '''
             def numbers = [0, 1, 2, 3, 4, 5]

Reply via email to