Skip to content

Commit

Permalink
#609 Add test to reveal projection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
snimavat committed Dec 23, 2022
1 parent 1aa9b7d commit 5c1a9fd
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.hibernate.criterion.Projections
import org.hibernate.type.StandardBasicTypes
import org.hibernate.type.Type
import spock.lang.Ignore
import spock.lang.IgnoreRest
import spock.lang.Issue
import spock.lang.Specification
import yakworks.testing.gorm.integration.DomainIntTest
import yakworks.rally.orgs.model.Org
Expand Down Expand Up @@ -87,6 +89,33 @@ class OrgMangoProjectionTests extends Specification implements DomainIntTest {
sumbObj[0]['type'] == OrgType.Customer
}

@Issue("https://github.com/yakworks/gorm-tools/issues/609")
void "test min projection"() {
setup:
def query = Org.query {
createAlias('calc', 'calc')
createAlias('contact', 'contact')
//putting projections here would pass.
}

//fails only when min used with groupBy in query.build {}
query = query.build {
projections {
groupBy("orgTypeId")
min("calc.totalDue") //this should result in a key calc_totalDue in the result map
}
}

when:
def results = query.list()

then:
results
results[0] instanceof Map
((Map)(results[0])).containsKey("calc_totalDue")
}


def "sum with projections key as string"() {
when: 'simulate what comes on url query string'
def qry = Org.query(projections: "'calc.totalDue':'sum', 'type':'group'", sort:'calc_totalDue:asc')
Expand Down

0 comments on commit 5c1a9fd

Please sign in to comment.