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 e2707d8 Tweak doco for GINQ
e2707d8 is described below
commit e2707d8d633873430227f36bba50de9834e3fbc7
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Jan 16 17:24:44 2021 +0800
Tweak doco for GINQ
---
.../groovy-ginq/src/spec/doc/ginq-userguide.adoc | 17 ++++++++++++-----
.../spec/test/org/apache/groovy/ginq/GinqTest.groovy | 15 +++++++++++++++
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
b/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
index f9863b0..a161b36 100644
--- a/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
+++ b/subprojects/groovy-ginq/src/spec/doc/ginq-userguide.adoc
@@ -677,17 +677,24 @@ GINQ could be used as list comprehension in the loops
directly:
include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_03,indent=0]
----
-==== Query JSON
+==== Query & Update
+This is like `update` statement in SQL
[source, groovy]
----
-include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_04,indent=0]
+include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_07,indent=0]
----
-==== Query & Update
-This is like `update` in SQL
+==== Alternative for `with` clause
+GINQ does not support `with` clause for now. We could define a temporary
variable to workaround:
[source, groovy]
----
-include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_07,indent=0]
+include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_12,indent=0]
+----
+
+==== Query JSON
+[source, groovy]
+----
+include::../test/org/apache/groovy/ginq/GinqTest.groovy[tags=ginq_tips_04,indent=0]
----
==== Parallel Querying
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 62f2f72..e634e28 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
@@ -3179,6 +3179,21 @@ class GinqTest {
}
@Test
+ void "testGinq - GINQ tips - 4"() {
+ assertGinqScript '''
+// tag::ginq_tips_12[]
+ def v = GQ { from n in [1, 2, 3] where n < 3 select n }
+ def result = GQ {
+ from n in v
+ where n > 1
+ select n
+ }
+ assert [2] == result.toList()
+// end::ginq_tips_12[]
+ '''
+ }
+
+ @Test
void "testGinq - GINQ examples - 1"() {
assertGinqScript '''
def expected =