MongoDB Plugin
  1. MongoDB Plugin
  2. GPMONGODB-15

GORM's .delete() ignores domains with identity of String type

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0-M5
    • Labels:
      None
    • Environment:
      Fedora linux, Mongodb 1.6.4, Grails 1.3.7, mongodb M4
    • Testcase included:
      yes

      Description

      If domain's id is of type String, delete doesn't work properly, it ignores String type and assumes it's ObjectId

      In both cases mongodb will execute (note _id is ObjectId):

      { "ts" : "Tue Feb 22 2011 23:28:26 GMT-0600 (CST)",
        "info" : "remove  query: { _id: ObjectId('4d649afa85632ecab2628ec2') }",
        "millis" : 0 }
      

      expected would be (for String version):

      { "ts" : "Tue Feb 22 2011 23:28:26 GMT-0600 (CST)",
        "info" : "remove  query: { _id: "4d649afa85632ecab2628ec2"}",
        "millis" : 0 }
      

      For example if we have these 2 domains:

      class Book {
         ObjectId id
         String title
      
         static constraints = { title blank:false }
      }
      
      class BookWithStringId {
         String id
         String title
      
         static constraints = { title blank:false }
      }
      
      def b = Book.get(id)
      b.delete() // works
      
      def b2 = BookWithStringId.get(id)
      b2.delete() // doesn't work
      

      Please see attached a sample project. With 1 integration test.

      PS: To see what mongodb does you may want to enable profiling (e.g. db.setProfilingLevel(2) )

        Activity

        Show
        Burt Beckwith added a comment - Fixed by https://github.com/SpringSource/spring-data-mapping/commit/cb6d667b1a36f51357f6688639b028b5361dce73

          People

          • Assignee:
            Burt Beckwith
            Reporter:
            Octavian Covalschi
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: