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

DetachedCriteria.deleteAll() ignores criteria created via lazyWhere #1306

Closed
4 tasks done
douglyuckling opened this issue Apr 28, 2020 · 4 comments
Closed
4 tasks done
Assignees
Milestone

Comments

@douglyuckling
Copy link

douglyuckling commented Apr 28, 2020

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. Create a simple domain class that has at least one property, and create some data for it
  2. Create an instance of DetachedCriteria for the domain class via whereLazy() and specify some reasonable criteria
  3. Invoke deleteAll() on the criteria.

Expected Behaviour

Only the data matching the specified criteria is deleted.

Actual Behaviour

The specified criteria are ignored and all data for the domain class is deleted.

Environment Information

  • Operating System: MacOS 10.14.6 (18G4032)
  • GORM Version: 6.1.12.RELEASE and 7.0.4.RELEASE
  • Grails Version (if using Grails): 3.3.11 and 4.0.3
  • JDK Version: openjdk version "1.8.0_242"

Example Application

https://github.com/douglyuckling/gorm-lazy-criteria-bug

@puneetbehl puneetbehl self-assigned this Apr 28, 2020
@puneetbehl puneetbehl added this to the 7.0.5 milestone Apr 28, 2020
@puneetbehl
Copy link
Contributor

@douglyuckling I believe it should work when you use Product.where { color == givenColor }.deleteAll() instead of calling where { }.deleteAll()

@puneetbehl
Copy link
Contributor

Nvm, I just noticed that you already mentioned it on the repo README.

puneetbehl added a commit that referenced this issue Apr 29, 2020
Fixes issue where deleteAll and updateAll was not applying the whereLazy criteria.
@douglyuckling
Copy link
Author

Thanks, @puneetbehl! Any chance we could get this fixed on the 6.1.x branch, too? We're not quite ready to upgrade to 7.0.x yet, and in the meantime it would be easy for someone to forget to add the workaround mentioned above. 😬

puneetbehl added a commit that referenced this issue May 7, 2020
Fixes issue where deleteAll and updateAll was not applying the whereLazy criteria.
@puneetbehl
Copy link
Contributor

@douglyuckling It is done.

jhron pushed a commit to jhron/grails-data-mapping that referenced this issue May 13, 2021
Fixes issue where deleteAll and updateAll was not applying the whereLazy criteria.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants