Skip to content

Validators are not executed in unit test (String-based queries like [executeQuery] are currently not supported in this implementation of GORM) #10200

Closed

Description

@saw303

After upgrading to Grails 3.2 I found a problem with a unit test that uses in memory database support.

When I use the annotation TestFor the specified domain field validation are working as expected but the String-based queries are not supported.

java.lang.UnsupportedOperationException: String-based queries like [executeQuery] are currently not supported in this implementation of GORM. Use criteria instead.

    at org.grails.datastore.gorm.GormStaticApi.unsupported(GormStaticApi.groovy:1124)
    at org.grails.datastore.gorm.GormStaticApi.executeQuery(GormStaticApi.groovy:1028)
    at org.grails.datastore.gorm.GormStaticApi.executeQuery(GormStaticApi.groovy:1024)
    at org.grails.datastore.gorm.GormEntity$Trait$Helper.executeQuery(GormEntity.groovy:1030)
    at grails.issues.Season.between(Season.groovy:64)
    at grails.issues.SeasonSpec.Find all season between #aDate and #bDate(SeasonSpec.groovy:49)

If I remove the TestFor annotation the behaviour changes the other way around. Validation does not work but the String-based queries are supported.

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Check out example
  2. Run this test
  3. This test works as expected since it uses the TestFor annotation

Expected Behaviour

The validator should be called in a unit test in any case. With or without the using the TestFor annotation. executeQuery operations should be supported.

Actual Behaviour

If I remove the TestFor annotation the validator does not get called but executeString operations are supported.

Environment Information

  • Operating System: OSX 10.11.6
  • Grails Version: 3.2
  • JDK Version: 1.8.0_102

Example Application

Activity

  1. added this to the grails-3.2.1 milestone on Oct 4, 2016
  2. changed the title [-]Validators are not executed in unit test[/-] [+]Validators are not executed in unit test (String-based queries like [executeQuery] are currently not supported in this implementation of GORM)[/+] on Oct 4, 2016
  3. self-assigned this
    on Oct 4, 2016
  4. saw303 commented on Oct 19, 2016

    @saw303
    ContributorAuthor

    This one does not seems to be fixed in Grails 3.2.1. The following test still fails if you use @TestFor.

    Can someone reopen this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions