groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Sun (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8258) [GEP] Create a LINQ-like DSL
Date Sat, 10 Aug 2019 17:52:00 GMT

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

Daniel Sun updated GROOVY-8258:
-------------------------------
    Description: 
h2. *Ⅰ. Introduction*

GINQ DSL is an alternative solution of GINQ, it is a simplified version of GINQ(GROOVY-9159)
and will be implemented as a module "groovy-linq".

GINQ DSL is wrapped with:
{code:java}
ginq {
   // GINQ code
}
{code}
h2. *Ⅱ. Sample code related to GROOVY-9159*
h4. 1.1
{code:java}
from p of persons
where p.age > 15 && p.age <= 35
select p.name
{code}
h4. 1.2
{code:java}
from p of persons
where p.age > 15 && p.age <= 35
select p
{code}
h4. 1.3
{code:java}
from t of numbers 
where t <= 2
select t
{code}
h4. 2.1
{code:java}
from p of persons
innerjoin c of cities
on p.city.name == c.name
select p.name, c.name
{code}
h4. 2.2
{code:java}
from p of persons
from c of cities
where p.city.name == c.name
select p.name, c.name
{code}
h4. 2.3
{code:java}
from p of persons
from c of cities
where p.city == c
select p.name
{code}
h4. 2.4
{code:java}
from p of persons
leftjoin c of cities
on p.city.name == c.name //  same with left outer join
select p.name, c.name
{code}
h4. 2.5
{code:java}
from p of persons
rightjoin c of cities
on p.city.name == c.name //  same with right outer join
select p.name, c.name
{code}
h4. 3.1
{code:java}
from p of persons
select p.name
{code}
h4. 3.2
{code:java}
from p of persons
select p.name, p.age
{code}
h4. 3.3
{code:java}
from p of persons
select [name: p.name, age: p.age]
{code}
h4. 3.4
{code:java}
from p of persons
select new Person(name: p.name, age: p.age)
{code}
h4. 3.5
{code:java}
from p of persons
select p
{code}
h4. 4.1
{code:java}
from p of persons
groupby p.gender
select p.gender, max(p.age)
{code}
h4. 5.1
{code:java}
from p of persons
groupby p.gender
having p.gender == 'Male'
select p.gender, max(p.age)
{code}
h4. 6.1
{code:java}
from p of persons
orderby p.age
select p.name
{code}
h4. 6.2
{code:java}
from p of persons
orderby p.age desc
select p.name
{code}
h4. 7.1
{code:java}
from n of numbers
limit 2, 5
select n
{code}
h4. 7.2
{code:java}
from n of numbers
limit 5
select n
{code}
h4. 8.1
{code:java}
from v of (
    from n of numbers
    where n <= 5
    select n
)
limit 2, 5
select v
{code}
h4. 9.1
{code:java}
with v as (
    from n of numbers
    where n <= 5
    select n
)
from v
limit 2, 5
select v
{code}
h4. TODO

  was:
h2. *Ⅰ. Introduction*

GINQ DSL is an alternative solution of GINQ, it is a simplified version of GINQ(GROOVY-9159)
and will be implemented as a module "groovy-linq".

GINQ DSL is wrapped with:
{code:java}
ginq {
   // GINQ code
}
{code}
h2. *Ⅱ. Sample code related to GROOVY-9159*
h4. 1.1
{code:java}
from p of persons
where p.age > 15 && p.age <= 35
select p.name
{code}
h4. 1.2
{code:java}
from p of persons
where p.age > 15 && p.age <= 35
select p
{code}
h4. 1.3
{code:java}
from t of numbers 
where t <= 2
select t
{code}
h4. 2.1
{code:java}
from p of persons
innerjoin c of cities
on p.city.name == c.name
select p.name, c.name
{code}
h4. 2.2
{code:java}
from p of persons
from c of cities
where p.city.name == c.name
select p.name, c.name
{code}
h4. 2.3
{code:java}
from p of persons
from c of cities
where p.city == c
select p.name
{code}
h4. 2.4
{code:java}
from p of persons
leftjoin c of cities
on p.city.name == c.name //  same with left outer join
select p.name, c.name
{code}
h4. 2.5
{code:java}
from p of persons
rightjoin c of cities
on p.city.name == c.name //  same with right outer join
select p.name, c.name
{code}
h4. 3.1
{code:java}
from p of persons
select p.name
{code}
h4. 3.2
{code:java}
from p of persons
select p.name, p.age
{code}
h4. 3.3
{code:java}
from p of persons
select [name: p.name, age: p.age]
{code}
h4. 3.4
{code:java}
from p of persons
select new Person(name: p.name, age: p.age)
{code}
h4. 3.5
{code:java}
from p of persons
select p
{code}
h4. 4.1
{code:java}
from p of persons
groupby p.gender
select p.gender, max(p.age)
{code}
h4. 5.1
{code:java}
from p of persons
groupby p.gender
having p.gender == 'Male'
select p.gender, max(p.age)
{code}
h4. 6.1
{code:java}
from p of persons
orderby p.age
select p.name
{code}
h4. 6.2
{code:java}
from p of persons
orderby p.age desc
select p.name
{code}
h4. 7.1
{code:java}
from n of numbers
limit 2, 5
select n
{code}
h4. 7.2
{code:java}
from n of numbers
limit 5
select n
{code}
h4. TODO


> [GEP] Create a LINQ-like DSL
> ----------------------------
>
>                 Key: GROOVY-8258
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8258
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Daniel Sun
>            Priority: Major
>
> h2. *Ⅰ. Introduction*
> GINQ DSL is an alternative solution of GINQ, it is a simplified version of GINQ(GROOVY-9159)
and will be implemented as a module "groovy-linq".
> GINQ DSL is wrapped with:
> {code:java}
> ginq {
>    // GINQ code
> }
> {code}
> h2. *Ⅱ. Sample code related to GROOVY-9159*
> h4. 1.1
> {code:java}
> from p of persons
> where p.age > 15 && p.age <= 35
> select p.name
> {code}
> h4. 1.2
> {code:java}
> from p of persons
> where p.age > 15 && p.age <= 35
> select p
> {code}
> h4. 1.3
> {code:java}
> from t of numbers 
> where t <= 2
> select t
> {code}
> h4. 2.1
> {code:java}
> from p of persons
> innerjoin c of cities
> on p.city.name == c.name
> select p.name, c.name
> {code}
> h4. 2.2
> {code:java}
> from p of persons
> from c of cities
> where p.city.name == c.name
> select p.name, c.name
> {code}
> h4. 2.3
> {code:java}
> from p of persons
> from c of cities
> where p.city == c
> select p.name
> {code}
> h4. 2.4
> {code:java}
> from p of persons
> leftjoin c of cities
> on p.city.name == c.name //  same with left outer join
> select p.name, c.name
> {code}
> h4. 2.5
> {code:java}
> from p of persons
> rightjoin c of cities
> on p.city.name == c.name //  same with right outer join
> select p.name, c.name
> {code}
> h4. 3.1
> {code:java}
> from p of persons
> select p.name
> {code}
> h4. 3.2
> {code:java}
> from p of persons
> select p.name, p.age
> {code}
> h4. 3.3
> {code:java}
> from p of persons
> select [name: p.name, age: p.age]
> {code}
> h4. 3.4
> {code:java}
> from p of persons
> select new Person(name: p.name, age: p.age)
> {code}
> h4. 3.5
> {code:java}
> from p of persons
> select p
> {code}
> h4. 4.1
> {code:java}
> from p of persons
> groupby p.gender
> select p.gender, max(p.age)
> {code}
> h4. 5.1
> {code:java}
> from p of persons
> groupby p.gender
> having p.gender == 'Male'
> select p.gender, max(p.age)
> {code}
> h4. 6.1
> {code:java}
> from p of persons
> orderby p.age
> select p.name
> {code}
> h4. 6.2
> {code:java}
> from p of persons
> orderby p.age desc
> select p.name
> {code}
> h4. 7.1
> {code:java}
> from n of numbers
> limit 2, 5
> select n
> {code}
> h4. 7.2
> {code:java}
> from n of numbers
> limit 5
> select n
> {code}
> h4. 8.1
> {code:java}
> from v of (
>     from n of numbers
>     where n <= 5
>     select n
> )
> limit 2, 5
> select v
> {code}
> h4. 9.1
> {code:java}
> with v as (
>     from n of numbers
>     where n <= 5
>     select n
> )
> from v
> limit 2, 5
> select v
> {code}
> h4. TODO



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message