Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

609 projection issue #610

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.hibernate.criterion.Projections
import org.hibernate.type.StandardBasicTypes
import org.hibernate.type.Type
import spock.lang.Ignore
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 +88,51 @@ class OrgMangoProjectionTests extends Specification implements DomainIntTest {
sumbObj[0]['type'] == OrgType.Customer
}

void "test min projection"() {
setup:
def query = Org.query {
createAlias('calc', 'calc')
createAlias('contact', 'contact')
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")
}


@Issue("https://github.com/yakworks/gorm-tools/issues/609")
void "test min projection sep build"() {
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.groupBy("orgTypeId").min("calc.totalDue")

when:
def results = query.list()
Map row1 = results[0]

then:
results
row1 instanceof Map
row1.containsKey("orgTypeId")
row1.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
2 changes: 1 addition & 1 deletion rally-domain/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ logging:
# org.hibernate.orm.deprecation: INFO # turns on deprecation notices
# uncomment to turn on sql logging
# org.hibernate.stat: DEBUG
# org.hibernate.SQL: DEBUG
org.hibernate.SQL: DEBUG
# shows the sql parameters
# org.hibernate.type.descriptor.sql.BasicBinder: TRACE

Expand Down