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

Setting embedded Shape object to null doesn't work in 7.0.7 #152

Open
injecteer opened this issue Oct 17, 2020 · 0 comments
Open

Setting embedded Shape object to null doesn't work in 7.0.7 #152

injecteer opened this issue Oct 17, 2020 · 0 comments

Comments

@injecteer
Copy link

injecteer commented Oct 17, 2020

My domain classes are like:

@Entity
class Arbitrary {
  
  String id

  Map<String,Object> data
  
  Geometry geometry
    
  static embedded = [ 'data', 'geometry' ]
}

and

import grails.mongodb.geo.MultiPoint
@Entity
class Geometry {
  MultiPoint points
}

Setting the arbitrary.data = null in controller works just fine, but arbitrary.geometry = null is ignored.

In order to dance the problem around, I defined a fake constant and the checker method in Geometry class, like so:

class Geometry {
  ...
  static final KINDA_NULL = new Geometry( points:MultiPoint.valueOf( [ [ 0, 0 ] ] ) )
  
  boolean kindaNull() {
    points == KINDA_NULL.points
  }
}

and added the interceptor into Arbitrary class like so:

class Arbitrary {
  ...
  def afterUpdate() {
    if( geometry.kindaNull() )
      Arbitrary.collection.update( [ _id:getId() ], [ $unset:[ geometry:1 ] ] )
  }
}

Then it works kinda as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant