[ 
https://issues.apache.org/jira/browse/GROOVY-9159?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun updated GROOVY-9159:
-------------------------------
    Description: 
Reusing most of standard SQL syntax can make the learning curve smooth and 
avoid infringing the patent of Microsoft.
 _{color:#d04437}(Note: The syntax can be changed before introduction){color}_

All GINQ related keywords are uppercase to avoid breaking existing source code 
as possible as we can, e.g. {{FROM}}, {{WHERE}}, {{SELECT}}, etc.

Here are some examples to show the proposed syntax:
 *Filtering*
{code:java}
def numbers = [1, 2, 3]

def result =
        FROM numbers t       // t is an alias
        WHERE t.VALUE <= 2
        SELECT t.VALUE

assert [1, 2] == result
{code}
{code:java}
@groovy.transform.EqualsAndHashCode
class Person {
        String name
        int age
}

def persons = [new Person(name: 'Daniel', age: 35), new Person(name: 'Peter', 
age: 10), new Person(name: 'Alice', age: 22)]

def result =
        FROM persons p       // p is an alias
        WHERE p.age > 15 AND p.age <= 35
        SELECT p.name

assert ['Daniel', 'Alice'] == result

result =
        FROM persons p       // p is an alias
        WHERE p.age > 15 AND p.age <= 35
        SELECT p

assert [new Person(name: 'Daniel', age: 35), new Person(name: 'Alice', age: 
22)] == result
{code}
TBD EBNF

  was:
Reusing most of standard SQL syntax can make the learning curve smooth and 
avoid infringing the patent of Microsoft.
 _{color:#d04437}(Note: The syntax can be changed before introduction){color}_

All GINQ related keywords are uppercase to avoid breaking existing source code 
as possible as we can, e.g. {{FROM}}, {{WHERE}}, {{SELECT}}, etc.

Here are some examples to show the proposed syntax:
 *Filtering*
{code:java}
def numbers = [1, 2, 3]

def result =
        FROM numbers t       // t is an alias
        WHERE t.VALUE <= 2
        SELECT t.VALUE

assert [1, 2] == result
{code}
{code:java}
class Person {
        String name
        int age
}

def persons = [new Person(name: 'Daniel', age: 35), new Person(name: 'Peter', 
age: 10), new Person(name: 'Alice', age: 22)]

def result =
        FROM persons p       // p is an alias
        WHERE p.age > 15 AND p.age <= 35
        SELECT p.name

assert ['Daniel', 'Alice'] == result
{code}
TBD EBNF


> [GEP] Support LINQ, aka GINQ
> ----------------------------
>
>                 Key: GROOVY-9159
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9159
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Daniel Sun
>            Priority: Major
>             Fix For: 4.x
>
>
> Reusing most of standard SQL syntax can make the learning curve smooth and 
> avoid infringing the patent of Microsoft.
>  _{color:#d04437}(Note: The syntax can be changed before introduction){color}_
> All GINQ related keywords are uppercase to avoid breaking existing source 
> code as possible as we can, e.g. {{FROM}}, {{WHERE}}, {{SELECT}}, etc.
> Here are some examples to show the proposed syntax:
>  *Filtering*
> {code:java}
> def numbers = [1, 2, 3]
> def result =
>       FROM numbers t       // t is an alias
>       WHERE t.VALUE <= 2
>       SELECT t.VALUE
> assert [1, 2] == result
> {code}
> {code:java}
> @groovy.transform.EqualsAndHashCode
> class Person {
>       String name
>       int age
> }
> def persons = [new Person(name: 'Daniel', age: 35), new Person(name: 'Peter', 
> age: 10), new Person(name: 'Alice', age: 22)]
> def result =
>       FROM persons p       // p is an alias
>       WHERE p.age > 15 AND p.age <= 35
>       SELECT p.name
> assert ['Daniel', 'Alice'] == result
> result =
>       FROM persons p       // p is an alias
>       WHERE p.age > 15 AND p.age <= 35
>       SELECT p
> assert [new Person(name: 'Daniel', age: 35), new Person(name: 'Alice', age: 
> 22)] == result
> {code}
> TBD EBNF



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to