id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,planetversion,pltversion
331,Struct creation failure leaves orphan document in collection,anonymous,jaymccarthy,"Consider following code and test case which is defined on a collection with a unique index constraint on global-unique-user-id. The code is designed to test that creation of a second user with same id will fail. The failure does occur, but the second record continues to exist with only the _id field present in it. This does not happen when I try the same test directly in mongo shell. 

(define-mongo-struct user ""users""
  ([global-unique-user-id #:required]
   [user-profile-data #:set-add #:push]
   [profiles #:set-add #:push]
   [default-profile #:set-add #:push]
   [app-specific-profiles #:set-add #:push]))

   (test-case
    ""Unique id creation""
    
    (define user?
      (λ (x)
         (and (mongo-dict? x)
              (not (bson-null? (mongo-dict-ref x 'global-unique-user-id))))))
    (define auth-handle?
      (λ (auth-handle)
         (and (equal? (authentication-handle-global-unique-user-id auth-handle) ""0000"")
              (equal? (authentication-handle-auth-handle-type auth-handle) ""pxSAN"")
              (equal? (authentication-handle-auth-handle auth-handle) ""me"")                           
              (equal? (authentication-handle-auth-credentials auth-handle) ""pwd""))))
    
    (let ((user (make-user #:global-unique-user-id ""0000"")))
      (check-pred user? user ""User 0000 Created"")
      (check-equal? (user-global-unique-user-id user) ""0000"")
      (check-exn exn:fail? (make-user #:global-unique-user-id ""0000""))
      (mongo-collection-remove! (mongo-collection (current-mongo-db) ""users"") '((global-unique-user-id . 1)))))",defect,closed,major,,jaymccarthy/mongodb.plt,invalid,,,(1 8),
