mongoid_rails4 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3213 -0
- data/LICENSE +20 -0
- data/README.md +62 -0
- data/Rakefile +35 -0
- data/lib/config/locales/en.yml +448 -0
- data/lib/mongoid.rb +104 -0
- data/lib/mongoid/atomic.rb +384 -0
- data/lib/mongoid/atomic/modifiers.rb +317 -0
- data/lib/mongoid/atomic/paths.rb +3 -0
- data/lib/mongoid/atomic/paths/embedded.rb +28 -0
- data/lib/mongoid/atomic/paths/embedded/many.rb +44 -0
- data/lib/mongoid/atomic/paths/embedded/one.rb +43 -0
- data/lib/mongoid/atomic/paths/root.rb +39 -0
- data/lib/mongoid/attributes.rb +284 -0
- data/lib/mongoid/attributes/dynamic.rb +154 -0
- data/lib/mongoid/attributes/nested.rb +82 -0
- data/lib/mongoid/attributes/processing.rb +147 -0
- data/lib/mongoid/attributes/readonly.rb +56 -0
- data/lib/mongoid/changeable.rb +379 -0
- data/lib/mongoid/composable.rb +104 -0
- data/lib/mongoid/config.rb +263 -0
- data/lib/mongoid/config/environment.rb +44 -0
- data/lib/mongoid/config/options.rb +74 -0
- data/lib/mongoid/config/validators.rb +3 -0
- data/lib/mongoid/config/validators/option.rb +25 -0
- data/lib/mongoid/config/validators/session.rb +140 -0
- data/lib/mongoid/contextual.rb +54 -0
- data/lib/mongoid/contextual/aggregable/memory.rb +109 -0
- data/lib/mongoid/contextual/aggregable/mongo.rb +147 -0
- data/lib/mongoid/contextual/atomic.rb +180 -0
- data/lib/mongoid/contextual/command.rb +61 -0
- data/lib/mongoid/contextual/eager.rb +158 -0
- data/lib/mongoid/contextual/find_and_modify.rb +69 -0
- data/lib/mongoid/contextual/geo_near.rb +238 -0
- data/lib/mongoid/contextual/map_reduce.rb +324 -0
- data/lib/mongoid/contextual/memory.rb +440 -0
- data/lib/mongoid/contextual/mongo.rb +676 -0
- data/lib/mongoid/contextual/queryable.rb +25 -0
- data/lib/mongoid/contextual/text_search.rb +180 -0
- data/lib/mongoid/copyable.rb +67 -0
- data/lib/mongoid/criteria.rb +562 -0
- data/lib/mongoid/criteria/findable.rb +179 -0
- data/lib/mongoid/criteria/inspectable.rb +25 -0
- data/lib/mongoid/criteria/marshalable.rb +50 -0
- data/lib/mongoid/criteria/modifiable.rb +189 -0
- data/lib/mongoid/criteria/scopable.rb +158 -0
- data/lib/mongoid/document.rb +361 -0
- data/lib/mongoid/equality.rb +66 -0
- data/lib/mongoid/errors.rb +40 -0
- data/lib/mongoid/errors/ambiguous_relationship.rb +51 -0
- data/lib/mongoid/errors/callback.rb +25 -0
- data/lib/mongoid/errors/delete_restriction.rb +29 -0
- data/lib/mongoid/errors/document_not_found.rb +111 -0
- data/lib/mongoid/errors/eager_load.rb +22 -0
- data/lib/mongoid/errors/invalid_collection.rb +18 -0
- data/lib/mongoid/errors/invalid_config_option.rb +27 -0
- data/lib/mongoid/errors/invalid_field.rb +64 -0
- data/lib/mongoid/errors/invalid_field_option.rb +35 -0
- data/lib/mongoid/errors/invalid_find.rb +19 -0
- data/lib/mongoid/errors/invalid_includes.rb +32 -0
- data/lib/mongoid/errors/invalid_index.rb +28 -0
- data/lib/mongoid/errors/invalid_options.rb +28 -0
- data/lib/mongoid/errors/invalid_path.rb +21 -0
- data/lib/mongoid/errors/invalid_scope.rb +24 -0
- data/lib/mongoid/errors/invalid_set_polymorphic_relation.rb +38 -0
- data/lib/mongoid/errors/invalid_storage_options.rb +27 -0
- data/lib/mongoid/errors/invalid_time.rb +22 -0
- data/lib/mongoid/errors/inverse_not_found.rb +29 -0
- data/lib/mongoid/errors/mixed_relations.rb +32 -0
- data/lib/mongoid/errors/mixed_session_configuration.rb +28 -0
- data/lib/mongoid/errors/mongoid_error.rb +92 -0
- data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +28 -0
- data/lib/mongoid/errors/no_default_session.rb +23 -0
- data/lib/mongoid/errors/no_environment.rb +19 -0
- data/lib/mongoid/errors/no_map_reduce_output.rb +24 -0
- data/lib/mongoid/errors/no_metadata.rb +21 -0
- data/lib/mongoid/errors/no_parent.rb +24 -0
- data/lib/mongoid/errors/no_session_config.rb +22 -0
- data/lib/mongoid/errors/no_session_database.rb +27 -0
- data/lib/mongoid/errors/no_session_hosts.rb +27 -0
- data/lib/mongoid/errors/no_sessions_config.rb +20 -0
- data/lib/mongoid/errors/readonly_attribute.rb +25 -0
- data/lib/mongoid/errors/scope_overwrite.rb +21 -0
- data/lib/mongoid/errors/too_many_nested_attribute_records.rb +20 -0
- data/lib/mongoid/errors/unknown_attribute.rb +25 -0
- data/lib/mongoid/errors/unsaved_document.rb +19 -0
- data/lib/mongoid/errors/unsupported_javascript.rb +27 -0
- data/lib/mongoid/errors/validations.rb +29 -0
- data/lib/mongoid/evolvable.rb +19 -0
- data/lib/mongoid/extensions.rb +35 -0
- data/lib/mongoid/extensions/array.rb +180 -0
- data/lib/mongoid/extensions/big_decimal.rb +69 -0
- data/lib/mongoid/extensions/boolean.rb +21 -0
- data/lib/mongoid/extensions/date.rb +77 -0
- data/lib/mongoid/extensions/date_time.rb +73 -0
- data/lib/mongoid/extensions/false_class.rb +38 -0
- data/lib/mongoid/extensions/float.rb +56 -0
- data/lib/mongoid/extensions/hash.rb +209 -0
- data/lib/mongoid/extensions/integer.rb +67 -0
- data/lib/mongoid/extensions/module.rb +28 -0
- data/lib/mongoid/extensions/nil_class.rb +33 -0
- data/lib/mongoid/extensions/object.rb +274 -0
- data/lib/mongoid/extensions/object_id.rb +54 -0
- data/lib/mongoid/extensions/range.rb +79 -0
- data/lib/mongoid/extensions/regexp.rb +27 -0
- data/lib/mongoid/extensions/set.rb +55 -0
- data/lib/mongoid/extensions/string.rb +199 -0
- data/lib/mongoid/extensions/symbol.rb +54 -0
- data/lib/mongoid/extensions/time.rb +88 -0
- data/lib/mongoid/extensions/time_with_zone.rb +56 -0
- data/lib/mongoid/extensions/true_class.rb +38 -0
- data/lib/mongoid/factory.rb +46 -0
- data/lib/mongoid/fields.rb +542 -0
- data/lib/mongoid/fields/foreign_key.rb +174 -0
- data/lib/mongoid/fields/localized.rb +73 -0
- data/lib/mongoid/fields/standard.rb +273 -0
- data/lib/mongoid/fields/validators.rb +2 -0
- data/lib/mongoid/fields/validators/macro.rb +92 -0
- data/lib/mongoid/findable.rb +133 -0
- data/lib/mongoid/identity_map.rb +163 -0
- data/lib/mongoid/indexable.rb +147 -0
- data/lib/mongoid/indexable/specification.rb +115 -0
- data/lib/mongoid/indexable/validators/options.rb +103 -0
- data/lib/mongoid/inspectable.rb +59 -0
- data/lib/mongoid/interceptable.rb +265 -0
- data/lib/mongoid/loggable.rb +69 -0
- data/lib/mongoid/matchable.rb +152 -0
- data/lib/mongoid/matchable/all.rb +27 -0
- data/lib/mongoid/matchable/and.rb +30 -0
- data/lib/mongoid/matchable/default.rb +72 -0
- data/lib/mongoid/matchable/exists.rb +23 -0
- data/lib/mongoid/matchable/gt.rb +21 -0
- data/lib/mongoid/matchable/gte.rb +21 -0
- data/lib/mongoid/matchable/in.rb +24 -0
- data/lib/mongoid/matchable/lt.rb +21 -0
- data/lib/mongoid/matchable/lte.rb +21 -0
- data/lib/mongoid/matchable/ne.rb +21 -0
- data/lib/mongoid/matchable/nin.rb +21 -0
- data/lib/mongoid/matchable/or.rb +33 -0
- data/lib/mongoid/matchable/size.rb +21 -0
- data/lib/mongoid/persistable.rb +207 -0
- data/lib/mongoid/persistable/creatable.rb +189 -0
- data/lib/mongoid/persistable/deletable.rb +149 -0
- data/lib/mongoid/persistable/destroyable.rb +55 -0
- data/lib/mongoid/persistable/incrementable.rb +36 -0
- data/lib/mongoid/persistable/logical.rb +38 -0
- data/lib/mongoid/persistable/poppable.rb +39 -0
- data/lib/mongoid/persistable/pullable.rb +55 -0
- data/lib/mongoid/persistable/pushable.rb +62 -0
- data/lib/mongoid/persistable/renamable.rb +35 -0
- data/lib/mongoid/persistable/savable.rb +52 -0
- data/lib/mongoid/persistable/settable.rb +33 -0
- data/lib/mongoid/persistable/unsettable.rb +36 -0
- data/lib/mongoid/persistable/updatable.rb +151 -0
- data/lib/mongoid/persistable/upsertable.rb +55 -0
- data/lib/mongoid/positional.rb +71 -0
- data/lib/mongoid/railtie.rb +156 -0
- data/lib/mongoid/railties/database.rake +97 -0
- data/lib/mongoid/railties/document.rb +12 -0
- data/lib/mongoid/relations.rb +162 -0
- data/lib/mongoid/relations/accessors.rb +299 -0
- data/lib/mongoid/relations/auto_save.rb +106 -0
- data/lib/mongoid/relations/binding.rb +218 -0
- data/lib/mongoid/relations/bindings.rb +9 -0
- data/lib/mongoid/relations/bindings/embedded/in.rb +63 -0
- data/lib/mongoid/relations/bindings/embedded/many.rb +50 -0
- data/lib/mongoid/relations/bindings/embedded/one.rb +55 -0
- data/lib/mongoid/relations/bindings/referenced/in.rb +65 -0
- data/lib/mongoid/relations/bindings/referenced/many.rb +42 -0
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +67 -0
- data/lib/mongoid/relations/bindings/referenced/one.rb +44 -0
- data/lib/mongoid/relations/builder.rb +57 -0
- data/lib/mongoid/relations/builders.rb +104 -0
- data/lib/mongoid/relations/builders/embedded/in.rb +29 -0
- data/lib/mongoid/relations/builders/embedded/many.rb +36 -0
- data/lib/mongoid/relations/builders/embedded/one.rb +30 -0
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +174 -0
- data/lib/mongoid/relations/builders/nested_attributes/one.rb +126 -0
- data/lib/mongoid/relations/builders/referenced/in.rb +26 -0
- data/lib/mongoid/relations/builders/referenced/many.rb +27 -0
- data/lib/mongoid/relations/builders/referenced/many_to_many.rb +40 -0
- data/lib/mongoid/relations/builders/referenced/one.rb +26 -0
- data/lib/mongoid/relations/cascading.rb +56 -0
- data/lib/mongoid/relations/cascading/delete.rb +44 -0
- data/lib/mongoid/relations/cascading/destroy.rb +43 -0
- data/lib/mongoid/relations/cascading/nullify.rb +35 -0
- data/lib/mongoid/relations/cascading/restrict.rb +39 -0
- data/lib/mongoid/relations/constraint.rb +49 -0
- data/lib/mongoid/relations/conversions.rb +34 -0
- data/lib/mongoid/relations/counter_cache.rb +105 -0
- data/lib/mongoid/relations/cyclic.rb +107 -0
- data/lib/mongoid/relations/embedded/batchable.rb +355 -0
- data/lib/mongoid/relations/embedded/in.rb +231 -0
- data/lib/mongoid/relations/embedded/many.rb +639 -0
- data/lib/mongoid/relations/embedded/one.rb +223 -0
- data/lib/mongoid/relations/macros.rb +356 -0
- data/lib/mongoid/relations/many.rb +208 -0
- data/lib/mongoid/relations/marshalable.rb +32 -0
- data/lib/mongoid/relations/metadata.rb +1174 -0
- data/lib/mongoid/relations/nested_builder.rb +74 -0
- data/lib/mongoid/relations/one.rb +48 -0
- data/lib/mongoid/relations/options.rb +48 -0
- data/lib/mongoid/relations/polymorphic.rb +39 -0
- data/lib/mongoid/relations/proxy.rb +270 -0
- data/lib/mongoid/relations/referenced/in.rb +297 -0
- data/lib/mongoid/relations/referenced/many.rb +787 -0
- data/lib/mongoid/relations/referenced/many_to_many.rb +486 -0
- data/lib/mongoid/relations/referenced/one.rb +290 -0
- data/lib/mongoid/relations/reflections.rb +62 -0
- data/lib/mongoid/relations/synchronization.rb +169 -0
- data/lib/mongoid/relations/targets.rb +2 -0
- data/lib/mongoid/relations/targets/enumerable.rb +473 -0
- data/lib/mongoid/relations/touchable.rb +94 -0
- data/lib/mongoid/reloadable.rb +95 -0
- data/lib/mongoid/scopable.rb +379 -0
- data/lib/mongoid/selectable.rb +59 -0
- data/lib/mongoid/serializable.rb +170 -0
- data/lib/mongoid/sessions.rb +330 -0
- data/lib/mongoid/sessions/factory.rb +129 -0
- data/lib/mongoid/sessions/mongo_uri.rb +93 -0
- data/lib/mongoid/sessions/options.rb +141 -0
- data/lib/mongoid/sessions/validators.rb +2 -0
- data/lib/mongoid/sessions/validators/storage.rb +49 -0
- data/lib/mongoid/shardable.rb +65 -0
- data/lib/mongoid/state.rb +97 -0
- data/lib/mongoid/threaded.rb +383 -0
- data/lib/mongoid/threaded/lifecycle.rb +164 -0
- data/lib/mongoid/timestamps.rb +15 -0
- data/lib/mongoid/timestamps/created.rb +30 -0
- data/lib/mongoid/timestamps/created/short.rb +19 -0
- data/lib/mongoid/timestamps/short.rb +10 -0
- data/lib/mongoid/timestamps/updated.rb +39 -0
- data/lib/mongoid/timestamps/updated/short.rb +19 -0
- data/lib/mongoid/traversable.rb +192 -0
- data/lib/mongoid/unit_of_work.rb +61 -0
- data/lib/mongoid/validatable.rb +180 -0
- data/lib/mongoid/validatable/associated.rb +48 -0
- data/lib/mongoid/validatable/format.rb +20 -0
- data/lib/mongoid/validatable/length.rb +20 -0
- data/lib/mongoid/validatable/localizable.rb +30 -0
- data/lib/mongoid/validatable/macros.rb +94 -0
- data/lib/mongoid/validatable/presence.rb +86 -0
- data/lib/mongoid/validatable/queryable.rb +30 -0
- data/lib/mongoid/validatable/uniqueness.rb +330 -0
- data/lib/mongoid/version.rb +4 -0
- data/lib/rack/mongoid.rb +2 -0
- data/lib/rack/mongoid/middleware/identity_map.rb +39 -0
- data/lib/rails/generators/mongoid/config/config_generator.rb +25 -0
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +76 -0
- data/lib/rails/generators/mongoid/model/model_generator.rb +25 -0
- data/lib/rails/generators/mongoid/model/templates/model.rb.tt +19 -0
- data/lib/rails/generators/mongoid/observer/observer_generator.rb +17 -0
- data/lib/rails/generators/mongoid/observer/templates/observer.rb.tt +4 -0
- data/lib/rails/generators/mongoid_generator.rb +65 -0
- data/lib/rails/mongoid.rb +180 -0
- data/lib/support/ruby_version.rb +26 -0
- data/spec/app/models/account.rb +28 -0
- data/spec/app/models/acolyte.rb +17 -0
- data/spec/app/models/actor.rb +18 -0
- data/spec/app/models/actress.rb +2 -0
- data/spec/app/models/address.rb +77 -0
- data/spec/app/models/address_component.rb +5 -0
- data/spec/app/models/address_number.rb +6 -0
- data/spec/app/models/agency.rb +5 -0
- data/spec/app/models/agent.rb +12 -0
- data/spec/app/models/album.rb +14 -0
- data/spec/app/models/alert.rb +5 -0
- data/spec/app/models/animal.rb +25 -0
- data/spec/app/models/answer.rb +4 -0
- data/spec/app/models/appointment.rb +7 -0
- data/spec/app/models/article.rb +10 -0
- data/spec/app/models/artist.rb +66 -0
- data/spec/app/models/artwork.rb +4 -0
- data/spec/app/models/audio.rb +5 -0
- data/spec/app/models/augmentation.rb +11 -0
- data/spec/app/models/author.rb +4 -0
- data/spec/app/models/band.rb +26 -0
- data/spec/app/models/bar.rb +10 -0
- data/spec/app/models/basic.rb +6 -0
- data/spec/app/models/bed.rb +1 -0
- data/spec/app/models/big_palette.rb +2 -0
- data/spec/app/models/birthday.rb +13 -0
- data/spec/app/models/book.rb +13 -0
- data/spec/app/models/breed.rb +4 -0
- data/spec/app/models/browser.rb +6 -0
- data/spec/app/models/building.rb +5 -0
- data/spec/app/models/building_address.rb +5 -0
- data/spec/app/models/bus.rb +7 -0
- data/spec/app/models/business.rb +5 -0
- data/spec/app/models/callback_recorder.rb +25 -0
- data/spec/app/models/callback_test.rb +9 -0
- data/spec/app/models/canvas.rb +25 -0
- data/spec/app/models/car.rb +1 -0
- data/spec/app/models/cat.rb +8 -0
- data/spec/app/models/category.rb +8 -0
- data/spec/app/models/child.rb +4 -0
- data/spec/app/models/child_doc.rb +22 -0
- data/spec/app/models/church.rb +4 -0
- data/spec/app/models/circle.rb +3 -0
- data/spec/app/models/circuit.rb +4 -0
- data/spec/app/models/circus.rb +7 -0
- data/spec/app/models/code.rb +5 -0
- data/spec/app/models/comment.rb +16 -0
- data/spec/app/models/contractor.rb +5 -0
- data/spec/app/models/cookie.rb +6 -0
- data/spec/app/models/country_code.rb +8 -0
- data/spec/app/models/definition.rb +7 -0
- data/spec/app/models/description.rb +11 -0
- data/spec/app/models/dictionary.rb +10 -0
- data/spec/app/models/division.rb +10 -0
- data/spec/app/models/doctor.rb +12 -0
- data/spec/app/models/dog.rb +7 -0
- data/spec/app/models/dokument.rb +5 -0
- data/spec/app/models/dragon.rb +4 -0
- data/spec/app/models/driver.rb +7 -0
- data/spec/app/models/drug.rb +6 -0
- data/spec/app/models/dungeon.rb +4 -0
- data/spec/app/models/email.rb +6 -0
- data/spec/app/models/employer.rb +5 -0
- data/spec/app/models/entry.rb +6 -0
- data/spec/app/models/eraser.rb +1 -0
- data/spec/app/models/event.rb +22 -0
- data/spec/app/models/exhibition.rb +4 -0
- data/spec/app/models/exhibitor.rb +5 -0
- data/spec/app/models/eye.rb +9 -0
- data/spec/app/models/eye_bowl.rb +9 -0
- data/spec/app/models/face.rb +8 -0
- data/spec/app/models/favorite.rb +6 -0
- data/spec/app/models/filesystem.rb +5 -0
- data/spec/app/models/fire_hydrant.rb +6 -0
- data/spec/app/models/firefox.rb +4 -0
- data/spec/app/models/fish.rb +7 -0
- data/spec/app/models/folder.rb +7 -0
- data/spec/app/models/folder_item.rb +9 -0
- data/spec/app/models/fruits.rb +28 -0
- data/spec/app/models/game.rb +19 -0
- data/spec/app/models/ghost.rb +7 -0
- data/spec/app/models/home.rb +4 -0
- data/spec/app/models/house.rb +6 -0
- data/spec/app/models/html_writer.rb +3 -0
- data/spec/app/models/image.rb +22 -0
- data/spec/app/models/implant.rb +16 -0
- data/spec/app/models/item.rb +8 -0
- data/spec/app/models/jar.rb +7 -0
- data/spec/app/models/label.rb +40 -0
- data/spec/app/models/language.rb +5 -0
- data/spec/app/models/lat_lng.rb +15 -0
- data/spec/app/models/league.rb +11 -0
- data/spec/app/models/learner.rb +2 -0
- data/spec/app/models/line_item.rb +6 -0
- data/spec/app/models/location.rb +8 -0
- data/spec/app/models/login.rb +8 -0
- data/spec/app/models/manufacturer.rb +7 -0
- data/spec/app/models/meat.rb +4 -0
- data/spec/app/models/membership.rb +4 -0
- data/spec/app/models/mixed_drink.rb +4 -0
- data/spec/app/models/movie.rb +13 -0
- data/spec/app/models/my_hash.rb +2 -0
- data/spec/app/models/name.rb +23 -0
- data/spec/app/models/node.rb +5 -0
- data/spec/app/models/note.rb +12 -0
- data/spec/app/models/ordered_post.rb +6 -0
- data/spec/app/models/ordered_preference.rb +6 -0
- data/spec/app/models/oscar.rb +15 -0
- data/spec/app/models/override.rb +16 -0
- data/spec/app/models/ownable.rb +6 -0
- data/spec/app/models/owner.rb +6 -0
- data/spec/app/models/pack.rb +3 -0
- data/spec/app/models/page.rb +5 -0
- data/spec/app/models/page_question.rb +4 -0
- data/spec/app/models/palette.rb +7 -0
- data/spec/app/models/parent.rb +5 -0
- data/spec/app/models/parent_doc.rb +6 -0
- data/spec/app/models/passport.rb +5 -0
- data/spec/app/models/patient.rb +9 -0
- data/spec/app/models/pdf_writer.rb +3 -0
- data/spec/app/models/pencil.rb +1 -0
- data/spec/app/models/person.rb +205 -0
- data/spec/app/models/pet.rb +23 -0
- data/spec/app/models/pet_owner.rb +6 -0
- data/spec/app/models/phone.rb +11 -0
- data/spec/app/models/pizza.rb +7 -0
- data/spec/app/models/player.rb +35 -0
- data/spec/app/models/post.rb +44 -0
- data/spec/app/models/powerup.rb +11 -0
- data/spec/app/models/preference.rb +9 -0
- data/spec/app/models/princess.rb +8 -0
- data/spec/app/models/product.rb +15 -0
- data/spec/app/models/profile.rb +5 -0
- data/spec/app/models/pronunciation.rb +5 -0
- data/spec/app/models/purchase.rb +4 -0
- data/spec/app/models/question.rb +8 -0
- data/spec/app/models/quiz.rb +7 -0
- data/spec/app/models/rating.rb +8 -0
- data/spec/app/models/record.rb +46 -0
- data/spec/app/models/registry.rb +4 -0
- data/spec/app/models/role.rb +7 -0
- data/spec/app/models/root_category.rb +4 -0
- data/spec/app/models/sandwich.rb +4 -0
- data/spec/app/models/scheduler.rb +7 -0
- data/spec/app/models/seo.rb +7 -0
- data/spec/app/models/series.rb +4 -0
- data/spec/app/models/server.rb +13 -0
- data/spec/app/models/service.rb +22 -0
- data/spec/app/models/shape.rb +12 -0
- data/spec/app/models/shelf.rb +5 -0
- data/spec/app/models/shipping_container.rb +5 -0
- data/spec/app/models/shipping_pack.rb +3 -0
- data/spec/app/models/shop.rb +6 -0
- data/spec/app/models/short_agent.rb +4 -0
- data/spec/app/models/short_quiz.rb +5 -0
- data/spec/app/models/slave.rb +6 -0
- data/spec/app/models/song.rb +8 -0
- data/spec/app/models/sound.rb +5 -0
- data/spec/app/models/square.rb +4 -0
- data/spec/app/models/strategy.rb +3 -0
- data/spec/app/models/sub_item.rb +3 -0
- data/spec/app/models/subscription.rb +4 -0
- data/spec/app/models/survey.rb +5 -0
- data/spec/app/models/symptom.rb +6 -0
- data/spec/app/models/tag.rb +8 -0
- data/spec/app/models/target.rb +5 -0
- data/spec/app/models/template.rb +5 -0
- data/spec/app/models/thing.rb +9 -0
- data/spec/app/models/title.rb +3 -0
- data/spec/app/models/tool.rb +8 -0
- data/spec/app/models/topping.rb +5 -0
- data/spec/app/models/track.rb +38 -0
- data/spec/app/models/translation.rb +5 -0
- data/spec/app/models/tree.rb +9 -0
- data/spec/app/models/truck.rb +3 -0
- data/spec/app/models/user.rb +21 -0
- data/spec/app/models/user_account.rb +10 -0
- data/spec/app/models/validation_callback.rb +10 -0
- data/spec/app/models/vehicle.rb +11 -0
- data/spec/app/models/version.rb +5 -0
- data/spec/app/models/vet_visit.rb +5 -0
- data/spec/app/models/video.rb +13 -0
- data/spec/app/models/weapon.rb +11 -0
- data/spec/app/models/wiki_page.rb +14 -0
- data/spec/app/models/word.rb +15 -0
- data/spec/app/models/word_origin.rb +11 -0
- data/spec/app/models/writer.rb +11 -0
- data/spec/config/mongoid.yml +38 -0
- data/spec/mongoid/atomic/modifiers_spec.rb +456 -0
- data/spec/mongoid/atomic/paths/embedded/many_spec.rb +118 -0
- data/spec/mongoid/atomic/paths/embedded/one_spec.rb +110 -0
- data/spec/mongoid/atomic/paths/root_spec.rb +48 -0
- data/spec/mongoid/atomic/paths_spec.rb +270 -0
- data/spec/mongoid/atomic_spec.rb +365 -0
- data/spec/mongoid/attributes/nested_spec.rb +4832 -0
- data/spec/mongoid/attributes/readonly_spec.rb +169 -0
- data/spec/mongoid/attributes_spec.rb +1412 -0
- data/spec/mongoid/changeable_spec.rb +1507 -0
- data/spec/mongoid/composable_spec.rb +24 -0
- data/spec/mongoid/config/environment_spec.rb +83 -0
- data/spec/mongoid/config/options_spec.rb +56 -0
- data/spec/mongoid/config_spec.rb +318 -0
- data/spec/mongoid/contextual/aggregable/memory_spec.rb +293 -0
- data/spec/mongoid/contextual/aggregable/mongo_spec.rb +455 -0
- data/spec/mongoid/contextual/atomic_spec.rb +529 -0
- data/spec/mongoid/contextual/find_and_modify_spec.rb +220 -0
- data/spec/mongoid/contextual/geo_near_spec.rb +405 -0
- data/spec/mongoid/contextual/map_reduce_spec.rb +464 -0
- data/spec/mongoid/contextual/memory_spec.rb +1236 -0
- data/spec/mongoid/contextual/mongo_spec.rb +1843 -0
- data/spec/mongoid/contextual/text_search_spec.rb +207 -0
- data/spec/mongoid/copyable_spec.rb +393 -0
- data/spec/mongoid/criteria/findable_spec.rb +1189 -0
- data/spec/mongoid/criteria/inspectable_spec.rb +27 -0
- data/spec/mongoid/criteria/marshalable_spec.rb +28 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +1063 -0
- data/spec/mongoid/criteria/scopable_spec.rb +391 -0
- data/spec/mongoid/criteria_spec.rb +3821 -0
- data/spec/mongoid/document_spec.rb +1205 -0
- data/spec/mongoid/equality_spec.rb +241 -0
- data/spec/mongoid/errors/ambiguous_relationship_spec.rb +29 -0
- data/spec/mongoid/errors/callback_spec.rb +29 -0
- data/spec/mongoid/errors/delete_restriction_spec.rb +29 -0
- data/spec/mongoid/errors/document_not_found_spec.rb +104 -0
- data/spec/mongoid/errors/eager_load_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_collection_spec.rb +36 -0
- data/spec/mongoid/errors/invalid_config_option_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_field_option_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_field_spec.rb +37 -0
- data/spec/mongoid/errors/invalid_find_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_includes_spec.rb +40 -0
- data/spec/mongoid/errors/invalid_index_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_options_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_path_spec.rb +23 -0
- data/spec/mongoid/errors/invalid_scope_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_set_polymorphic_relation_spec.rb +17 -0
- data/spec/mongoid/errors/invalid_storage_options_spec.rb +29 -0
- data/spec/mongoid/errors/invalid_time_spec.rb +29 -0
- data/spec/mongoid/errors/inverse_not_found_spec.rb +29 -0
- data/spec/mongoid/errors/mixed_relations_spec.rb +29 -0
- data/spec/mongoid/errors/mixed_session_configuration_spec.rb +29 -0
- data/spec/mongoid/errors/mongoid_error_spec.rb +48 -0
- data/spec/mongoid/errors/nested_attributes_metadata_not_found_spec.rb +29 -0
- data/spec/mongoid/errors/no_environment_spec.rb +29 -0
- data/spec/mongoid/errors/no_map_reduce_output_spec.rb +29 -0
- data/spec/mongoid/errors/no_metadata_spec.rb +23 -0
- data/spec/mongoid/errors/no_parent_spec.rb +29 -0
- data/spec/mongoid/errors/no_session_config_spec.rb +29 -0
- data/spec/mongoid/errors/no_session_database_spec.rb +29 -0
- data/spec/mongoid/errors/no_session_hosts_spec.rb +29 -0
- data/spec/mongoid/errors/no_sessions_config_spec.rb +29 -0
- data/spec/mongoid/errors/readonly_attribute_spec.rb +29 -0
- data/spec/mongoid/errors/scope_overwrite_spec.rb +29 -0
- data/spec/mongoid/errors/too_many_nested_attribute_records_spec.rb +29 -0
- data/spec/mongoid/errors/unknown_attribute_spec.rb +29 -0
- data/spec/mongoid/errors/unsaved_document_spec.rb +37 -0
- data/spec/mongoid/errors/unsupported_javascript_spec.rb +29 -0
- data/spec/mongoid/errors/validations_spec.rb +45 -0
- data/spec/mongoid/extensions/array_spec.rb +638 -0
- data/spec/mongoid/extensions/big_decimal_spec.rb +104 -0
- data/spec/mongoid/extensions/binary_spec.rb +60 -0
- data/spec/mongoid/extensions/boolean_spec.rb +135 -0
- data/spec/mongoid/extensions/date_spec.rb +235 -0
- data/spec/mongoid/extensions/date_time_spec.rb +155 -0
- data/spec/mongoid/extensions/false_class_spec.rb +42 -0
- data/spec/mongoid/extensions/float_spec.rb +133 -0
- data/spec/mongoid/extensions/hash_spec.rb +333 -0
- data/spec/mongoid/extensions/integer_spec.rb +136 -0
- data/spec/mongoid/extensions/module_spec.rb +42 -0
- data/spec/mongoid/extensions/nil_class_spec.rb +11 -0
- data/spec/mongoid/extensions/object_id_spec.rb +946 -0
- data/spec/mongoid/extensions/object_spec.rb +292 -0
- data/spec/mongoid/extensions/range_spec.rb +105 -0
- data/spec/mongoid/extensions/regexp_spec.rb +47 -0
- data/spec/mongoid/extensions/set_spec.rb +33 -0
- data/spec/mongoid/extensions/string_spec.rb +357 -0
- data/spec/mongoid/extensions/symbol_spec.rb +76 -0
- data/spec/mongoid/extensions/time_spec.rb +467 -0
- data/spec/mongoid/extensions/time_with_zone_spec.rb +405 -0
- data/spec/mongoid/extensions/true_class_spec.rb +42 -0
- data/spec/mongoid/extensions_spec.rb +15 -0
- data/spec/mongoid/factory_spec.rb +185 -0
- data/spec/mongoid/fields/foreign_key_spec.rb +694 -0
- data/spec/mongoid/fields/internal/foreign_keys/array_spec.rb +184 -0
- data/spec/mongoid/fields/internal/foreign_keys/object_spec.rb +201 -0
- data/spec/mongoid/fields/localized_spec.rb +386 -0
- data/spec/mongoid/fields/standard_spec.rb +166 -0
- data/spec/mongoid/fields_spec.rb +1229 -0
- data/spec/mongoid/findable_spec.rb +342 -0
- data/spec/mongoid/identity_map_spec.rb +564 -0
- data/spec/mongoid/indexable/specification_spec.rb +87 -0
- data/spec/mongoid/indexable_spec.rb +504 -0
- data/spec/mongoid/inspectable_spec.rb +49 -0
- data/spec/mongoid/interceptable_spec.rb +1564 -0
- data/spec/mongoid/loggable_spec.rb +21 -0
- data/spec/mongoid/matchable/all_spec.rb +31 -0
- data/spec/mongoid/matchable/and_spec.rb +162 -0
- data/spec/mongoid/matchable/default_spec.rb +130 -0
- data/spec/mongoid/matchable/exists_spec.rb +57 -0
- data/spec/mongoid/matchable/gt_spec.rb +75 -0
- data/spec/mongoid/matchable/gte_spec.rb +74 -0
- data/spec/mongoid/matchable/in_spec.rb +25 -0
- data/spec/mongoid/matchable/lt_spec.rb +74 -0
- data/spec/mongoid/matchable/lte_spec.rb +74 -0
- data/spec/mongoid/matchable/ne_spec.rb +25 -0
- data/spec/mongoid/matchable/nin_spec.rb +25 -0
- data/spec/mongoid/matchable/or_spec.rb +106 -0
- data/spec/mongoid/matchable/size_spec.rb +25 -0
- data/spec/mongoid/matchable_spec.rb +532 -0
- data/spec/mongoid/persistable/creatable_spec.rb +512 -0
- data/spec/mongoid/persistable/deletable_spec.rb +205 -0
- data/spec/mongoid/persistable/destroyable_spec.rb +148 -0
- data/spec/mongoid/persistable/incrementable_spec.rb +173 -0
- data/spec/mongoid/persistable/logical_spec.rb +143 -0
- data/spec/mongoid/persistable/poppable_spec.rb +115 -0
- data/spec/mongoid/persistable/pullable_spec.rb +228 -0
- data/spec/mongoid/persistable/pushable_spec.rb +258 -0
- data/spec/mongoid/persistable/renamable_spec.rb +135 -0
- data/spec/mongoid/persistable/savable_spec.rb +432 -0
- data/spec/mongoid/persistable/settable_spec.rb +139 -0
- data/spec/mongoid/persistable/unsettable_spec.rb +155 -0
- data/spec/mongoid/persistable/updatable_spec.rb +522 -0
- data/spec/mongoid/persistable/upsertable_spec.rb +106 -0
- data/spec/mongoid/persistable_spec.rb +206 -0
- data/spec/mongoid/positional_spec.rb +227 -0
- data/spec/mongoid/railties/document_spec.rb +24 -0
- data/spec/mongoid/relations/accessors_spec.rb +736 -0
- data/spec/mongoid/relations/auto_save_spec.rb +261 -0
- data/spec/mongoid/relations/bindings/embedded/in_spec.rb +171 -0
- data/spec/mongoid/relations/bindings/embedded/many_spec.rb +54 -0
- data/spec/mongoid/relations/bindings/embedded/one_spec.rb +77 -0
- data/spec/mongoid/relations/bindings/referenced/in_spec.rb +241 -0
- data/spec/mongoid/relations/bindings/referenced/many_spec.rb +153 -0
- data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +178 -0
- data/spec/mongoid/relations/bindings/referenced/one_spec.rb +131 -0
- data/spec/mongoid/relations/builders/embedded/in_spec.rb +34 -0
- data/spec/mongoid/relations/builders/embedded/many_spec.rb +132 -0
- data/spec/mongoid/relations/builders/embedded/one_spec.rb +99 -0
- data/spec/mongoid/relations/builders/nested_attributes/many_spec.rb +234 -0
- data/spec/mongoid/relations/builders/nested_attributes/one_spec.rb +250 -0
- data/spec/mongoid/relations/builders/referenced/in_spec.rb +241 -0
- data/spec/mongoid/relations/builders/referenced/many_spec.rb +137 -0
- data/spec/mongoid/relations/builders/referenced/many_to_many_spec.rb +178 -0
- data/spec/mongoid/relations/builders/referenced/one_spec.rb +124 -0
- data/spec/mongoid/relations/builders_spec.rb +226 -0
- data/spec/mongoid/relations/cascading/delete_spec.rb +101 -0
- data/spec/mongoid/relations/cascading/destroy_spec.rb +47 -0
- data/spec/mongoid/relations/cascading/nullify_spec.rb +32 -0
- data/spec/mongoid/relations/cascading/restrict_spec.rb +68 -0
- data/spec/mongoid/relations/cascading_spec.rb +355 -0
- data/spec/mongoid/relations/constraint_spec.rb +74 -0
- data/spec/mongoid/relations/conversions_spec.rb +126 -0
- data/spec/mongoid/relations/counter_cache_spec.rb +205 -0
- data/spec/mongoid/relations/cyclic_spec.rb +156 -0
- data/spec/mongoid/relations/embedded/dirty_spec.rb +65 -0
- data/spec/mongoid/relations/embedded/in_spec.rb +579 -0
- data/spec/mongoid/relations/embedded/many_spec.rb +3781 -0
- data/spec/mongoid/relations/embedded/one_spec.rb +1014 -0
- data/spec/mongoid/relations/macros_spec.rb +613 -0
- data/spec/mongoid/relations/metadata_spec.rb +1917 -0
- data/spec/mongoid/relations/options_spec.rb +35 -0
- data/spec/mongoid/relations/polymorphic_spec.rb +128 -0
- data/spec/mongoid/relations/proxy_spec.rb +48 -0
- data/spec/mongoid/relations/referenced/in_spec.rb +1435 -0
- data/spec/mongoid/relations/referenced/many_spec.rb +3546 -0
- data/spec/mongoid/relations/referenced/many_to_many_spec.rb +3556 -0
- data/spec/mongoid/relations/referenced/one_spec.rb +1289 -0
- data/spec/mongoid/relations/reflections_spec.rb +101 -0
- data/spec/mongoid/relations/synchronization_spec.rb +449 -0
- data/spec/mongoid/relations/targets/enumerable_spec.rb +1710 -0
- data/spec/mongoid/relations/touchable_spec.rb +296 -0
- data/spec/mongoid/relations_spec.rb +188 -0
- data/spec/mongoid/reloadable_spec.rb +305 -0
- data/spec/mongoid/scopable_spec.rb +926 -0
- data/spec/mongoid/selectable_spec.rb +134 -0
- data/spec/mongoid/serializable_spec.rb +862 -0
- data/spec/mongoid/sessions/factory_spec.rb +312 -0
- data/spec/mongoid/sessions/mongo_uri_spec.rb +103 -0
- data/spec/mongoid/sessions/options_spec.rb +71 -0
- data/spec/mongoid/sessions_spec.rb +1078 -0
- data/spec/mongoid/shardable_spec.rb +61 -0
- data/spec/mongoid/state_spec.rb +102 -0
- data/spec/mongoid/threaded_spec.rb +258 -0
- data/spec/mongoid/timestamps/created/short_spec.rb +51 -0
- data/spec/mongoid/timestamps/created_spec.rb +44 -0
- data/spec/mongoid/timestamps/updated/short_spec.rb +90 -0
- data/spec/mongoid/timestamps/updated_spec.rb +86 -0
- data/spec/mongoid/timestamps_spec.rb +112 -0
- data/spec/mongoid/traversable_spec.rb +244 -0
- data/spec/mongoid/unit_of_work_spec.rb +196 -0
- data/spec/mongoid/validatable/associated_spec.rb +183 -0
- data/spec/mongoid/validatable/format_spec.rb +83 -0
- data/spec/mongoid/validatable/length_spec.rb +119 -0
- data/spec/mongoid/validatable/numericality_spec.rb +30 -0
- data/spec/mongoid/validatable/presence_spec.rb +511 -0
- data/spec/mongoid/validatable/uniqueness_spec.rb +2305 -0
- data/spec/mongoid/validatable_spec.rb +309 -0
- data/spec/mongoid_spec.rb +74 -0
- data/spec/rack/mongoid/middleware/identity_map_spec.rb +72 -0
- data/spec/rails/mongoid_spec.rb +462 -0
- data/spec/spec_helper.rb +103 -0
- metadata +1159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4809a1b2bdf5f5e69a73854cfa14834956b5eeac
|
4
|
+
data.tar.gz: 6e9d8327675fa9471be8011803cb6c4954085d4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1307171863ec4e1290d5a0cae3fef3d1c1a9d12ed3e6738ae818d6e095adab1abb4a3b2d1f2c27d1ad615428b5ec53cef46e1e489f719a7a95ced55904606fc4
|
7
|
+
data.tar.gz: 49db6dcbd5dc6327a540b3389343e50f6d7850b9bc79a1a5141250e95788e0652bc8701a4152013bc00f2530a1a2099bd9ca9b82e02928ce94e5db0fd9afabe1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,3213 @@
|
|
1
|
+
# Overview
|
2
|
+
|
3
|
+
For instructions on upgrading to newer versions, visit
|
4
|
+
[mongoid.org](http://mongoid.org/en/mongoid/docs/upgrading.html).
|
5
|
+
|
6
|
+
## 4.0.0
|
7
|
+
|
8
|
+
### Major Changes (Backwards Incompatible)
|
9
|
+
|
10
|
+
* Mongoid now requires Active Model 4 or higher.
|
11
|
+
|
12
|
+
* `Document#set` now accepts multiple attributes in the form of a hash,
|
13
|
+
instead of the previous `(field, value)` args. Field aliases and typecasting
|
14
|
+
are also now supported in this operation.
|
15
|
+
|
16
|
+
document.set(name: "Photek", likes: 10000)
|
17
|
+
|
18
|
+
* `Document#rename` now accepts multiple attributes in the form of a hash,
|
19
|
+
instead of the previous `(field, value)` args. Field aliases are supported.
|
20
|
+
|
21
|
+
document.rename(first_name: "fn", last_name: "ln")
|
22
|
+
|
23
|
+
* `Document#inc` now accepts multiple attributes in the form of a hash, instead
|
24
|
+
of previously only being able to increment one value at a time. Aliases and
|
25
|
+
serialization is supported.
|
26
|
+
|
27
|
+
document.inc(score: 10, place: -1, lives: -10)
|
28
|
+
|
29
|
+
* `Document#pop` now accepts multiple attributes in the form of a hash, instead
|
30
|
+
of previously only being able to pop one value at a time. Aliases and
|
31
|
+
serialization is supported.
|
32
|
+
|
33
|
+
document.pop(names: 1, aliases: -1)
|
34
|
+
|
35
|
+
* `Document#bit` now accepts multiple attributes in the form of a hash, instead
|
36
|
+
of previously only being able to apply one set of operations at a time.
|
37
|
+
Aliases and serialization are supported.
|
38
|
+
|
39
|
+
document.bit(age: { and: 13 }, score: { or: 13 })
|
40
|
+
|
41
|
+
* `Document#pull` now accepts multiple attributes in the form of a hash, instead
|
42
|
+
of previously only being able to pull one value at a time. Aliases and
|
43
|
+
serialization is supported.
|
44
|
+
|
45
|
+
document.pull(names: "James", aliases: "007")
|
46
|
+
|
47
|
+
* `Document#pull_all` now accepts multiple attributes in the form of a hash,
|
48
|
+
instead of previously only being able to pull one value at a time. Aliases and
|
49
|
+
serialization is supported.
|
50
|
+
|
51
|
+
document.pull_all(names: ["James", "Bond"], aliases: ["007"])
|
52
|
+
|
53
|
+
* `Document#push_all` has been removed since it was deprecated in MongoDB 2.4.
|
54
|
+
Use `Document.push` instead.
|
55
|
+
|
56
|
+
* `Document#push` now accepts multiple attributes in the form of a hash, and
|
57
|
+
can handle the pushing of single values or multiple values to the field via
|
58
|
+
$push with $each. Aliases and serialization is supported.
|
59
|
+
|
60
|
+
document.push(names: "James", aliases: [ "007", "Jim" ])
|
61
|
+
|
62
|
+
* `Document#add_to_set` now accepts multiple attributes in the form of a hash,
|
63
|
+
and now aliases and serialization are supported.
|
64
|
+
|
65
|
+
document.add_to_set(names: "James", aliases: "007")
|
66
|
+
|
67
|
+
* Criteria atomic operations API is now changed to match the changes in the
|
68
|
+
single document atomic API, for example:
|
69
|
+
|
70
|
+
Band.where(name: "Depeche Mode").inc(likes: 10, followers: 20)
|
71
|
+
|
72
|
+
* \#3138 `update_attributes` can now be accessed simply by calling `update`.
|
73
|
+
|
74
|
+
* \#3083 A new rake task: `rake mongoid:remove_undefined_indexes` has been added to
|
75
|
+
remove indexes from the database that are not explicitly defined in the models.
|
76
|
+
(Aidan Feldman)
|
77
|
+
|
78
|
+
* \#3029 The `relation_field` field that is added for a single use case with polymorphic
|
79
|
+
relations has been removed. So where the following would work before:
|
80
|
+
|
81
|
+
class Eye
|
82
|
+
include Mongoid::Document
|
83
|
+
belongs_to :eyeable, polymorphic: true
|
84
|
+
end
|
85
|
+
|
86
|
+
class Face
|
87
|
+
include Mongoid::Document
|
88
|
+
has_one :left_eye, class_name: "Eye", as: :eyeable
|
89
|
+
has_one :right_eye, class_name: "Eye", as: :eyeable
|
90
|
+
end
|
91
|
+
|
92
|
+
This would now need to be modeled as (with the appropriate migration):
|
93
|
+
|
94
|
+
class Eye
|
95
|
+
include Mongoid::Document
|
96
|
+
belongs_to :left_socket, class_name: "Face", inverse_of: :left_eye
|
97
|
+
belongs_to :right_socket, class_name: "Face", inverse_of: :right_eye
|
98
|
+
end
|
99
|
+
|
100
|
+
class Face
|
101
|
+
include Mongoid::Document
|
102
|
+
has_one :left_eye, class_name: "Eye", inverse_of: :left_socket
|
103
|
+
has_one :right_eye, class_name: "Eye", inverse_of: :right_socket
|
104
|
+
end
|
105
|
+
|
106
|
+
* \#3075 `update_attribute` now properly calls the setter method instead of
|
107
|
+
using `write_attribute`.
|
108
|
+
|
109
|
+
* \#3060 Allow atomically blocks to allow multiple calls of the same type.
|
110
|
+
(Brian Norton)
|
111
|
+
|
112
|
+
* \#3037 Model indexes are no longer stored in an `index_options` hash on the
|
113
|
+
model class. Instead, an array named `index_specifications` now exists on the
|
114
|
+
class which contains a list of `Indexable::Specification` objects. This is so
|
115
|
+
we could properly handle the case of indexes with the same keys but different
|
116
|
+
order.
|
117
|
+
|
118
|
+
* \#2991 The `timeless` feature has been removed, due to the fact with the current
|
119
|
+
overall design of Mongoid it would never be thread safe when accessed from the
|
120
|
+
class level, and has too many edge cases. Active Record's implementation of this
|
121
|
+
feature also suffers the same faults.
|
122
|
+
|
123
|
+
* \#2956 Caching on queries now only happens when `cache` is specifically
|
124
|
+
called. (Arthur Neves)
|
125
|
+
|
126
|
+
* \#2898 Dirty attribute methods now properly handle field aliases.
|
127
|
+
(Niels Ganser)
|
128
|
+
|
129
|
+
* \#2659 `Mongoid::Railtie` now properly uses only one initializer and
|
130
|
+
the name has changed to `mongoid.load-config`.
|
131
|
+
|
132
|
+
* \#2656 `rake db:reseed` is now `rake db:reset` (Arthur Neves)
|
133
|
+
|
134
|
+
* \#2648 `Boolean` becomes `Mongoid::Boolean` to avoid polluting the global
|
135
|
+
namespace with a commonly used class by other libraries.
|
136
|
+
|
137
|
+
* \#2603 Return values from setters are now always the set value, regardless
|
138
|
+
of calling the setter or using send.
|
139
|
+
|
140
|
+
* \#2563 The `allow_dynamic_fields` configuration option has been removed as
|
141
|
+
dynamic fields are now allowed on a per-model level. In order to allow a
|
142
|
+
model to use dynamic fields, simply include the module in each.
|
143
|
+
(Josh Martin)
|
144
|
+
|
145
|
+
class Band
|
146
|
+
include Mongoid::Document
|
147
|
+
include Mongoid::Attributes::Dynamic
|
148
|
+
end
|
149
|
+
|
150
|
+
* \#2497 Calling `to_json` no longer tampers with the return value from the
|
151
|
+
driver, and proper returns `{ "$oid" : object_id.to_s }` instead of just
|
152
|
+
the string representation previously.
|
153
|
+
|
154
|
+
* \#2433 `Mongoid::Paranoia` has been removed.
|
155
|
+
|
156
|
+
* \#2432 `Mongoid::Versioning` has been removed.
|
157
|
+
|
158
|
+
* \#2218 Creating or instantiating documents that have default scopes will now
|
159
|
+
apply the default scope to the document, if the scope is not complex.
|
160
|
+
|
161
|
+
* \#2200 Mass assignment security now mirrors Rails 4's behavior.
|
162
|
+
|
163
|
+
* `delete_all` and `destroy_all` no longer take a `:conditions` hash but
|
164
|
+
just the raw attributes.
|
165
|
+
|
166
|
+
* \#1344 Atomic updates can now be executed in an `atomically` block, which will
|
167
|
+
delay any atomic updates on the document the block was called on until the
|
168
|
+
block is complete.
|
169
|
+
|
170
|
+
Update calls can be executed as normal in the block:
|
171
|
+
|
172
|
+
document.atomically do
|
173
|
+
document.inc(likes: 10)
|
174
|
+
document.bit(members: { and: 10 })
|
175
|
+
document.set(name: "Photek")
|
176
|
+
end
|
177
|
+
|
178
|
+
The document is also yielded to the block:
|
179
|
+
|
180
|
+
document.atomically do |doc|
|
181
|
+
doc.inc(likes: 10)
|
182
|
+
doc.bit(members: { and: 10 })
|
183
|
+
doc.set(name: "Photek")
|
184
|
+
end
|
185
|
+
|
186
|
+
The atomic commands are have a fluid interface:
|
187
|
+
|
188
|
+
document.atomically do |doc|
|
189
|
+
doc.inc(likes: 10).bit(members: { and: 10 }).set(name: "Photek")
|
190
|
+
end
|
191
|
+
|
192
|
+
If the fluid interface is leveraged without the `atomically` block, the
|
193
|
+
operations will persist in individual calls. For example, the following
|
194
|
+
would hit the database 3 times without the block provided:
|
195
|
+
|
196
|
+
doc.inc(likes: 10).bit(members: { and: 10 }).set(name: "Photek")
|
197
|
+
|
198
|
+
The block is only good for 1 document at a time, so embedded and root
|
199
|
+
document updates cannot be mixed at this time.
|
200
|
+
|
201
|
+
### New Features
|
202
|
+
|
203
|
+
* \#3146 Adding :overwrite field option, when it`s true, it wont check duplicates.
|
204
|
+
(Daniel Libanori)
|
205
|
+
|
206
|
+
* \#3002 Reloading the Rails console will also now clear Mongoid's identity map.
|
207
|
+
|
208
|
+
* \#2938 A configuration option `duplicate_fields_exception` has been added that
|
209
|
+
when set to `true` will raise an exception when defining a field that will
|
210
|
+
override an existing method. (Arthur Neves)
|
211
|
+
|
212
|
+
* \#2924 MongoDB 2.4 beta text search now has a DSL provided by Mongoid. Like
|
213
|
+
other queries, text searches are lazy evaluated, and available off the class
|
214
|
+
or criteria level.
|
215
|
+
|
216
|
+
Note that any 3rd party gem that provides a `text_search` method will now no
|
217
|
+
longer work with Mongoid, and will need to change its syntax. Examples:
|
218
|
+
|
219
|
+
Band.text_search("mode").project(name: 1).each do |doc|
|
220
|
+
# ...
|
221
|
+
end
|
222
|
+
|
223
|
+
Band.limit(10).text_search("phase").language("latin")
|
224
|
+
Band.where(:likes.gt => 1000).text_search("lucy")
|
225
|
+
|
226
|
+
* \#2855 Multiple extensions can now be supplied to relations. (Daniel Libanori)
|
227
|
+
|
228
|
+
### Resolved Issues
|
229
|
+
|
230
|
+
* \#3116 Relations instance variables are now all prefixed with `_`.
|
231
|
+
|
232
|
+
* \#3093 Only flatten 1 level when atomically pushing arrays.
|
233
|
+
|
234
|
+
* \#3063 `Document#becomes` now properly sets base object on errors.
|
235
|
+
(Adam Ross Cohen)
|
236
|
+
|
237
|
+
* \#2903 Removed unused string `to_a` extension.
|
238
|
+
|
239
|
+
## 3.1.5
|
240
|
+
|
241
|
+
### Resolved Issues
|
242
|
+
|
243
|
+
* \#3173 Fixed issues around many to many relations with custom primary keys.
|
244
|
+
(Bowen Sun)
|
245
|
+
|
246
|
+
* \#3159 Upserting now properly flags documents as persisted.
|
247
|
+
|
248
|
+
* \#3081 Criteria's `method_missing` now checks if an array responds to the provided
|
249
|
+
method before calling entries in order to not hit the database if a `NoMethodError`
|
250
|
+
was to get raised.
|
251
|
+
|
252
|
+
* \#3068 Fixed spec runs on non standard MongoDB ports if `MONGOID_SPEC_PORT` is
|
253
|
+
set.
|
254
|
+
|
255
|
+
* \#3047 Ensure `blank?` and `empty?` don't fall through method missing on criteria.
|
256
|
+
|
257
|
+
## 3.1.4
|
258
|
+
|
259
|
+
### Resolved Issues
|
260
|
+
|
261
|
+
* \#3044 Ensure enumerable targets match arrays in case statements.
|
262
|
+
|
263
|
+
* \#3034 `first_or_create` on criterion now properly passes the block to create
|
264
|
+
instead of calling after the document was created.
|
265
|
+
|
266
|
+
* \#3021 Removed `mongoid.yml` warning from initializer, this is now handled by
|
267
|
+
the session configuration options.
|
268
|
+
|
269
|
+
* \#3018 Uniqueness validator now properly serializes values in its check.
|
270
|
+
(Jerry Clinesmith)
|
271
|
+
|
272
|
+
* \#3011 Fixed aliased field support for uniqueness validation. (Johnny Shields)
|
273
|
+
|
274
|
+
* \#3008 Fixed subclasses not being able to inherit scopes properly when scope
|
275
|
+
is added post class load. (Mike Dillon)
|
276
|
+
|
277
|
+
* \#2991 `Document.timeless` now properly scopes to the instance and not thread.
|
278
|
+
|
279
|
+
* \#2980 Dynamic fields now properly handle in place editing of hashes and
|
280
|
+
arrays. (Matthew Widmann)
|
281
|
+
|
282
|
+
* \#2979 `pluck` no longer modifies the context in place. (Brian Goff)
|
283
|
+
|
284
|
+
* \#2970 Fixed counter cache to properly use the name of the relation if available
|
285
|
+
then the inverse class name second if not.
|
286
|
+
|
287
|
+
* \#2959 Nested attributes will now respect `autosave: false` if defined on the
|
288
|
+
relation.
|
289
|
+
|
290
|
+
* \#2944 Fixed uniqueness validation for localized fields when case insensitive
|
291
|
+
is true. (Vladimir Zhukov)
|
292
|
+
|
293
|
+
## 3.1.3
|
294
|
+
|
295
|
+
### Resolved Issues
|
296
|
+
|
297
|
+
* Dont duplicate embedded documents when saving after calling becomes method.
|
298
|
+
(Arthur Neves)
|
299
|
+
|
300
|
+
* \#2961 Reloading a mongoid.yml configuration now properly clears previously
|
301
|
+
configured sessions.
|
302
|
+
|
303
|
+
* \#2937 Counts can now take a `true` argument to factor in skip and limit.
|
304
|
+
(Arthur Neves)
|
305
|
+
|
306
|
+
* \#2921 Don't use type in identity map selection if inheritance is not
|
307
|
+
in play. (Arthur Neves)
|
308
|
+
|
309
|
+
* \#2893 Removed memoization of collection name and database name so lambdas
|
310
|
+
with `store_in` work properly when changing.
|
311
|
+
|
312
|
+
* \#2911 The `_destroy` attribute on 1-n relations when processing nested
|
313
|
+
attributes can now be a string or symbol when passed an array.
|
314
|
+
|
315
|
+
* \#2886 Fixed namespacing issue with Rails generators.
|
316
|
+
|
317
|
+
* \#2885 Fixed touch for aliased fields. (Niels Ganser)
|
318
|
+
|
319
|
+
* \#2883 Allow cyclic relations to not raise mixed relation errors.
|
320
|
+
|
321
|
+
* \#2867 `pluck` now properly handles aliased fields.
|
322
|
+
|
323
|
+
* \#2862 Autosaving no longer performs extra unnecessary queries.
|
324
|
+
(Arthur Neves)
|
325
|
+
|
326
|
+
## 3.1.2
|
327
|
+
|
328
|
+
### Resolved Issues
|
329
|
+
|
330
|
+
* \#2851 Fixed BigDecimal demongoization of NaN values. (nkem)
|
331
|
+
|
332
|
+
* \#2848 Fixed `touch` to work when usinng short timestamps. (Arthur Neves)
|
333
|
+
|
334
|
+
* \#2840 Fixed end-to-end `no_timeout` option handling.
|
335
|
+
|
336
|
+
* \#2826 Dynamic fields are now properly mongoized.
|
337
|
+
|
338
|
+
* \#2822 Marshal load of relations now properly reapplies extensions.
|
339
|
+
|
340
|
+
## 3.1.1
|
341
|
+
|
342
|
+
### Resolved Issues
|
343
|
+
|
344
|
+
* \#2839 Validations fixed to use the type cast value with the exception
|
345
|
+
of the numericality validator. (Lailson Bandeira)
|
346
|
+
|
347
|
+
* \#2838 `store_in` options now properly merge instead of override.
|
348
|
+
(Colin MacKenzie)
|
349
|
+
|
350
|
+
## 3.1.0
|
351
|
+
|
352
|
+
### New Features
|
353
|
+
|
354
|
+
* The minimum MongoDB requirement is now raised to 2.2, since we now
|
355
|
+
depend on the aggregation framework.
|
356
|
+
|
357
|
+
* The minimum Active Model and Active Support dependencies have been
|
358
|
+
raised to 3.2.
|
359
|
+
|
360
|
+
* \#2809 Relations can now specify a primary key to use instead of the
|
361
|
+
id on foreign keys.
|
362
|
+
|
363
|
+
class Person
|
364
|
+
include Mongoid::Document
|
365
|
+
field :username, type: String
|
366
|
+
has_many :cats, primary_key: "username"
|
367
|
+
end
|
368
|
+
|
369
|
+
class Cat
|
370
|
+
include Mongoid::Document
|
371
|
+
belongs_to :person, primary_key: "username"
|
372
|
+
end
|
373
|
+
|
374
|
+
* \#2804 $geoNear support has now been added to criteria.
|
375
|
+
|
376
|
+
Bar.where(:likes.gt => 1000).geo_near([ 52, 13 ])
|
377
|
+
Bar.geo_near([ 52, 13 ]).max_distance(0.5).spherical
|
378
|
+
|
379
|
+
* \#2799 Criteria#map can now accept a symbol of a field name as well as
|
380
|
+
a block to perform a more optimized `map`. (Gosha Arinich)
|
381
|
+
|
382
|
+
Band.where(:likes.gt => 1000).map(:name)
|
383
|
+
|
384
|
+
* \#2798 Aggregations (`sum`, `min`, `max`, `avg`) now use the
|
385
|
+
aggregation framework instead of map/reduce. (Gosha Arinich)
|
386
|
+
|
387
|
+
* \#2776 MongoDB 2.4.x new index types are now supported: "2dsphere",
|
388
|
+
"text", and "hashed". (Irakli Janiashvili)
|
389
|
+
|
390
|
+
* \#2767 $maxScan support from Origin is now supported. (Jonathan Hyman)
|
391
|
+
|
392
|
+
* \#2701 Cleanup up extra excessive database queries with 1-1 relations.
|
393
|
+
|
394
|
+
* \#2693 Custom collection names can be passed to the model generator.
|
395
|
+
(Subhash Bhushan)
|
396
|
+
|
397
|
+
rails g model band --collection=artists
|
398
|
+
|
399
|
+
* \#2688 `Model.create` and `Model.create!` now can take an array of
|
400
|
+
attributes hashes to create multiple documents at once. If an array
|
401
|
+
of attributes is provided then an array of documents is returned.
|
402
|
+
|
403
|
+
Band.create([{ name: "Tool" }, { name: "Placebo" }])
|
404
|
+
Band.create!([{ name: "Tool" }, { name: "Placebo" }])
|
405
|
+
|
406
|
+
* \#2670 Unsetting fields now accepts multiple fields instead of only 1.
|
407
|
+
(Arthur Neves)
|
408
|
+
|
409
|
+
band.unset(:name, :founded)
|
410
|
+
Band.where(name: "Placebo").unset(:members, :origin)
|
411
|
+
|
412
|
+
* \#2669 Passing a block to `Criteria#new` now properly sends the
|
413
|
+
block through to the model's contructor. (Arthur Neves)
|
414
|
+
|
415
|
+
* \#2667 `exists?` no longer hits the database in cases where we have
|
416
|
+
the necessary information in memory.
|
417
|
+
|
418
|
+
* \#2665 Mongoid now supports a counter cache for `belongs_to`
|
419
|
+
relations. (Arthur Neves)
|
420
|
+
|
421
|
+
class Band
|
422
|
+
include Mongoid::Document
|
423
|
+
belongs_to :label, counter_cache: "b_count"
|
424
|
+
end
|
425
|
+
|
426
|
+
class Album
|
427
|
+
include Mongoid::Document
|
428
|
+
belongs_to :band, counter_cache: true
|
429
|
+
end
|
430
|
+
|
431
|
+
* \#2662 Embedded documents that have `belongs_to` relations may now
|
432
|
+
eager load them.
|
433
|
+
|
434
|
+
* \#2657 Logger getter and setter convenience methods have been
|
435
|
+
added to the `Config` module. (Arthur Neves)
|
436
|
+
|
437
|
+
* \#2615 Index options can now take a specific database name if the
|
438
|
+
indexes are only to exist in a database other than the default.
|
439
|
+
|
440
|
+
class Band
|
441
|
+
include Mongoid::Document
|
442
|
+
index name: 1, { database: "another_db" }
|
443
|
+
end
|
444
|
+
|
445
|
+
* \#2613 Procs can now be provided as values to `store_in`:
|
446
|
+
|
447
|
+
class Band
|
448
|
+
include Mongoid::Document
|
449
|
+
store_in database: ->{ Thread.current[:database] }
|
450
|
+
end
|
451
|
+
|
452
|
+
* \#2609 Pass through batch_size option to query. (Martin Mauch)
|
453
|
+
|
454
|
+
* \#2555 Passing hashes to `find` when the documents id is of type hash
|
455
|
+
now properly works. (Szymon Kurcab)
|
456
|
+
|
457
|
+
* \#2545 The `$` positional operator is used for update selectors on
|
458
|
+
embedded documents that are nested 1 level deep, when appropriate.
|
459
|
+
|
460
|
+
* \#2539 `Mongoid.models` now tracks all models in the application for more
|
461
|
+
accurate determination of models for things such as indexing rake tasks.
|
462
|
+
(Ara Howard)
|
463
|
+
|
464
|
+
* \#2525 Added the ability to have short timestamped fields with aliases. This
|
465
|
+
sets timestamp fields as `c_at` and `u_at` that are also aliased as
|
466
|
+
`created_at` and `updated_at` for convenience. (Rodrigo Saito)
|
467
|
+
|
468
|
+
class Band
|
469
|
+
include Mongoid::Document
|
470
|
+
include Mongoid::Timestamps::Short # For c_at and u_at.
|
471
|
+
end
|
472
|
+
|
473
|
+
class Band
|
474
|
+
include Mongoid::Document
|
475
|
+
include Mongoid::Timestamps::Created::Short # For c_at only.
|
476
|
+
end
|
477
|
+
|
478
|
+
class Band
|
479
|
+
include Mongoid::Document
|
480
|
+
include Mongoid::Timestamps::Updated::Short # For u_at only.
|
481
|
+
end
|
482
|
+
|
483
|
+
* \#2465 Documents now have an `attribute_before_type_cast` for proper
|
484
|
+
handling of validations. (Gerad Suyderhoud)
|
485
|
+
|
486
|
+
* \#2443 `expire_after_seconds` is now a valid index option
|
487
|
+
(http://docs.mongodb.org/manual/core/indexes/#ttl-indexes,
|
488
|
+
http://docs.mongodb.org/manual/tutorial/expire-data/).
|
489
|
+
|
490
|
+
class Event
|
491
|
+
include Mongoid::Document
|
492
|
+
field :created_at, type: DateTime
|
493
|
+
index({ created_at: 1 }, { expire_after_seconds: 3600 })
|
494
|
+
end
|
495
|
+
|
496
|
+
* \#2373 Relations with the `touch: true` option will now be automatically
|
497
|
+
touched when the child document is created or destroyed.
|
498
|
+
|
499
|
+
* Added `Document.first_or_create!` and `Criteria#first_or_create!`. This
|
500
|
+
raises a validations error if creation fails validation.
|
501
|
+
|
502
|
+
Band.where(name: "Depeche Mode").first_or_create!
|
503
|
+
Band.where(name: "Tool").first_or_create!(active: true)
|
504
|
+
|
505
|
+
* Added `Document.first_or_initialize` and `Criteria#first_or_initialize`.
|
506
|
+
This is the same as `first_or_create` but initializes a new (unpersisted)
|
507
|
+
document if none is found.
|
508
|
+
|
509
|
+
Band.where(name: "Depeche Mode").first_or_initialize
|
510
|
+
Band.where(name: "Tool").first_or_initialize(active: true)
|
511
|
+
|
512
|
+
* Added `Model.pluck` and `Criteria#pluck` similar to Active Record's, which
|
513
|
+
returns an array of values for the provided field. (Jason Lee)
|
514
|
+
|
515
|
+
Band.where(name: "Depeche Mode").pluck(:_id)
|
516
|
+
Band.where(name: "Tool").pluck(:likes)
|
517
|
+
|
518
|
+
* \#2324 Embeds many relations now properly handle `delete_if`.
|
519
|
+
|
520
|
+
* \#2317 Added `Document.first_or_create` and `Criteria#first_or_create`.
|
521
|
+
This will return the first matching document or create one with additional
|
522
|
+
attributes if one does not exist. (incorvia)
|
523
|
+
|
524
|
+
Band.where(name: "Depeche Mode").first_or_create
|
525
|
+
Band.where(name: "Tool").first_or_create(active: true)
|
526
|
+
|
527
|
+
* \#2292 Added `Model.each_with_index`.
|
528
|
+
|
529
|
+
* \#2285 `Config.load_configuration` is now public for those who want to instantiate
|
530
|
+
settings directly from a hash.
|
531
|
+
|
532
|
+
* \#2275 Added rake task `db:mongoid:purge` that will drop all collections with
|
533
|
+
the exception of the system collections in the default database.
|
534
|
+
|
535
|
+
* \#2257 `after_find` callbacks have been added for when documents are returned
|
536
|
+
from the database.
|
537
|
+
|
538
|
+
class Band
|
539
|
+
include Mongoid::Document
|
540
|
+
|
541
|
+
after_find do |doc|
|
542
|
+
# Some logic here.
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
* \#2223 Allow to find documents by javascript with parameters that are
|
547
|
+
protected from javascript injection via `Model.for_js`.
|
548
|
+
|
549
|
+
Band.for_js("this.name = param", param: "Tool")
|
550
|
+
Band.where(:likes.gt => 1000).for_js("this.likes < this.follows")
|
551
|
+
|
552
|
+
* \#2197 When providing session configuration with no ports, Mongoid will now
|
553
|
+
default these to 27017.
|
554
|
+
|
555
|
+
* \#2180 1-n and n-n relations now support before/after add/remove callbacks.
|
556
|
+
(Rodrigo Saito)
|
557
|
+
|
558
|
+
class Band
|
559
|
+
include Mongoid::Document
|
560
|
+
|
561
|
+
embeds_many :albums, after_add: :notify_labels
|
562
|
+
has_many :followers, before_remove: ->(band, follower){ notify_unfollow(follower) }
|
563
|
+
end
|
564
|
+
|
565
|
+
* \#2157 `Criteria#update` and `Criteria#update_all` now serialize values
|
566
|
+
according to their field type, if a field is defined.
|
567
|
+
|
568
|
+
* \#2022 Custom callbacks can now register themselves for use with observers
|
569
|
+
by using the `observable` macro.
|
570
|
+
|
571
|
+
class Band
|
572
|
+
include Mongoid::Document
|
573
|
+
|
574
|
+
define_model_callbacks :notification
|
575
|
+
observable :notification
|
576
|
+
end
|
577
|
+
|
578
|
+
class BandObserver < Mongoid::Observer
|
579
|
+
|
580
|
+
def before_notification(band)
|
581
|
+
#...
|
582
|
+
end
|
583
|
+
|
584
|
+
def after_notification(band)
|
585
|
+
#...
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
* \#1766 Many to many relations will not touch the database if the foreign key
|
590
|
+
is an empty array.
|
591
|
+
|
592
|
+
* \#1564 Many to many foreign keys now have the default set lazily only if the
|
593
|
+
relation has been accessed. This avoids storing empty arrays if the relation
|
594
|
+
has not been touched.
|
595
|
+
|
596
|
+
### Resolved Issues
|
597
|
+
|
598
|
+
* \#2730 Calling sort on a context properly updates the context's criteria.
|
599
|
+
(Arthur Neves)
|
600
|
+
|
601
|
+
* \#2719 `distinct` is now available at the class level.
|
602
|
+
|
603
|
+
Band.distinct(:name)
|
604
|
+
|
605
|
+
* \#2714 Overriding sessions when the new session has a different database will
|
606
|
+
now properly switch the database at runtime as well.
|
607
|
+
|
608
|
+
* \#2697 Eager loading fixed when including multiple models that inherit from
|
609
|
+
the same class. (Kirill Lazarev)
|
610
|
+
|
611
|
+
* \#2664 In memory sorting of embedded documents now properly works when
|
612
|
+
multiple fields are provided. (Neer Friedman)
|
613
|
+
|
614
|
+
## 3.0.24
|
615
|
+
|
616
|
+
### Resolved Issues
|
617
|
+
|
618
|
+
* \#2879 `remove_attribute` on new documents no longer creates an unnecessary
|
619
|
+
$unset operation.
|
620
|
+
|
621
|
+
## 3.0.23
|
622
|
+
|
623
|
+
### Resolved Issues
|
624
|
+
|
625
|
+
* \#2851 Fixed BigDecimal demongoization of NaN values. (nkem)
|
626
|
+
|
627
|
+
* \#2841 Calling `delete_all` or `destroy_all` on an embeds many when in the
|
628
|
+
middle of a parent update will now properly execute the deletion.
|
629
|
+
(Arthur Neves)
|
630
|
+
|
631
|
+
* \#2835 Fixed clearing of persistence options in uniqueness validator.
|
632
|
+
|
633
|
+
* \#2826 Dynamic fields are now properly mongoized.
|
634
|
+
|
635
|
+
* \#2822 Marshal load of relations now properly reapplies extensions.
|
636
|
+
|
637
|
+
* \#2821 Autosaved relations should be duped in inheriting classes.
|
638
|
+
|
639
|
+
## 3.0.22
|
640
|
+
|
641
|
+
### Resolved Issues
|
642
|
+
|
643
|
+
* \#2812 Fixed criteria on many to many relations when the base document is
|
644
|
+
destroyed and the foreign key has not yet been lazy evaluated.
|
645
|
+
|
646
|
+
* \#2796 Don't cascade changes on has_many relations when assigning with
|
647
|
+
a delete.
|
648
|
+
|
649
|
+
* \#2795 Fix precision on time conversions. (Tom de Bruijn)
|
650
|
+
|
651
|
+
* \#2794 Don't autobuild when reading a relation for validation.
|
652
|
+
|
653
|
+
* \#2790 `becomes` now copies embedded documents even if they were protected
|
654
|
+
by mass assignment.
|
655
|
+
|
656
|
+
* \#2787 Allow `becomes` to replace the document in the identity map.
|
657
|
+
|
658
|
+
* \#2786 Fixed regressed cascading callbacks on destroy not firing.
|
659
|
+
|
660
|
+
* \#2784 Fixed uniqueness validation properly getting added to subclasses.
|
661
|
+
(Takeshi Akima)
|
662
|
+
|
663
|
+
## 3.0.21
|
664
|
+
|
665
|
+
### Resolved Issues
|
666
|
+
|
667
|
+
* \#2781 / * \#2777 - Fixed issue with serialization of `DateTime` that was
|
668
|
+
only present in Rails environments.
|
669
|
+
|
670
|
+
## 3.0.20
|
671
|
+
|
672
|
+
### Resolved Issues
|
673
|
+
|
674
|
+
* \#2774 Ensure validations macros for uniqueness, presence, and associated
|
675
|
+
are also available at the instance level.
|
676
|
+
|
677
|
+
* \#2772 Localized fields are now properly handled when cloning a document.
|
678
|
+
|
679
|
+
* \#2758 `Mongoid.create_indexes` does not fail when cannot constantize class.
|
680
|
+
(Arthur Neves)
|
681
|
+
|
682
|
+
* \#2743 Persistence options are no longer cleared when loading revisions.
|
683
|
+
(Arthur Neves)
|
684
|
+
|
685
|
+
* \#2741 Fix time mongoization usec rounding errors on MRI and JRuby.
|
686
|
+
|
687
|
+
* \#2740 Support integer keys in hash fields when using `read_attribute` with
|
688
|
+
dot notation.
|
689
|
+
|
690
|
+
* \#2739 Ensure integer deserialization properly casts to integers.
|
691
|
+
|
692
|
+
* \#2733 Many to many relations with `inverse_of: nil` do not persist the
|
693
|
+
inverse relation on `<<` or `push` if the document is already persisted.
|
694
|
+
|
695
|
+
* \#2705 Fixed logic around when children can be added to the cascading
|
696
|
+
callbacks list.
|
697
|
+
|
698
|
+
## 3.0.19
|
699
|
+
|
700
|
+
### Resolved Issues
|
701
|
+
|
702
|
+
* Released to revert the changes in \#2703.
|
703
|
+
|
704
|
+
## 3.0.18
|
705
|
+
|
706
|
+
### Resolved Issues
|
707
|
+
|
708
|
+
* \#2707 Calling `find_or_create_by` or `find_by_initialize_by` off a relation
|
709
|
+
with a chained criteria or scope now properly keeps the relations intact on
|
710
|
+
the new or found document.
|
711
|
+
|
712
|
+
* \#2699 Resetting a field now removes the name from the changed attributes
|
713
|
+
list. (Subhash Bhushan)
|
714
|
+
|
715
|
+
* \#2683 Aliased fields are now supported when executing atomic operations from
|
716
|
+
criteria. (Arthur Neves)
|
717
|
+
|
718
|
+
* \#2678 Calling `Criteria#sum` with no matching documents returns `0` instead
|
719
|
+
of `nil`.
|
720
|
+
|
721
|
+
* \#2671 Matchers now correctly handle symbol keys. (Jonathan Hyman)
|
722
|
+
|
723
|
+
## 3.0.17
|
724
|
+
|
725
|
+
### Resolved Issues
|
726
|
+
|
727
|
+
* \#2686 Fixed the broken Moped dependency - Moped now must be at least at
|
728
|
+
version 1.2.0.
|
729
|
+
|
730
|
+
## 3.0.16
|
731
|
+
|
732
|
+
### Resolved Issues
|
733
|
+
|
734
|
+
* \#2661 Implement instance level `model_name` for documents.
|
735
|
+
|
736
|
+
* \#2651 Ensure `Criteria#type` works properly with both symbol and string
|
737
|
+
keys in the selector.
|
738
|
+
|
739
|
+
* \#2647 Ensure `deleted?` and `destroyed?` on paranoid documents return the
|
740
|
+
same value.
|
741
|
+
|
742
|
+
* \#2646 Set unloaded doc in memory on enumerable targets before yielding to
|
743
|
+
the block.
|
744
|
+
|
745
|
+
* \#2645 Take caching into consideration when asking for counts.
|
746
|
+
(Arthur Nogueira Neves)
|
747
|
+
|
748
|
+
* \#2642 Don't batch push empty arrays on embedded documents. (Laszlo Bacsi)
|
749
|
+
|
750
|
+
* \#2639 Avoid extra unnecesary queries on new records when building relations
|
751
|
+
off of them.
|
752
|
+
|
753
|
+
* \#2638 When a criteria is eager loading, calling `first` or `last` then
|
754
|
+
iterating the entire results properly eager loads the full request.
|
755
|
+
|
756
|
+
* \#2618 Validating uniqueness now always uses string consistency by default.
|
757
|
+
|
758
|
+
* \#2564 Fixed infinite recursion for cases where a relation getter was
|
759
|
+
overridden and called the setter from that method.
|
760
|
+
|
761
|
+
* \#2554 Ensure `unscoped` on an `embeds_many` does not include documents
|
762
|
+
flagged for destruction.
|
763
|
+
|
764
|
+
## 3.0.15
|
765
|
+
|
766
|
+
### Resolved Issues
|
767
|
+
|
768
|
+
* \#2630 Fix cascading when the metadata exists but no cascade defined.
|
769
|
+
|
770
|
+
* \#2625 Fix `Marshal.dump` and `Marshal.load` of proxies and criteria
|
771
|
+
objects.
|
772
|
+
|
773
|
+
* \#2619 Fixed the classes returned by `observed_classes` on an observer
|
774
|
+
when it is observing custom models.
|
775
|
+
|
776
|
+
* \#2612 `DocumentNotFound` errors now expose the class in the error
|
777
|
+
instance.
|
778
|
+
|
779
|
+
* \#2610 Ensure calling `first` after a `last` that had sorting options resets
|
780
|
+
the sort.
|
781
|
+
|
782
|
+
* \#2604 Check pulls and pushes for conflicting updates. (Lucas Souza)
|
783
|
+
|
784
|
+
* \#2600 Instantiate the proper class type for attributes when using
|
785
|
+
multi parameter attributes. (xxswingxx)
|
786
|
+
|
787
|
+
* \#2598 Fixed sorting on localized fields with embedded docs.
|
788
|
+
|
789
|
+
* \#2588 Block defining methods for dynamic attributes that would be invalid
|
790
|
+
ruby methods. (Matt Sanford)
|
791
|
+
|
792
|
+
* \#2587 Fix method clash with `belongs_to` proxies when resetting relation
|
793
|
+
unloaded criteria.
|
794
|
+
|
795
|
+
* \#2585 Ensure session configuration options get passed to Moped as symbols.
|
796
|
+
|
797
|
+
* \#2584 Allow map/reduce to operate on secondaries if output is set to `inline`.
|
798
|
+
|
799
|
+
* \#2582 Ensure `nil` session override can never cause to access a session with
|
800
|
+
name `nil`.
|
801
|
+
|
802
|
+
* \#2581 Use strong consistency when reloading documents. (Mark Kremer)
|
803
|
+
|
804
|
+
## 3.0.14
|
805
|
+
|
806
|
+
### Resolved Issues
|
807
|
+
|
808
|
+
* \#2575 Prevent end of month times from rounding up since floats are not
|
809
|
+
precise enough to handle usec. (Steve Valaitis)
|
810
|
+
|
811
|
+
* \#2573 Don't use i18n for inspection messages.
|
812
|
+
|
813
|
+
* \#2571 Remove blank error message from locales. (Jordan Elver)
|
814
|
+
|
815
|
+
* \#2568 Fix uniqueness validation for lacalized fields when a scope is also
|
816
|
+
provided.
|
817
|
+
|
818
|
+
* \#2552 Ensure `InvalidPath` errors are raised when embedded documents try to
|
819
|
+
get paths from a root selector.
|
820
|
+
|
821
|
+
## 3.0.13
|
822
|
+
|
823
|
+
### Resolved Issues
|
824
|
+
|
825
|
+
* \#2548 Fix error when generating config file with a fresh app with Unicorn in
|
826
|
+
the gemset.
|
827
|
+
|
828
|
+
## 3.0.12
|
829
|
+
|
830
|
+
### Resolved Issues
|
831
|
+
|
832
|
+
* \#2542 Allow embedded documents using `store_as` to properly alias in
|
833
|
+
criteria.
|
834
|
+
|
835
|
+
* \#2541 Ensure that the type change is correct when upcasting/downcasting a
|
836
|
+
document via `Document#becomes` (Łukasz Bandzarewicz)
|
837
|
+
|
838
|
+
* \#2529 Fields on subclasses that override fields in the parent where both have
|
839
|
+
defaults with procs now properly override the default in the subclass.
|
840
|
+
|
841
|
+
* \#2528 Aliased fields need to be duped when subclassing.
|
842
|
+
|
843
|
+
* \#2527 Ensure removal of docs in a `has_many` does a multi update when setting
|
844
|
+
to an empty array.
|
845
|
+
|
846
|
+
## 3.0.11
|
847
|
+
|
848
|
+
### Resolved Issues
|
849
|
+
|
850
|
+
* \#2522 Fixed `Criteria#with` to return the criteria and not the class.
|
851
|
+
|
852
|
+
* \#2518 Fix unit of work call for the identity map when using Passenger.
|
853
|
+
|
854
|
+
* \#2512 Ensure nested attributes destroy works with the delayed destroys
|
855
|
+
introduced in 3.0.10 when multiple levels deep.
|
856
|
+
|
857
|
+
* \#2509 Don't hit identity map an extra time when the returned value is an
|
858
|
+
empty hash. (Douwe Maan)
|
859
|
+
|
860
|
+
## 3.0.10
|
861
|
+
|
862
|
+
### Resolved Issues
|
863
|
+
|
864
|
+
* \#2507 Ensure no extra db hits when eager loading has a mix of parents
|
865
|
+
with and without docs. (Douwe Maan)
|
866
|
+
|
867
|
+
* \#2505 Ensure `update` and `update_all` from criteria properly handle
|
868
|
+
aliased fields. (Dmitry Krasnoukhov)
|
869
|
+
|
870
|
+
* \#2504 `Model#becomes` properly keeps the same id.
|
871
|
+
|
872
|
+
* \#2498 Criteria now properly pass provided blocks though `method_missing`.
|
873
|
+
|
874
|
+
* \#2496 Embedded documents that were previously stored without ids now
|
875
|
+
properly update and get assigned ids from within Mongoid.
|
876
|
+
|
877
|
+
* \#2494 All explicit atomic operations now properly respect aliased fields.
|
878
|
+
|
879
|
+
* \#2493 Use `Class#name` instead of `Class#model_name` when setting
|
880
|
+
polymorphic types in case `model_name` has been overridden.
|
881
|
+
|
882
|
+
* \#2491 Removed unnecessary merge call in cascadable children.
|
883
|
+
|
884
|
+
* \#2485 Removing indexes now always uses strong consistency.
|
885
|
+
|
886
|
+
* \#2483 Versioning now handles localized fields. (Lawrence Curtis)
|
887
|
+
|
888
|
+
* \#2482 Store find parameters in the `DocumentNotFound` error.
|
889
|
+
|
890
|
+
* \#2481 Map/reduce aggregations now properly handle Mongo's batching of
|
891
|
+
reduce jobs in groups of 100 with the state being passed through on the
|
892
|
+
count.
|
893
|
+
|
894
|
+
* \#2476 Handle skip and limit outside of range on embeds_many relations
|
895
|
+
gracefully.
|
896
|
+
|
897
|
+
* \#2474 Correctly detach 1-1 relations when the child is not yet loaded.
|
898
|
+
(Kostyantyn Stepanyuk)
|
899
|
+
|
900
|
+
* \#2451 `relation.deleted` on embedded paranoid documents now works properly
|
901
|
+
again.
|
902
|
+
|
903
|
+
* \#2472 Ensure `update_all` on embedded relations works properly when nothing
|
904
|
+
is actually going to be updated.
|
905
|
+
|
906
|
+
* \#2469 Nullified documents on relations are now able to be re-added with the
|
907
|
+
same in memory instance.
|
908
|
+
|
909
|
+
* \#2454 `Model#as_document` properly allows changes from having a relation to
|
910
|
+
the relation being removed. (James Almond)
|
911
|
+
|
912
|
+
* \#2445 Mongoid middleware now properly supports both normal and streamed
|
913
|
+
responses and properly clears the identity map for either.
|
914
|
+
|
915
|
+
* \#2367 Embedded documents that are to be deleted via nested attributes no
|
916
|
+
longer become immediately removed from the relation in case the parent
|
917
|
+
validation fails. Instead, they get flagged for destruction and then the
|
918
|
+
removal occurs upon the parent passing validation and going to persist.
|
919
|
+
|
920
|
+
Note this is a behaviour change, but since the API does not change and
|
921
|
+
the previous behaviour was incorrect and did not match AR this was able
|
922
|
+
to go into a point release.
|
923
|
+
|
924
|
+
## 3.0.9
|
925
|
+
|
926
|
+
### Resolved Issues
|
927
|
+
|
928
|
+
* \#2463 Fixed the broken `rails g mongoid:config` from a fresh repo.
|
929
|
+
|
930
|
+
* \#2456 The descendants cache is now reset when the document is inherited
|
931
|
+
again. (Kostyantyn Stepanyuk)
|
932
|
+
|
933
|
+
* \#2453 `Model#write_attribute` now properly works with aliased fields.
|
934
|
+
(Campbell Allen)
|
935
|
+
|
936
|
+
* \#2444 Removed extra dirty methods creation call. (Kostyantyn Stepanyuk)
|
937
|
+
|
938
|
+
* \#2440/\#2435 Pass mass assignment options down to children when setting via
|
939
|
+
nested attributes or embedded documents.
|
940
|
+
|
941
|
+
* \#2439 Fixed memory leak in threaded selection of returned fields.
|
942
|
+
(Tim Olsen)
|
943
|
+
|
944
|
+
* mongoid/moped\#82 Aliased fields now work with `Criteria#distinct`.
|
945
|
+
|
946
|
+
* \#2423 Fixed embedded document's `update_all` to perform the correct $set
|
947
|
+
when using off a criteria.
|
948
|
+
|
949
|
+
* \#2414 Index definitions now respect aliased fields.
|
950
|
+
|
951
|
+
* \#2413 Enumerable targets now properly return enumerators when no blocks
|
952
|
+
are provided. (Andrew Smith)
|
953
|
+
|
954
|
+
* \#2411 BigDecimal fields are properly stored as strings when mongoizing
|
955
|
+
integers and floats.
|
956
|
+
|
957
|
+
* \#2409 Don't warn about missing mongoid.yml if configured programatically.
|
958
|
+
|
959
|
+
* \#2403 Return false on `update_all` of an embeds many with no documents.
|
960
|
+
|
961
|
+
* \#2401 Bring back the ability to merge a criteria with a hash.
|
962
|
+
|
963
|
+
* \#2399 Reject blank id values on has_many `Model#object_ids=`.
|
964
|
+
(Tiago Rafael Godinho)
|
965
|
+
|
966
|
+
* \#2393 Ensure `inverse_of` is respected when using polymorphic relations.
|
967
|
+
|
968
|
+
* \#2388 Map/reduce properly uses `sort` instead of `orderby` in the execution
|
969
|
+
of the command. (Alex Tsibulya)
|
970
|
+
|
971
|
+
* \#2386 Allow geo haystack and bits parameters in indexes. (Bradley Rees)
|
972
|
+
|
973
|
+
* \#2380 `Model#becomes` now properly copies over dirty attributes.
|
974
|
+
|
975
|
+
* \#2331 Don't double push child documents when extra saves are called in an
|
976
|
+
after_create callback.
|
977
|
+
|
978
|
+
## 3.0.8 (Yanked)
|
979
|
+
|
980
|
+
## 3.0.6
|
981
|
+
|
982
|
+
### Resolved Issues
|
983
|
+
|
984
|
+
* \#2375 Uniqueness validation scoping now works with aliased fields.
|
985
|
+
|
986
|
+
* \#2372 Ensure that all atomic operations mongoize values before executing.
|
987
|
+
|
988
|
+
* \#2370 Paranoid documents now properly don't get deleted when using
|
989
|
+
`dependent: :restrict` and an exception is raised.
|
990
|
+
|
991
|
+
* \#2365 Don't do anything when trying to replace an embeds_one with the same
|
992
|
+
document.
|
993
|
+
|
994
|
+
* \#2362 Don't store inverse of field values in the database when they are not
|
995
|
+
needed. (When there is not more than one polymorphic parent defined on the
|
996
|
+
same class).
|
997
|
+
|
998
|
+
* \#2360 Cloning documents should ignore mass assignment protection rules.
|
999
|
+
|
1000
|
+
* \#2356 When limiting fields returned in queries via `only` ensure that the
|
1001
|
+
limitation is scoped to the model.
|
1002
|
+
|
1003
|
+
* \#2353 Allow `update_attribute` to properly handle aliased fields.
|
1004
|
+
|
1005
|
+
* \#2348 Conversion of strings to times should raise an arugment error if the
|
1006
|
+
string is invalid. (Campbell Allen)
|
1007
|
+
|
1008
|
+
* \#2346 Ensure `belongs_to` relations are evolvable when passed the proxy and
|
1009
|
+
not the document.
|
1010
|
+
|
1011
|
+
* \#2334 Fixed aggregation map/reduce when fields sometimes do not exist.
|
1012
|
+
(James McKinney)
|
1013
|
+
|
1014
|
+
* \#2330 Fixed inconsistency of #size and #length on criteria when the documents
|
1015
|
+
have been iterated over with a limit applied.
|
1016
|
+
|
1017
|
+
* \#2328 Ensure ordering is applied on all relation criteria if defined.
|
1018
|
+
|
1019
|
+
* \#2327 Don't execute callbacks from base document if the document cannot execute
|
1020
|
+
them.
|
1021
|
+
|
1022
|
+
* \#2318 Ensure setting any numeric on a Float field actually sets it as a float,
|
1023
|
+
even if the number provided is an integer.
|
1024
|
+
|
1025
|
+
## 3.0.5
|
1026
|
+
|
1027
|
+
### Resolved Issues
|
1028
|
+
|
1029
|
+
* \#2313 Fixed deserialization of `nil` `TimeWithZone` fields. (nagachika)
|
1030
|
+
|
1031
|
+
* \#2311 `Document#changes` no longer returns `nil` values for Array and Hash
|
1032
|
+
fields that were only accessed and didn't actually change. Regression from 2.4.x.
|
1033
|
+
|
1034
|
+
* \#2310 Setting a many to many duplicate successively in memory no longer clears
|
1035
|
+
the inverse foreign keys.
|
1036
|
+
|
1037
|
+
* \#2309 Allow embeds_one relations to be set with hashes more than just the
|
1038
|
+
initial set.
|
1039
|
+
|
1040
|
+
* \#2308 Ensure documents retrieved via `#find` on `has_many` and
|
1041
|
+
`has_and_belongs_to_many` relations are kept in memory.
|
1042
|
+
|
1043
|
+
* \#2304 Default scopes now properly merge instead of overwrite when more
|
1044
|
+
than one is defined as per expectations with AR. (Kirill Maksimov)
|
1045
|
+
|
1046
|
+
* \#2300 Ensure reloading refreshes the document in the identity map.
|
1047
|
+
|
1048
|
+
* \#2298 Protect against many to many relations pulling a null set of ids.
|
1049
|
+
(Jonathan Hyman)
|
1050
|
+
|
1051
|
+
* \#2291 Fixed touch operations only to update the timestamp and the optional
|
1052
|
+
field, no matter what the other changes on the document are.
|
1053
|
+
|
1054
|
+
* \#1091 Allow presence validation to pass if the value is `false`.
|
1055
|
+
|
1056
|
+
## 3.0.4
|
1057
|
+
|
1058
|
+
### Resolved Issues
|
1059
|
+
|
1060
|
+
* \#2280 Fix synchronization of many-to-many relations when an ordering default
|
1061
|
+
scope exists on either side of the association.
|
1062
|
+
|
1063
|
+
* \#2278 `Criteria#update` now properly updates only the first matching document,
|
1064
|
+
where `Criteria#update_all` will update all matching documents. (no flag vs multi).
|
1065
|
+
|
1066
|
+
* \#2274 When loading models, warn if error is raised but continue processing.
|
1067
|
+
|
1068
|
+
* \#2272 Don't wipe selectors or options when removing the default scope for
|
1069
|
+
actual nil values. Must check if key exists as well.
|
1070
|
+
|
1071
|
+
* \#2266 Restored paranoid documents are no longer flagged as destroyed.
|
1072
|
+
(Mario Uher)
|
1073
|
+
|
1074
|
+
* \#2263 Ensure casting of non object id foreign keys on many to many relations
|
1075
|
+
happens in the initial set, not at validation time.
|
1076
|
+
|
1077
|
+
## 3.0.3
|
1078
|
+
|
1079
|
+
### Resolved Issues
|
1080
|
+
|
1081
|
+
* \#2259 Ensure subclassed documents can not be pulled from the identity map
|
1082
|
+
via an id of another document in the same collection with a parent or
|
1083
|
+
sibeling type.
|
1084
|
+
|
1085
|
+
* \#2254 $inc operations no longer convert all values to floats.
|
1086
|
+
|
1087
|
+
* \#2252 Don't fire autosave when before callbacks have terminated.
|
1088
|
+
|
1089
|
+
* \#2248 Improved the performance of `exists?` on criteria and relations.
|
1090
|
+
(Jonathan Hyman)
|
1091
|
+
|
1092
|
+
## 3.0.2
|
1093
|
+
|
1094
|
+
### Resolved Issues
|
1095
|
+
|
1096
|
+
* \#2244 Get rid of id mass assignment warnings in nested attributes.
|
1097
|
+
|
1098
|
+
* \#2242 Fix eager loading not to load all documents when calling first or
|
1099
|
+
last.
|
1100
|
+
|
1101
|
+
* \#2241 Map/reduce operations now always use strong consistency since they
|
1102
|
+
have the potential to write to collections, most of the time.
|
1103
|
+
|
1104
|
+
* \#2238 Ensure n-n foreign key fields are flagged as resizable to prevent
|
1105
|
+
`nil` -> `[]` changes when using `#only` and updating.
|
1106
|
+
|
1107
|
+
* \#2236 Keep the instance of the document in the validations exception
|
1108
|
+
accessible via `document` or `record`.
|
1109
|
+
|
1110
|
+
* \#2234 Ensure validations when document is getting persisted with custom
|
1111
|
+
options work properly with custom options, and do not clear them out if
|
1112
|
+
validation passes.
|
1113
|
+
|
1114
|
+
* \#2224 `Model#inc` now accepts `BigDecimal` values.
|
1115
|
+
|
1116
|
+
* \#2216 Fixed assignment of metadata on embeds one relations when setting
|
1117
|
+
multiple times in a row.
|
1118
|
+
|
1119
|
+
* \#2212 Ensure errors are cleared after a save with `validate: false` in all
|
1120
|
+
situations.
|
1121
|
+
|
1122
|
+
* \#2207 When eager loading ids the query must be duped to avoid multiple
|
1123
|
+
iteration problems not getting the required fields.
|
1124
|
+
|
1125
|
+
* \#2204 Raise an `InvalidIncludes` error when passing arguments to
|
1126
|
+
`Criteria.includes` that are invalid (not relations, or more than 1 level.)
|
1127
|
+
|
1128
|
+
* \#2203 Map/Reduce now works properly in conjunction with `Model#with`.
|
1129
|
+
|
1130
|
+
Band.
|
1131
|
+
with(session: "secondary").
|
1132
|
+
where(:likes.gt => 100).
|
1133
|
+
map_reduce(map, reduce).
|
1134
|
+
out(inline: 1)
|
1135
|
+
|
1136
|
+
* \#2199 Autosave false is now respected when automatically adding
|
1137
|
+
presence validation. (John Nishinaga)
|
1138
|
+
|
1139
|
+
## 3.0.1
|
1140
|
+
|
1141
|
+
### Resolved Issues
|
1142
|
+
|
1143
|
+
* \#2191 Ensure proper visibility (private) for error message generation
|
1144
|
+
methods.
|
1145
|
+
|
1146
|
+
* \#2187 Ensure all levels of nested documents are serialized in json.
|
1147
|
+
|
1148
|
+
* \#2184 Allow names of relations that conflict with ruby core kernel
|
1149
|
+
methods to pass existence checks.
|
1150
|
+
|
1151
|
+
* \#2181 Ensure `.first` criteria sort by ascending ids, if no other
|
1152
|
+
sorting criteria was provided.
|
1153
|
+
|
1154
|
+
## 3.0.0
|
1155
|
+
|
1156
|
+
### New Features
|
1157
|
+
|
1158
|
+
* \#2151 When asking for metadata before persistence, Mongoid will now
|
1159
|
+
raise a `Mongoid::Errors::NoMetadata` error if the metadata is not
|
1160
|
+
present.
|
1161
|
+
|
1162
|
+
* \#2147 `Model#becomes` now copies over the embedded documents.
|
1163
|
+
|
1164
|
+
* A new callback has been introduced: `upsert`, which runs when calling
|
1165
|
+
`document.upsert` since Mongoid does not know if the document is to be
|
1166
|
+
treated as new or persisted. With this come the model callbacks:
|
1167
|
+
|
1168
|
+
before_upsert
|
1169
|
+
after_upsert
|
1170
|
+
around_upsert
|
1171
|
+
|
1172
|
+
* \#2080/\#2087 The database or session that Mongoid persists to can now be
|
1173
|
+
overridden on a global level for cases where `Model#with` is not a viable
|
1174
|
+
option.
|
1175
|
+
|
1176
|
+
Mongoid.override_database(:secondary)
|
1177
|
+
Mongoid.override_session(:secondary)
|
1178
|
+
|
1179
|
+
Band.create(name: "Placebo") #=> Persists to secondary.
|
1180
|
+
band.albums.create #=> Persists to secondary.
|
1181
|
+
|
1182
|
+
Note that this option is global and overrides for all models on the current
|
1183
|
+
thread. It is the developer's responsibility to remember to set this back
|
1184
|
+
to nil if you no longer want the override to happen.
|
1185
|
+
|
1186
|
+
Mongoid.override_database(nil)
|
1187
|
+
Mongoid.override_session(nil)
|
1188
|
+
|
1189
|
+
* \#1989 Criteria `count`, `size` and `length` now behave as Active Record
|
1190
|
+
with regards to database access.
|
1191
|
+
|
1192
|
+
`Criteria#count` will always hit the database to get the count.
|
1193
|
+
|
1194
|
+
`Criteria#length` and `Criteria#size` will hit the database once if the
|
1195
|
+
criteria has not been loaded, and subsequent calls will return the
|
1196
|
+
cached value.
|
1197
|
+
|
1198
|
+
If the criteria has been iterated over or loaded, `length` and `size`
|
1199
|
+
will never hit the db.
|
1200
|
+
|
1201
|
+
* \#1976 Eager loading no longer produces queries when the base query returns
|
1202
|
+
zero results.
|
1203
|
+
|
1204
|
+
* `Model.find_by` now accepts a block and will yield to the found document if
|
1205
|
+
it is not nil.
|
1206
|
+
|
1207
|
+
Band.find_by(name: "Depeche Mode") do |band|
|
1208
|
+
band.likes = 100
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
* \#1958/\#1798 Documents and `belongs_to` relations now support touch.
|
1212
|
+
|
1213
|
+
class Band
|
1214
|
+
include Mongoid::Document
|
1215
|
+
include Mongoid::Timestamps::Updated
|
1216
|
+
belongs_to :label, touch: true
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
Update the document's updated_at timestamp to the current time. This
|
1220
|
+
will also update any touchable relation's timestamp as well.
|
1221
|
+
|
1222
|
+
Band.first.touch
|
1223
|
+
|
1224
|
+
Update a specific time field along with the udpated_at.
|
1225
|
+
|
1226
|
+
Band.first.touch(:founded)
|
1227
|
+
|
1228
|
+
This fires no validations or callbacks.
|
1229
|
+
|
1230
|
+
* Mongoid now supports MongoDB's $findAndModify command.
|
1231
|
+
|
1232
|
+
Band.find_and_modify("$inc" => { likes: 1 })
|
1233
|
+
|
1234
|
+
Band.desc(:name).only(:name).find_and_modify(
|
1235
|
+
{ "$inc" => { likes: 1 }}, new: true
|
1236
|
+
)
|
1237
|
+
|
1238
|
+
* \#1906 Mongoid will retrieve documents from the identity map when
|
1239
|
+
providing multiple ids to find. (Hans Hasselberg)
|
1240
|
+
|
1241
|
+
* \#1903 Mongoid raises an error if provided a javascript expression
|
1242
|
+
to a where clause on an embedded collection. (Sebastien Azimi)
|
1243
|
+
|
1244
|
+
* Aggregations now adhere to both a Mongoid API and their enumerable
|
1245
|
+
counterparts where applicable.
|
1246
|
+
|
1247
|
+
Band.min(:likes)
|
1248
|
+
Band.min do |a, b|
|
1249
|
+
a.likes <=> b.likes
|
1250
|
+
end
|
1251
|
+
|
1252
|
+
Band.max(:likes)
|
1253
|
+
Band.max do |a, b|
|
1254
|
+
a.likes <=> b.likes
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
Note that when providing a field name and no block, a single numeric
|
1258
|
+
value will be returned, but when providing a block, a document will
|
1259
|
+
be returned which has the min/max value. This is since Ruby's
|
1260
|
+
Enumerable API dictates when providing a block, the matching element
|
1261
|
+
is returned.
|
1262
|
+
|
1263
|
+
When providing a block, all documents will be loaded into memory.
|
1264
|
+
When providing a symbol, the execution is handled via map/reduce on
|
1265
|
+
the server.
|
1266
|
+
|
1267
|
+
* A kitchen sink aggregation method is now provided, to get everything in
|
1268
|
+
in a single call for a field.
|
1269
|
+
|
1270
|
+
Band.aggregates(:likes)
|
1271
|
+
# =>
|
1272
|
+
# {
|
1273
|
+
# "count" => 2.0,
|
1274
|
+
# "max" => 1000.0,
|
1275
|
+
# "min" => 500.0,
|
1276
|
+
# "sum" => 1500.0,
|
1277
|
+
# "avg" => 750.0
|
1278
|
+
# }
|
1279
|
+
|
1280
|
+
* A DSL off the criteria API is now provided for map/reduce operations
|
1281
|
+
as a convenience.
|
1282
|
+
|
1283
|
+
Band.where(name: "Tool").map_reduce(map, reduce).out(inline: 1)
|
1284
|
+
Band.map_reduce(map, reduce).out(replace: "coll-name")
|
1285
|
+
Band.map_reduce(map, reduce).out(inline: 1).finalize(finalize)
|
1286
|
+
|
1287
|
+
* Mongoid now uses Origin for its Criteria API. See the Origin repo
|
1288
|
+
and API docs for the documentation.
|
1289
|
+
|
1290
|
+
* \#1861 Mongoid now raises an `AmbiguousRelationship` error when it
|
1291
|
+
cannot determine the inverse of a relation and there are multiple
|
1292
|
+
potential candidates. (Hans Hasselberg)
|
1293
|
+
|
1294
|
+
* You can now perform an explain directly from criteria.
|
1295
|
+
|
1296
|
+
Band.where(name: "Depeche Mode").explain
|
1297
|
+
|
1298
|
+
* \#1856 Push on one to many relations can now be chained.
|
1299
|
+
|
1300
|
+
band.albums.push(undertow).push(aenima)
|
1301
|
+
|
1302
|
+
* \#1842 MultiParameterAttributes now supported aliased fields.
|
1303
|
+
(Anton Orel)
|
1304
|
+
|
1305
|
+
* \#1833 If an embedded document is attempted to be saved with no
|
1306
|
+
parent defined, Mongoid now will raise a `Mongoid::Errors::NoParent`
|
1307
|
+
exception.
|
1308
|
+
|
1309
|
+
* Added an ORM-agnostic way to get the field names
|
1310
|
+
|
1311
|
+
class Band
|
1312
|
+
include Mongoid::Document
|
1313
|
+
field :name, type: String
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
Band.attribute_names
|
1317
|
+
|
1318
|
+
* \#1831 `find_or_create_by` on relations now takes mass assignment
|
1319
|
+
and type options. (Tatsuya Ono)
|
1320
|
+
|
1321
|
+
class Band
|
1322
|
+
include Mongoid::Document
|
1323
|
+
embeds_many :albums
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
band.albums.find_or_create_by({ name: "101" }, LP)
|
1327
|
+
|
1328
|
+
* \#1818 Add capability to choose the key where your `embeds_many` relation
|
1329
|
+
is stores. (Cyril Mougel)
|
1330
|
+
|
1331
|
+
class User
|
1332
|
+
include Mongoid::Document
|
1333
|
+
field :name, type: String
|
1334
|
+
embeds_many :prefs, class_name: "Preference", store_as: 'my_preferences'
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
user.prefs.build(value: "ok")
|
1338
|
+
user.save
|
1339
|
+
# document saves in MongoDB as:
|
1340
|
+
# { "name" => "foo", "my_preferences" => [{ "value" => "ok" }]}
|
1341
|
+
|
1342
|
+
* \#1806 `Model.find_or_create_by` and `Model.find_or_initialize_by` can now
|
1343
|
+
take documents as paramters for belongs_to relations.
|
1344
|
+
|
1345
|
+
person = Person.first
|
1346
|
+
Game.find_or_create_by(person: person)
|
1347
|
+
|
1348
|
+
* \#1774 Relations now have a :restrict option for dependent relations
|
1349
|
+
which will raise an error when attempting to delete a parent that
|
1350
|
+
still has children on it. (Hans Hasselberg)
|
1351
|
+
|
1352
|
+
class Band
|
1353
|
+
include Mongoid::Document
|
1354
|
+
has_many :albums, dependent: :restrict
|
1355
|
+
end
|
1356
|
+
|
1357
|
+
band = Band.first
|
1358
|
+
band.albums << Albums.first
|
1359
|
+
band.delete # Raises DeleteRestriction error.
|
1360
|
+
|
1361
|
+
* \#1764 Add method to check if field differs from the default value.
|
1362
|
+
|
1363
|
+
class Band
|
1364
|
+
include Mongoid::Document
|
1365
|
+
field :name, type: String, default: "New"
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
band = Band.first
|
1369
|
+
band.name_changed_from_default?
|
1370
|
+
|
1371
|
+
* \#1759 Invalid fields error messages have been updated to show the
|
1372
|
+
source and location of the original method. The new message is:
|
1373
|
+
|
1374
|
+
Problem:
|
1375
|
+
Defining a field named 'crazy_method' is not allowed.
|
1376
|
+
Summary:
|
1377
|
+
Defining this field would override the method 'crazy_method',
|
1378
|
+
which would cause issues with expectations around the original
|
1379
|
+
method and cause extremely hard to debug issues.
|
1380
|
+
The original method was defined in:
|
1381
|
+
Object: MyModule
|
1382
|
+
File: /path/to/my/module.rb
|
1383
|
+
Line: 8
|
1384
|
+
Resolution:
|
1385
|
+
Use Mongoid.destructive_fields to see what names are
|
1386
|
+
not allowed, and don't use these names. These include names
|
1387
|
+
that also conflict with core Ruby methods on Object, Module,
|
1388
|
+
Enumerable, or included gems that inject methods into these
|
1389
|
+
or Mongoid internals.
|
1390
|
+
|
1391
|
+
* \#1753/#1649 A setter and getter for has_many relations to set its
|
1392
|
+
children is now provided. (Piotr Jakubowski)
|
1393
|
+
|
1394
|
+
class Album
|
1395
|
+
include Mongoid::Document
|
1396
|
+
has_many :engineers
|
1397
|
+
end
|
1398
|
+
|
1399
|
+
class Engineer
|
1400
|
+
include Mongoid::Document
|
1401
|
+
belongs_to :album
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
album = Album.first
|
1405
|
+
engineer = Engineer.first
|
1406
|
+
album.engineer_ids = [ engineer.id ]
|
1407
|
+
album.engineer_ids # Returns the ids of the engineers.
|
1408
|
+
|
1409
|
+
* \#1741 Mongoid now provides a rake task to force remove indexes for
|
1410
|
+
environments where Mongoid manages the index definitions and the
|
1411
|
+
removal should be automated. (Hans Hasselberg)
|
1412
|
+
|
1413
|
+
rake db:force_remove_indexes
|
1414
|
+
rake db:mongoid:force_remove_indexes
|
1415
|
+
|
1416
|
+
* \#1726 `Mongoid.load!` now accepts an optional second argument for the
|
1417
|
+
environment to load. This takes precedence over any environment variable
|
1418
|
+
that is set if provided.
|
1419
|
+
|
1420
|
+
Mongoid.load!("/path/to/mongoid.yml", :development)
|
1421
|
+
|
1422
|
+
* \#1724 Mongoid now supports regex fields.
|
1423
|
+
|
1424
|
+
class Rule
|
1425
|
+
include Mongoid::Document
|
1426
|
+
field :pattern, type: Regexp, default: /[^abc]/
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
* \#1714/\#1706 Added better logging on index creation. (Hans Hasselberg)
|
1430
|
+
|
1431
|
+
When an index is present on a root document model:
|
1432
|
+
|
1433
|
+
Creating indexes on: Model for: name, dob.
|
1434
|
+
|
1435
|
+
When an index is defined on an embedded model:
|
1436
|
+
|
1437
|
+
Index ignored on: Address, please define in the root model.
|
1438
|
+
|
1439
|
+
When no index is defined, nothing is logged, and if a bad index is
|
1440
|
+
defined an error is raised.
|
1441
|
+
|
1442
|
+
* \#1710 For cases when you don't want Mongoid to auto-protect the id
|
1443
|
+
and type attributes, you can set a configuration option to turn this
|
1444
|
+
off.
|
1445
|
+
|
1446
|
+
Mongoid.protect_sensitive_fields = false
|
1447
|
+
|
1448
|
+
* \#1685 Belongs to relations now have build_ and create_ methods.
|
1449
|
+
|
1450
|
+
class Comment
|
1451
|
+
include Mongoid::Document
|
1452
|
+
belongs_to :user
|
1453
|
+
end
|
1454
|
+
|
1455
|
+
comment = Comment.new
|
1456
|
+
comment.build_user # Build a new user object
|
1457
|
+
comment.create_user # Create a new user object
|
1458
|
+
|
1459
|
+
* \#1684 Raise a `Mongoid::Errors::InverseNotFound` when attempting to
|
1460
|
+
set a child on a relation without the proper inverse_of definitions
|
1461
|
+
due to Mongoid not being able to determine it.
|
1462
|
+
|
1463
|
+
class Lush
|
1464
|
+
include Mongoid::Document
|
1465
|
+
embeds_one :whiskey, class_name: "Drink"
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
class Drink
|
1469
|
+
include Mongoid::Document
|
1470
|
+
embedded_in :alcoholic, class_name: "Lush"
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
lush = Lush.new
|
1474
|
+
lush.whiskey = Drink.new # raises an InverseNotFound error.
|
1475
|
+
|
1476
|
+
* \#1680 Polymorphic relations now use `*_type` keys in lookup queries.
|
1477
|
+
|
1478
|
+
class User
|
1479
|
+
include Mongoid::Document
|
1480
|
+
has_many :comments, as: :commentable
|
1481
|
+
end
|
1482
|
+
|
1483
|
+
class Comment
|
1484
|
+
include Mongoid::Document
|
1485
|
+
belongs_to :commentable, polymorphic: true
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
user = User.find(id)
|
1489
|
+
user.comments # Uses user.id and type "User" in the query.
|
1490
|
+
|
1491
|
+
* \#1677 Support for parent separable polymorphic relations to the same
|
1492
|
+
parent class is now available. This only works if set from the parent
|
1493
|
+
side in order to know which relation the children belong to.
|
1494
|
+
(Douwe Maan)
|
1495
|
+
|
1496
|
+
class Face
|
1497
|
+
include Mongoid::Document
|
1498
|
+
has_one :left_eye, class_name: "Eye", as: :visible
|
1499
|
+
has_one :right_eye, class_name: "Eye", as: :visible
|
1500
|
+
end
|
1501
|
+
|
1502
|
+
class Eye
|
1503
|
+
include Mongoid::Document
|
1504
|
+
belongs_to :visible, polymorphic: true
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
face = Face.new
|
1508
|
+
right_eye = Eye.new
|
1509
|
+
left_eye = Eye.new
|
1510
|
+
face.right_eye = right_eye
|
1511
|
+
face.left_eye = left_eye
|
1512
|
+
right_eye.visible = face # Will raise an error.
|
1513
|
+
|
1514
|
+
* \#1650 Objects that respond to `to_criteria` can now be merged into
|
1515
|
+
existing criteria objects.
|
1516
|
+
|
1517
|
+
class Filter
|
1518
|
+
def to_criteria
|
1519
|
+
# return a Criteria object.
|
1520
|
+
end
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
criteria = Person.where(title: "Sir")
|
1524
|
+
criteria.merge(filter)
|
1525
|
+
|
1526
|
+
* \#1635 All exceptions now provide more comprehensive errors, including
|
1527
|
+
the problem that occured, a detail summary of why it happened, and
|
1528
|
+
potential resolutions. Example:
|
1529
|
+
|
1530
|
+
(Mongoid::Errors::DocumentNotFound)
|
1531
|
+
Problem:
|
1532
|
+
Document not found for class Town with
|
1533
|
+
id(s) [BSON::ObjectId('4f35781b8ad54812e1000001')].
|
1534
|
+
Summary:
|
1535
|
+
When calling Town.find with an id or array of ids,
|
1536
|
+
each parameter must match a document in the database
|
1537
|
+
or this error will be raised.
|
1538
|
+
Resolution:
|
1539
|
+
Search for an id that is in the database or set the
|
1540
|
+
Mongoid.raise_not_found_error configuration option to
|
1541
|
+
false, which will cause a nil to be returned instead
|
1542
|
+
of raising this error.
|
1543
|
+
|
1544
|
+
* \#1616 `Model.find_by` added which takes a hash of arugments to search
|
1545
|
+
for in the database. If no single document is returned a DocumentNotFound
|
1546
|
+
error is raised. (Piotr Jakubowski)
|
1547
|
+
|
1548
|
+
Band.find_by(name: "Depeche Mode")
|
1549
|
+
|
1550
|
+
* \#1606 Mongoid now enables autosave, like Active Record, when adding
|
1551
|
+
an accepts_nested_attributes_for to a relation.
|
1552
|
+
|
1553
|
+
class Band
|
1554
|
+
include Mongoid::Document
|
1555
|
+
has_many :albums
|
1556
|
+
accepts_nested_attributes_for :albums # This enables the autosave.
|
1557
|
+
end
|
1558
|
+
|
1559
|
+
* \#1477 Mongoid now automatically protects the id and type attributes
|
1560
|
+
from mass assignment. You can override this (not recommended) by redefining
|
1561
|
+
them as accessible.
|
1562
|
+
|
1563
|
+
class Band
|
1564
|
+
include Mongoid::Document
|
1565
|
+
attr_accessible :id, :_id, :_type
|
1566
|
+
end
|
1567
|
+
|
1568
|
+
* \#1459 The identity map can be disabled now for specific code execution
|
1569
|
+
by passing options to the unit of work.
|
1570
|
+
|
1571
|
+
Mongoid.unit_of_work(disable: :all) do
|
1572
|
+
# Disables the identity map on all threads for the block.
|
1573
|
+
end
|
1574
|
+
|
1575
|
+
Mongoid.unit_of_work(disable: :current) do
|
1576
|
+
# Disables the identity map on the current thread for the block.
|
1577
|
+
end
|
1578
|
+
|
1579
|
+
Mongoid.unit_of_work do
|
1580
|
+
# Business as usual.
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
* \#1355 Associations now can have safety options provided to them on single
|
1584
|
+
document persistence operations.
|
1585
|
+
|
1586
|
+
band.albums.with(safe: true).push(album)
|
1587
|
+
band.albums.with(safe: true).create(name: "Smiths")
|
1588
|
+
|
1589
|
+
album.with(safe: true).create_producer(name: "Flood")
|
1590
|
+
|
1591
|
+
* \#1348 Eager loading is now supported on many-to-many relations.
|
1592
|
+
|
1593
|
+
* \#1292 Remove attribute now unsets the attribute when the document is
|
1594
|
+
saved instead of setting to nil.
|
1595
|
+
|
1596
|
+
band = Band.find(id)
|
1597
|
+
band.remove_attribute(:label) # Uses $unset when the document is saved.
|
1598
|
+
|
1599
|
+
* \#1291 Mongoid database sessions are now connected to lazily, and are
|
1600
|
+
completely thread safe. If a new thread is created, then a new database
|
1601
|
+
session will be created for it.
|
1602
|
+
|
1603
|
+
* \#1291 Mongoid now supports any number of database connections as defined in
|
1604
|
+
the mongoid.yml. For example you could have a local single server db, a
|
1605
|
+
multi availablity zone replica set, and a shard cluster all in the same
|
1606
|
+
application environment. Mongoid can connect to any session at any point in
|
1607
|
+
time.
|
1608
|
+
|
1609
|
+
* \#1291 Mongoid now allows you to persist to whatever database or collection
|
1610
|
+
you like at runtime, on a per-query or persistence operation basis by using
|
1611
|
+
`with`.
|
1612
|
+
|
1613
|
+
Band.with(collection: "artists").create(name: "Depeche Mode")
|
1614
|
+
band.with(database: "secondary).save!
|
1615
|
+
Band.with(collection: "artists").where(name: "Depeche Mode")
|
1616
|
+
|
1617
|
+
* \#1291 You can now configure on a per-model basis where its documents are
|
1618
|
+
stored with the new and improved `store_in` macro.
|
1619
|
+
|
1620
|
+
class Band
|
1621
|
+
include Mongoid::Document
|
1622
|
+
store_in collection: "artists", database: "secondary", session: "replica"
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
This can be overridden, of course, at runtime via the `with` method.
|
1626
|
+
|
1627
|
+
* \#1212 Embedded documents can now be popped off a relation with persistence.
|
1628
|
+
|
1629
|
+
band.albums.pop # Pop 1 document and persist the removal.
|
1630
|
+
band.albums.pop(3) # Pop 3 documents and persist the removal.
|
1631
|
+
|
1632
|
+
* \#1188 Relations now have existence predicates for simplified checking if the
|
1633
|
+
relation is blank or not. (Andy Morris)
|
1634
|
+
|
1635
|
+
class Band
|
1636
|
+
include Mongoid::Document
|
1637
|
+
embeds_many :albums
|
1638
|
+
embeds_one :label
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
band = Band.new
|
1642
|
+
band.albums?
|
1643
|
+
band.has_albums?
|
1644
|
+
band.label?
|
1645
|
+
band.has_label?
|
1646
|
+
|
1647
|
+
* \#1188 1-1 relations now have an :autobuild option to indicate if the
|
1648
|
+
relation should automatically be build with empty attributes upon access
|
1649
|
+
where the relation currently does not exist. Works on embeds_one,
|
1650
|
+
embedded_in, has_one, belongs_to. (Andy Morris)
|
1651
|
+
|
1652
|
+
class Band
|
1653
|
+
include Mongoid::Document
|
1654
|
+
has_one :label, autobuild: true
|
1655
|
+
end
|
1656
|
+
|
1657
|
+
band = Band.new
|
1658
|
+
band.label # Returns a new label with empty attributes.
|
1659
|
+
|
1660
|
+
When using existence checks, autobuilding will not execute.
|
1661
|
+
|
1662
|
+
band = Band.new
|
1663
|
+
band.label? # Returns false, does not autobuild on a check.
|
1664
|
+
band.has_label? # Returns false, does not autobuild on a check.
|
1665
|
+
|
1666
|
+
* \#1081 Mongoid indexes both id and type as a compound index when providing
|
1667
|
+
`index: true` to a polymorphic belongs_to.
|
1668
|
+
|
1669
|
+
class Comment
|
1670
|
+
include Mongoid::Document
|
1671
|
+
|
1672
|
+
# Indexes commentable_id and commentable_type as a compound index.
|
1673
|
+
belongs_to :commentable, polymorphic: true, index: true
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
* \#1053 Raise a `Mongoid::Errors::UnknownAttribute` instead of no method
|
1677
|
+
when attempting to set a field that is not defined and allow dynamic
|
1678
|
+
fields is false. (Cyril Mougel)
|
1679
|
+
|
1680
|
+
Mongoid.allow_dynamic_fields = false
|
1681
|
+
|
1682
|
+
class Person
|
1683
|
+
include Mongoid::Document
|
1684
|
+
field :title, type: String
|
1685
|
+
end
|
1686
|
+
|
1687
|
+
Person.new.age = 50 # raises the UnknownAttribute error.
|
1688
|
+
|
1689
|
+
* \#772 Fields can now be flagged as readonly, which will only let their
|
1690
|
+
values be set when the document is new.
|
1691
|
+
|
1692
|
+
class Band
|
1693
|
+
include Mongoid::Document
|
1694
|
+
field :name, type: String
|
1695
|
+
field :genre, type: String
|
1696
|
+
|
1697
|
+
attr_readonly :name, :genre
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
Readonly values are ignored when attempting to set them on persisted
|
1701
|
+
documents, with the exception of update_attribute and remove_attribute,
|
1702
|
+
where errors will get raised.
|
1703
|
+
|
1704
|
+
band = Band.create(name: "Depeche Mode")
|
1705
|
+
band.update_attribute(:name, "Smiths") # Raises ReadonlyAttribute error.
|
1706
|
+
band.remove_attribute(:name) # Raises ReadonlyAttribute error.
|
1707
|
+
|
1708
|
+
|
1709
|
+
### Major Changes (Backwards Incompatible)
|
1710
|
+
|
1711
|
+
* Polymorphic relations can not have ids other than object ids. This is
|
1712
|
+
because Mongoid cannot properly figure out in an optimized way what the
|
1713
|
+
various classes on the other side of the relation store their ids as, as
|
1714
|
+
they could potentially all be different.
|
1715
|
+
|
1716
|
+
This was not allowed before, but nowhere was it explicitly stated.
|
1717
|
+
|
1718
|
+
* \#2039 Validating presence of a relation now checks both the relation and
|
1719
|
+
the foreign key value.
|
1720
|
+
|
1721
|
+
* Indexing syntax has changed. The first parameter is now a hash of
|
1722
|
+
name/direction pairs with an optional second hash parameter for
|
1723
|
+
additional options.
|
1724
|
+
|
1725
|
+
Normal indexing with options, directions are either 1 or -1:
|
1726
|
+
|
1727
|
+
class Band
|
1728
|
+
include Mongoid::Document
|
1729
|
+
field :name, type: String
|
1730
|
+
|
1731
|
+
index({ name: 1 }, { unique: true, background: true })
|
1732
|
+
end
|
1733
|
+
|
1734
|
+
Geospacial indexing needs "2d" as its direction.
|
1735
|
+
|
1736
|
+
class Venue
|
1737
|
+
include Mongoid::Document
|
1738
|
+
field :location, type: Array
|
1739
|
+
|
1740
|
+
index location: "2d"
|
1741
|
+
end
|
1742
|
+
|
1743
|
+
* Custom serializable fields have revamped. Your object no longer should
|
1744
|
+
include `Mongoid::Fields::Serializable` - instead it only needs to
|
1745
|
+
implement 3 methods: `#mongoize`, `.demongoize` and `.evolve`.
|
1746
|
+
|
1747
|
+
`#mongoize` is an instance method that transforms your object into
|
1748
|
+
a mongo-friendly value.
|
1749
|
+
|
1750
|
+
`.demongoize` is a class method, that can take some data from mongo
|
1751
|
+
and instantiate and object of your custom type.
|
1752
|
+
|
1753
|
+
`.evolve` is a class method, that can take any object, and
|
1754
|
+
transform it for use in a `Mongoid::Criteria`.
|
1755
|
+
|
1756
|
+
An example of an implementation of this for `Range`:
|
1757
|
+
|
1758
|
+
class Range
|
1759
|
+
|
1760
|
+
def mongoize
|
1761
|
+
{ "min" => first, "max" => last }
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
class << self
|
1765
|
+
|
1766
|
+
def demongoize(object)
|
1767
|
+
Range.new(object["min"], object["max"])
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
def evolve(object)
|
1771
|
+
{ "$gte" => object.first, "$lte" => object.last }
|
1772
|
+
end
|
1773
|
+
end
|
1774
|
+
end
|
1775
|
+
|
1776
|
+
* `Document#changes` is no longer a hash with indifferent access.
|
1777
|
+
|
1778
|
+
* `after_initialize` callbacks no longer cascade to children if the option
|
1779
|
+
is set.
|
1780
|
+
|
1781
|
+
* \#1865 `count` on the memory and mongo contexts now behave exactly the
|
1782
|
+
same as Ruby's `count` on enumerable, and can take an object or a block.
|
1783
|
+
This is optimized on the mongo context not to load everything in memory
|
1784
|
+
with the exception of passing a block.
|
1785
|
+
|
1786
|
+
Band.where(name: "Tool").count
|
1787
|
+
Band.where(name: "Tool").count(tool) # redundant.
|
1788
|
+
Band.where(name: "Tool") do |doc|
|
1789
|
+
doc.likes > 0
|
1790
|
+
end
|
1791
|
+
|
1792
|
+
Note that although the signatures are the same for both the memory and
|
1793
|
+
mongo contexts, it's recommended you only use the block syntax for the
|
1794
|
+
memory context since the embedded documents are already loaded into
|
1795
|
+
memory.
|
1796
|
+
|
1797
|
+
Also note that passing a boolean to take skip and limit into account
|
1798
|
+
is no longer supported, as this is not necessarily a useful feature.
|
1799
|
+
|
1800
|
+
* The `autocreate_indexes` configuration option has been removed.
|
1801
|
+
|
1802
|
+
* `Model.defaults` no longer exists. You may get all defaults with a
|
1803
|
+
combination of `Model.pre_processed_defaults` and
|
1804
|
+
`Model.post_processed_defaults`.
|
1805
|
+
|
1806
|
+
Band.pre_processed_defaults
|
1807
|
+
Band.post_processed_defaults
|
1808
|
+
|
1809
|
+
* `Model.identity` and `Model.key` have been removed. For custom ids,
|
1810
|
+
users must now override the _id field.
|
1811
|
+
|
1812
|
+
When the default value is a proc, the default is applied *after* all
|
1813
|
+
other attributes are set.
|
1814
|
+
|
1815
|
+
class Band
|
1816
|
+
include Mongoid::Document
|
1817
|
+
field :_id, type: String, default: ->{ name }
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
To have the default applied *before* other attributes, set `:pre_processed`
|
1821
|
+
to true.
|
1822
|
+
|
1823
|
+
class Band
|
1824
|
+
include Mongoid::Document
|
1825
|
+
field :_id,
|
1826
|
+
type: String,
|
1827
|
+
pre_processed: true,
|
1828
|
+
default: ->{ BSON::ObjectId.new.to_s }
|
1829
|
+
end
|
1830
|
+
|
1831
|
+
* Custom application exceptions in various languages has been removed,
|
1832
|
+
along with the `Mongoid.add_language` feature.
|
1833
|
+
|
1834
|
+
* Mongoid no longer supports 1.8. MRI 1.9.3 and higher, or JRuby 1.6 and
|
1835
|
+
higher in 1.9 mode are only supported.
|
1836
|
+
|
1837
|
+
* \#1734 When searching for documents via `Model.find` with multiple ids,
|
1838
|
+
Mongoid will raise an error if not *all* ids are found, and tell you
|
1839
|
+
what the missing ones were. Previously the error only got raised if
|
1840
|
+
nothing was returned.
|
1841
|
+
|
1842
|
+
* \#1675 Adding presence validation on a relation now enables autosave.
|
1843
|
+
This is to ensure that when a new parent object is saved with a new
|
1844
|
+
child and marked is valid, both are persisted to ensure a correct
|
1845
|
+
state in the database.
|
1846
|
+
|
1847
|
+
* \#1491 Ensure empty translations returns an empty hash on access.
|
1848
|
+
|
1849
|
+
* \#1484 `Model#has_attribute?` now behaves the same as Active Record.
|
1850
|
+
|
1851
|
+
* \#1471 Mongoid no longer strips any level of precision off of times.
|
1852
|
+
|
1853
|
+
* \#1475 Active support's time zone is now used by default in time
|
1854
|
+
serialization if it is defined.
|
1855
|
+
|
1856
|
+
* \#1342 `Model.find` and `model.relation.find` now only take a single or
|
1857
|
+
multiple ids. The first/last/all with a conditions hash has been removed.
|
1858
|
+
|
1859
|
+
* \#1291 The mongoid.yml has been revamped completely, and upgrading
|
1860
|
+
existing applications will greet you with some lovely Mongoid specific
|
1861
|
+
configuration errors. You can re-generate a new mongoid.yml via the
|
1862
|
+
existing rake task, which is commented to an insane degree to help you
|
1863
|
+
with all the configuration possibilities.
|
1864
|
+
|
1865
|
+
* \#1291 The `persist_in_safe_mode` configuration option has been removed.
|
1866
|
+
You must now tell a database session in the mongoid.yml whether or not
|
1867
|
+
it should persist in safe mode by default.
|
1868
|
+
|
1869
|
+
production:
|
1870
|
+
sessions:
|
1871
|
+
default:
|
1872
|
+
database: my_app_prod
|
1873
|
+
hosts:
|
1874
|
+
- db.app.com:27018
|
1875
|
+
- db.app.com:27019
|
1876
|
+
options:
|
1877
|
+
consistency: :eventual
|
1878
|
+
safe: true
|
1879
|
+
|
1880
|
+
* \#1291 `safely` and `unsafely` have been removed. Please now use `with`
|
1881
|
+
to provide safe mode options at runtime.
|
1882
|
+
|
1883
|
+
Band.with(safe: true).create
|
1884
|
+
band.with(safe: { w: 3 }).save!
|
1885
|
+
Band.with(safe: false).create!
|
1886
|
+
|
1887
|
+
* \#1270 Relation macros have been changed to match their AR counterparts:
|
1888
|
+
only :has_one, :has_many, :has_and_belongs_to_many, and :belongs_to
|
1889
|
+
exist now.
|
1890
|
+
|
1891
|
+
* \#1268 `Model#new?` has been removed, developers must now always use
|
1892
|
+
`Model#new_record?`.
|
1893
|
+
|
1894
|
+
* \#1182 A reload is no longer required to refresh a relation after setting
|
1895
|
+
the value of the foreign key field for it. Note this behaves exactly as
|
1896
|
+
Active Record.
|
1897
|
+
|
1898
|
+
If the id is set, but the document for it has not been persisted, accessing
|
1899
|
+
the relation will return empty results.
|
1900
|
+
|
1901
|
+
If the id is set and its document is persisted, accessing the relation
|
1902
|
+
will return the document.
|
1903
|
+
|
1904
|
+
If the id is set, but the base document is not saved afterwards, then
|
1905
|
+
reloading will return the document to its original state.
|
1906
|
+
|
1907
|
+
* \#1093 Field serialization strategies have changed on Array, Hash, Integer
|
1908
|
+
and Boolean to be more consistent and match AR where appropriate.
|
1909
|
+
|
1910
|
+
Serialization of arrays calls `Array.wrap(object)`
|
1911
|
+
Serialization of hashes calls `Hash[object]` (to_hash on the object)
|
1912
|
+
Serialization of integers always returns an int via `to_i`
|
1913
|
+
Serialization of booleans defaults to false instead of nil.
|
1914
|
+
|
1915
|
+
* \#933 `:field.size` has been renamed to `:field.count` in criteria for
|
1916
|
+
$size not to conflict with Symbol's size method.
|
1917
|
+
|
1918
|
+
* \#829/\#797 Mongoid scoping code has been completely rewritten, and now
|
1919
|
+
matches the Active Record API. With this backwards incompatible change,
|
1920
|
+
some methods have been removed or renamed.
|
1921
|
+
|
1922
|
+
Criteria#as_conditions and Criteria#fuse no longer exist.
|
1923
|
+
|
1924
|
+
Criteria#merge now only accepts another object that responds to
|
1925
|
+
`to_criteria`.
|
1926
|
+
|
1927
|
+
Criteria#merge! now merges in another object without creating a new
|
1928
|
+
criteria object.
|
1929
|
+
|
1930
|
+
Band.where(name: "Tool").merge!(criteria)
|
1931
|
+
|
1932
|
+
Named scopes and default scopes no longer take hashes as parameters.
|
1933
|
+
From now on only criteria and procs wrapping criteria will be
|
1934
|
+
accepted, and an error will be raised if the arguments are incorrect.
|
1935
|
+
|
1936
|
+
class Band
|
1937
|
+
include Mongoid::Document
|
1938
|
+
|
1939
|
+
default_scope ->{ where(active: true) }
|
1940
|
+
scope :inactive, where(active: false)
|
1941
|
+
scope :invalid, where: { valid: false } # This will raise an error.
|
1942
|
+
end
|
1943
|
+
|
1944
|
+
The 'named_scope' macro has been removed, from now on only use 'scope'.
|
1945
|
+
|
1946
|
+
Model.unscoped now accepts a block which will not allow default scoping
|
1947
|
+
to be applied for any calls inside the block.
|
1948
|
+
|
1949
|
+
Band.unscoped do
|
1950
|
+
Band.scoped.where(name: "Ministry")
|
1951
|
+
end
|
1952
|
+
|
1953
|
+
Model.scoped now takes options that will be set directly on the criteria
|
1954
|
+
options hash.
|
1955
|
+
|
1956
|
+
Band.scoped(skip: 10, limit: 20)
|
1957
|
+
|
1958
|
+
* \#463 `Document#upsert` is no longer aliased to `Document#save` and now
|
1959
|
+
actually performs a proper MongoDB upsert command when called. If you
|
1960
|
+
were using this method before and want the same behaviour, please switch
|
1961
|
+
to `save`.
|
1962
|
+
|
1963
|
+
band = Band.new(name: "Tool")
|
1964
|
+
band.upsert #=> Inserts the document in the database.
|
1965
|
+
band.name = "Placebo"
|
1966
|
+
band.upsert #=> Updates the existing document.
|
1967
|
+
|
1968
|
+
### Resolved Issues
|
1969
|
+
|
1970
|
+
* \#2166 `Criteria#from_map_or_db` strips type selection when eager loading
|
1971
|
+
since it will check if the type is correct after.
|
1972
|
+
|
1973
|
+
* \#2129 Fixed sorting for all fields on embeds many relations.
|
1974
|
+
|
1975
|
+
* \#2124 Fixed default scope and deleted scope on paranoid documents.
|
1976
|
+
|
1977
|
+
* \#2122 Allow embedded documents to sort on boolean fields.
|
1978
|
+
|
1979
|
+
* \#2119 Allow `Criteria#update_all` to accept atomic ops and normal sets.
|
1980
|
+
|
1981
|
+
* \#2118 Don't strip any precision during `DateTime` -> `Time` conversions.
|
1982
|
+
|
1983
|
+
* \#2117 Ensure embeds one relations have callbacks run when using nested
|
1984
|
+
attributes.
|
1985
|
+
|
1986
|
+
* \#2110 `Model#touch` now works properly on embedded documents.
|
1987
|
+
|
1988
|
+
* \#2100 Allow atomic operations to properly execute on paranoid documents
|
1989
|
+
that have a deleted_at set.
|
1990
|
+
|
1991
|
+
* \#2089 Allow proper separation of mongoization and evolving with respect to
|
1992
|
+
foreign keys.
|
1993
|
+
|
1994
|
+
* \#2088 Allow finds by string ids to pull from the identity map if the ids
|
1995
|
+
are stored as object ids.
|
1996
|
+
|
1997
|
+
* \#2085 Allow demongoization of floats and ints to big decimals.
|
1998
|
+
|
1999
|
+
* \#2084 Don't cascade if metadata does not exist.
|
2000
|
+
|
2001
|
+
* \#2078 Calling `Model#clone` or `Model#dup` now properly sets attributes
|
2002
|
+
as dirty.
|
2003
|
+
|
2004
|
+
* \#2070 Allow for updated_at to be overridden manually for new documents that
|
2005
|
+
also have a created_at.
|
2006
|
+
|
2007
|
+
* \#2041 Don't hit the database multiple times on relation access after an
|
2008
|
+
eager load returned zero documents.
|
2009
|
+
|
2010
|
+
* \#1997 Cascading callbacks should be able to halt the callback chain when
|
2011
|
+
terminating.
|
2012
|
+
|
2013
|
+
* \#1972 `added`, `loaded`, and `unloaded` can now be valid scope names on a
|
2014
|
+
document that is part of a 1-n relation.
|
2015
|
+
|
2016
|
+
* \#1952/#1950 `#all_in` behaviour on embedded documents now properly matches
|
2017
|
+
root documents when passing an empty array. (Hans Hasselberg)
|
2018
|
+
|
2019
|
+
* \#1941/#1939 `Model.find_by` now returns nil if raise not found error is
|
2020
|
+
set to false. (Hans Hasselberg)
|
2021
|
+
|
2022
|
+
* \#1859/#1860 `Model#remove_attribute` now properly unsets on embedded
|
2023
|
+
documents. (Anton Onyshchenko)
|
2024
|
+
|
2025
|
+
* \#1852 Ensure no infinite recursion on cascading callbacks. (Ara Howard)
|
2026
|
+
|
2027
|
+
* \#1823 `Relation#includes?` now properly works with identity map enabled.
|
2028
|
+
|
2029
|
+
* \#1810 `Model#changed?` no longer returns true when hash and array fields
|
2030
|
+
have only been accessed.
|
2031
|
+
|
2032
|
+
* \#1876/\#1782 Allow dot notation in embeds many criteria queries.
|
2033
|
+
(Cyril Mougel)
|
2034
|
+
|
2035
|
+
* \#1745 Fixed batch clear to work within attribute setting.
|
2036
|
+
|
2037
|
+
* \#1718 Ensure consistency of #first/#last in relations - they now always
|
2038
|
+
match first/last in the database, but opts for in memory first.
|
2039
|
+
|
2040
|
+
* \#1692/\#1376 `Model#updateattributes` and `Model#update_attributes!` now
|
2041
|
+
accept assignment options. (Hans Hasselberg)
|
2042
|
+
|
2043
|
+
* \#1688/\#1207 Don't require namespacing when providing class name on
|
2044
|
+
relation macros inside the namespace. (Hans Hasselberg)
|
2045
|
+
|
2046
|
+
* \#1665/\#1672 Expand complex criteria in nested criteria selectors, like
|
2047
|
+
\#matches. (Hans Hasselberg)
|
2048
|
+
|
2049
|
+
* \#1335 Don't add id sorting criteria to first/last is there is already
|
2050
|
+
sorting options on the criteria.
|
2051
|
+
|
2052
|
+
* \#1321 Referenced many enumerable targets are now hash-backed, preventing
|
2053
|
+
duplicates in a more efficient manner.
|
2054
|
+
|
2055
|
+
* \#1135 DateTimes now properly get time zones on deserialization.
|
2056
|
+
|
2057
|
+
* \#1031 Mongoid now serializes values in Array fields to their proper
|
2058
|
+
Mongo-friendly values when possible.
|
2059
|
+
|
2060
|
+
* \#685 Attempting to use versioning with embedded documents will now
|
2061
|
+
raise a proper error alerting the developer this is not allowed.
|
2062
|
+
|
2063
|
+
## 2.6.0
|
2064
|
+
|
2065
|
+
### New Features
|
2066
|
+
|
2067
|
+
* \#2709 Backported the `touch` functionality from Mongoid 3.
|
2068
|
+
|
2069
|
+
## 2.5.2
|
2070
|
+
|
2071
|
+
### Resolved Issues
|
2072
|
+
|
2073
|
+
* \#2502 Fixed cache key to properly handle when the document does not
|
2074
|
+
include `Mongoid::Timestamps::Updated`. (Arthur Nogueira Neves)
|
2075
|
+
|
2076
|
+
## 2.5.1
|
2077
|
+
|
2078
|
+
### Resolved Issues
|
2079
|
+
|
2080
|
+
* \#2492 Backport cascading callbacks performance and memory fixes from
|
2081
|
+
3.0.0-stable.
|
2082
|
+
|
2083
|
+
* \#2464 Backport the nested attributes fix for keeping many relations in
|
2084
|
+
memory when updating attributes. (Chris Thompson)
|
2085
|
+
|
2086
|
+
## 2.5.0
|
2087
|
+
|
2088
|
+
### New Features
|
2089
|
+
|
2090
|
+
* This is a release to support the 1.7.0 and higher Mongo and BSON gems and
|
2091
|
+
resolves issues that kept the 2.4.x series locked below 1.6.2
|
2092
|
+
|
2093
|
+
## 2.4.12
|
2094
|
+
|
2095
|
+
### Resolved Issues
|
2096
|
+
|
2097
|
+
* \#2178 Ensure destroy callbacks are run post replacement of an embeds one
|
2098
|
+
relation.
|
2099
|
+
|
2100
|
+
* \#2169 Allow saves to pass when documents are destroyed after the save
|
2101
|
+
in a callback.
|
2102
|
+
|
2103
|
+
* \#2144 Uniqueness validation on paranoid documents now properly scopes.
|
2104
|
+
|
2105
|
+
* \#2127 Don't unbind parents of embedded documents mid nested
|
2106
|
+
attributes deletion.
|
2107
|
+
|
2108
|
+
## 2.4.11
|
2109
|
+
|
2110
|
+
### Resolved Issues
|
2111
|
+
|
2112
|
+
* This release forces a cap on the mongo driver version at 1.6.2 due to
|
2113
|
+
changes in the `Mongo::Connection.from_uri` API not allowing valid
|
2114
|
+
connection options anymore.
|
2115
|
+
|
2116
|
+
* \#2040 Fixed bad interpolation for locale presence validation.
|
2117
|
+
|
2118
|
+
* \#2038 Allow inverse relations to be determined by foreign keys alone
|
2119
|
+
if defined on both sides, not just an inverse_of declaration.
|
2120
|
+
|
2121
|
+
* \#2023 Allow serilialization of dynamic types that conflict with core
|
2122
|
+
Ruby methods to still be serialized.
|
2123
|
+
|
2124
|
+
* \#2008 Presence validation should hit the db to check validity if the
|
2125
|
+
relation in memory is blank.
|
2126
|
+
|
2127
|
+
* \#2006 Allow excluding only the _id field post execution of an #only call.
|
2128
|
+
|
2129
|
+
## 2.4.10
|
2130
|
+
|
2131
|
+
### Resolved Issues
|
2132
|
+
|
2133
|
+
* \#2003 Don't fail on document generation when an embedded document was
|
2134
|
+
stored as nil in the database.
|
2135
|
+
|
2136
|
+
* \#1997 Don't delete paranoid embedded docs via nested attributes when
|
2137
|
+
a before_destroy callback returns false.
|
2138
|
+
|
2139
|
+
* \#1994 `dependent: :delete` only hits the database once now for one to
|
2140
|
+
many and many to many relations instead of once for each document.
|
2141
|
+
|
2142
|
+
* \#1987 Don't double-insert documents into identity map when eager loading
|
2143
|
+
twice inside the unit of work.
|
2144
|
+
|
2145
|
+
* \#1953 Uniqueness validation now works on localized fields.
|
2146
|
+
|
2147
|
+
* \#1936 Allow setting n levels deep embedded documents atomically without
|
2148
|
+
conflicting mods when not using nested attributes or documents themselves
|
2149
|
+
in an update call from the parent.
|
2150
|
+
|
2151
|
+
* \#1957/\#1954 Ensure database name is set with inheritance.
|
2152
|
+
(Hans Hasselberg)
|
2153
|
+
|
2154
|
+
## 2.4.9
|
2155
|
+
|
2156
|
+
### Resolved Issues
|
2157
|
+
|
2158
|
+
* \#1943 Ensure numericality validation works for big decimals.
|
2159
|
+
|
2160
|
+
* \#1938 Length validation now works with localized fields.
|
2161
|
+
|
2162
|
+
* \#1936 Conflicting pushes with other pushes is now properly handled.
|
2163
|
+
|
2164
|
+
* \#1933 `Proxy#extend` should delegate through to the target, where
|
2165
|
+
extending the proxy itself is now handled through `Proxy#proxy_extend`.
|
2166
|
+
|
2167
|
+
* \#1930 Ensure complex criteria are expanded in all where clauses.
|
2168
|
+
(Hans Hasselberg)
|
2169
|
+
|
2170
|
+
* \#1928 Deletion of embedded documents via nested attributes now performs
|
2171
|
+
a $pull with id match criteria instead of a $pullAll to cover all cases.
|
2172
|
+
Previously newly added defaults to documents that had already persisted
|
2173
|
+
could not be deleted in this matter since the doc did not match what was
|
2174
|
+
in the database.
|
2175
|
+
|
2176
|
+
* \#1924/\#1917 Fix pushing to embedded relations with default scopes not
|
2177
|
+
scoping on the new document. (Hans Hasselberg)
|
2178
|
+
|
2179
|
+
* \#1922/\#1919 Dropping collections unmemoizes the internally wrapped
|
2180
|
+
collection, in order to ensure when defining capped collections that
|
2181
|
+
they are always recreated as capped. (Hans Hasselberg)
|
2182
|
+
|
2183
|
+
* \#1916/\#1913 Uniqueness validation no longer is affected by the default
|
2184
|
+
scope. (Hans Hasselberg)
|
2185
|
+
|
2186
|
+
* \#1943 Ensure numericality validation works for big decimals.
|
2187
|
+
|
2188
|
+
## 2.4.8
|
2189
|
+
|
2190
|
+
### Resolved Issues
|
2191
|
+
|
2192
|
+
* \#1892 When getting not master operation error, Mongoid should reconnect
|
2193
|
+
before retrying the operation.
|
2194
|
+
|
2195
|
+
* \#1887 Don't cascade callbacks to children that don't have the callback
|
2196
|
+
defined.
|
2197
|
+
|
2198
|
+
* \#1882 Don't expand duplicate id criterion into an $and with duplicate
|
2199
|
+
selections.
|
2200
|
+
|
2201
|
+
* \#1878 Fixed default application values not to apply in certain `only`
|
2202
|
+
or `without` selection on iteration, not just `first` and `last`.
|
2203
|
+
|
2204
|
+
* \#1874 Fixed the reject all blank proc constant to handle values
|
2205
|
+
properly with a destroy non blank value. (Stefan Daschek)
|
2206
|
+
|
2207
|
+
* \#1869/\#1868 Delayed atomic sets now uses the atomic path instead of
|
2208
|
+
the metadata name to fix multiple level embedding issues.
|
2209
|
+
(Chris Micacchi provided specs)
|
2210
|
+
|
2211
|
+
* \#1866 Post processed defaults (procs) should be applied post binding
|
2212
|
+
of the child in a relation.build.
|
2213
|
+
|
2214
|
+
## 2.4.7
|
2215
|
+
|
2216
|
+
### Resolved Issues
|
2217
|
+
|
2218
|
+
* Ensure reloading of embedded documents retains reference to the parent.
|
2219
|
+
|
2220
|
+
* \#1837 Always pass symbol options to the driver.
|
2221
|
+
|
2222
|
+
* \#1836 Ensure relation counts pick up persisted document that have not
|
2223
|
+
had the foreign key link persisted.
|
2224
|
+
|
2225
|
+
* \#1820 Destroying embedded documents in an embeds_many should also
|
2226
|
+
removed the document from the underlying _uncoped target and reindex
|
2227
|
+
the relation.
|
2228
|
+
|
2229
|
+
* \#1814 Don't cascade callbacks on after_initialize.
|
2230
|
+
|
2231
|
+
* \#1800 Invalid options for the Mongo connection are now filtered out.
|
2232
|
+
|
2233
|
+
* \#1785 Case equality has been fixed to handle instance checks properly.
|
2234
|
+
|
2235
|
+
## 2.4.6
|
2236
|
+
|
2237
|
+
### Resolved Issues
|
2238
|
+
|
2239
|
+
* \#1772 Allow skip and limit to convert strings to integers. (Jean Boussier)
|
2240
|
+
|
2241
|
+
* \#1767 Model#update_attributes accepts mass assignment options again.
|
2242
|
+
(Hans Hasselberg)
|
2243
|
+
|
2244
|
+
* \#1762 Criteria#any_of now properly handles localized fields.
|
2245
|
+
|
2246
|
+
* \#1758 Metadata now returns self on options for external library support.
|
2247
|
+
|
2248
|
+
* \#1757 Ensure serialization converts any attribute types to the type
|
2249
|
+
defined by the field.
|
2250
|
+
|
2251
|
+
* \#1756 Serializable hash options should pass through to embedded docs.
|
2252
|
+
|
2253
|
+
## 2.4.5
|
2254
|
+
|
2255
|
+
### Resolved Issues
|
2256
|
+
|
2257
|
+
* \#1751 Mongoid's logger now responds to level for Ruby logging API
|
2258
|
+
compatibility.
|
2259
|
+
|
2260
|
+
* \#1744/#1750 Sorting works now for localized fields in embedded documents
|
2261
|
+
using the criteria API. (Hans Hasselberg)
|
2262
|
+
|
2263
|
+
* \#1746 Presence validation now shows which locales were empty for
|
2264
|
+
localized fields. (Cyril Mougel)
|
2265
|
+
|
2266
|
+
* \#1727 Allow dot notation in embedded criteria to work on both embeds one
|
2267
|
+
and embeds many. (Lyle Underwood)
|
2268
|
+
|
2269
|
+
* \#1723 Initialize callbacks should cascade through children without needing
|
2270
|
+
to determine if the child is changed.
|
2271
|
+
|
2272
|
+
* \#1715 Serializable hashes are now consistent on inclusion of embedded
|
2273
|
+
documents per or post save.
|
2274
|
+
|
2275
|
+
* \#1713 Fixing === checks when comparing a class with an instance of a
|
2276
|
+
subclass.
|
2277
|
+
|
2278
|
+
* \#1495 Callbacks no longer get the 'super called outside of method` errors on
|
2279
|
+
busted 1.8.7 rubies.
|
2280
|
+
|
2281
|
+
## 2.4.4
|
2282
|
+
|
2283
|
+
### Resolved Issues
|
2284
|
+
|
2285
|
+
* \#1705 Allow changing the order of many to many foreign keys.
|
2286
|
+
|
2287
|
+
* \#1703 Updated at is now versioned again. (Lucas Souza)
|
2288
|
+
|
2289
|
+
* \#1686 Set the base metadata on unbind as well as bind for belongs to
|
2290
|
+
relations.
|
2291
|
+
|
2292
|
+
* \#1681 Attempt to create indexes for models without namespacing if the
|
2293
|
+
namespace does not exist for the subdirectory.
|
2294
|
+
|
2295
|
+
* \#1676 Allow eager loading to work as a default scope.
|
2296
|
+
|
2297
|
+
* \#1665/\#1672 Expand complex criteria in nested criteria selectors, like
|
2298
|
+
\#matches. (Hans Hasselberg)
|
2299
|
+
|
2300
|
+
* \#1668 Ensure Mongoid logger exists before calling warn. (Rémy Coutable)
|
2301
|
+
|
2302
|
+
* \#1661 Ensure uniqueness validation works on cloned documents.
|
2303
|
+
|
2304
|
+
* \#1659 Clear delayed atomic sets when resetting the same embedded relation.
|
2305
|
+
|
2306
|
+
* \#1656/\#1657 Don't hit database for uniqueness validation if BOTH scope
|
2307
|
+
and attribute hasn't changed. (priyaaank)
|
2308
|
+
|
2309
|
+
* \#1205/\#1642 When limiting fields returned from the database via
|
2310
|
+
`Criteria#only` and `Criteria#without` and then subsequently saving
|
2311
|
+
the document. Default values no longer override excluded fields.
|
2312
|
+
|
2313
|
+
## 2.4.3
|
2314
|
+
|
2315
|
+
### Resolved Issues
|
2316
|
+
|
2317
|
+
* \#1647 DateTime serialization when already in UTC does not convert to
|
2318
|
+
local time.
|
2319
|
+
|
2320
|
+
* \#1641/\#1639 Mongoid.observer.disable :all now behaves as AR does.
|
2321
|
+
|
2322
|
+
* \#1640 Update consumers should be tied to the name of the collection
|
2323
|
+
they persist to, not the name of the class.
|
2324
|
+
|
2325
|
+
* \#1637/\#1636 Scopes no longer modify parent class scopes when subclassing.
|
2326
|
+
(Hans Hasselberg)
|
2327
|
+
|
2328
|
+
* \#1629 $all and $in criteria on embedded many relations now properly
|
2329
|
+
handles regex searches and elements of varying length. (Douwe Maan)
|
2330
|
+
|
2331
|
+
* \#1623/\#1634 Default scopes no longer break Mongoid::Versioning.
|
2332
|
+
(Hans Hasselberg)
|
2333
|
+
|
2334
|
+
* \#1605 Fix regression of rescue responses, Rails 3.2
|
2335
|
+
|
2336
|
+
## 2.4.2
|
2337
|
+
|
2338
|
+
### Resolved Issues
|
2339
|
+
|
2340
|
+
* \#1628 _type field can once again be included in serialization to json
|
2341
|
+
or xml as a global option with `include_type_for_serialization`.
|
2342
|
+
(Roman Shterenzon)
|
2343
|
+
|
2344
|
+
* \#1627 Validating format now works properly with localized fields.
|
2345
|
+
(Douwe Maan)
|
2346
|
+
|
2347
|
+
* \#1617 Relation proxy methods now show up in Mongoid's list of
|
2348
|
+
prohibited fields.
|
2349
|
+
|
2350
|
+
* \#1615 Allow a single configuration of host and port for all spec runs,
|
2351
|
+
overridden by setting MONGOID_SPEC_HOST and MONGOID_SPEC_PORT env vars.
|
2352
|
+
|
2353
|
+
* \#1610 When versioning paranoid documents and max version is set, hard
|
2354
|
+
delete old versions from the embedded relation.
|
2355
|
+
|
2356
|
+
* \#1609 Allow connection retry during cursor iteration as well as all other
|
2357
|
+
operations.
|
2358
|
+
|
2359
|
+
* \#1608 Guard against no method errors when passing ids in nested attributes
|
2360
|
+
and the documents do not exist.
|
2361
|
+
|
2362
|
+
* \#1605 Remove deprecation warning on rescue responses, Rails 3.2
|
2363
|
+
|
2364
|
+
* \#1602 Preserve structure of $and and $or queries when typecasting.
|
2365
|
+
|
2366
|
+
* \#1600 Uniqueness validation no longer errors when provided a relation.
|
2367
|
+
|
2368
|
+
* \#1599 Make sure enumerable targets yield to what is in memory first when
|
2369
|
+
performing #each, not always the unloaded first.
|
2370
|
+
|
2371
|
+
* \#1597 Fix the ability to change the order of array fields with the same
|
2372
|
+
elements.
|
2373
|
+
|
2374
|
+
* \#1590 Allow proper serialization of boolean values in criteria where the
|
2375
|
+
field is nested inside an array.
|
2376
|
+
|
2377
|
+
## 2.4.1
|
2378
|
+
|
2379
|
+
### Resolved Issues
|
2380
|
+
|
2381
|
+
* \#1593 Arrays on embedded documents now properly atomically update when
|
2382
|
+
modified from original version.
|
2383
|
+
|
2384
|
+
* \#1592 Don't swallow exceptions from index generation in the create_indexes
|
2385
|
+
rake task.
|
2386
|
+
|
2387
|
+
* \#1589 Allow assignment of empty array to HABTM when no documents are yet
|
2388
|
+
loaded into memory.
|
2389
|
+
|
2390
|
+
* \#1587 When a previous value for an array field was an explicit nil, it can
|
2391
|
+
now be reset atomically with new values.
|
2392
|
+
|
2393
|
+
* \#1585 `Model#respond_to?` returns true now for the setter when allowing
|
2394
|
+
dynamic fields.
|
2395
|
+
|
2396
|
+
* \#1582 Allow nil values to be set in arrays.
|
2397
|
+
|
2398
|
+
* \#1580 Allow arrays to be set to nil post save, and not just empty.
|
2399
|
+
|
2400
|
+
* \#1579 Don't call #to_a on individual set field elements in criterion.
|
2401
|
+
|
2402
|
+
* \#1576 Don't hit database on uniqueness validation if the field getting
|
2403
|
+
validated has not changed.
|
2404
|
+
|
2405
|
+
* \#1571 Aliased fields get all the dirty attribute methods and all getters and
|
2406
|
+
setters for both the original name and the alias. (Hans Hasselberg)
|
2407
|
+
|
2408
|
+
* \#1568 Fallback to development environment with warning when no env configured.
|
2409
|
+
|
2410
|
+
* \#1565 For fields and foreign keys with non-standard Ruby or database names,
|
2411
|
+
use define_method instead of class_eval for creating the accessors and
|
2412
|
+
dirty methods.
|
2413
|
+
|
2414
|
+
* \#1557 Internal strategy class no longer conflicts with models.
|
2415
|
+
|
2416
|
+
* \#1551 Parent documents now return `true` for `Model#changed?` if only child
|
2417
|
+
(embedded) documents have changed.
|
2418
|
+
|
2419
|
+
* \#1547 Resetting persisted children from a parent save when new waits until post
|
2420
|
+
callbacks, mirroring update functionality.
|
2421
|
+
|
2422
|
+
* \#1536 Eager loading now happens when calling `first` or `last` on a
|
2423
|
+
criteria if inclusions are specified.
|
2424
|
+
|
2425
|
+
## 2.4.0
|
2426
|
+
|
2427
|
+
### New Features
|
2428
|
+
|
2429
|
+
* Ranges can now be passed to #where criteria to create a $gte/$lte query under the
|
2430
|
+
covers. `Person.where(dob: start_date...end_date)`
|
2431
|
+
|
2432
|
+
* Custom serializable fields can now override #selection to provide
|
2433
|
+
customized serialization for criteria queries.
|
2434
|
+
|
2435
|
+
* \#1544 Internals use `Array.wrap` instead of `to_a` now where possible.
|
2436
|
+
|
2437
|
+
* \#1511 Presence validation now supports localized fields. (Tiago Rafael Godinho)
|
2438
|
+
|
2439
|
+
* \#1506 `Model.set` will now accept false and nil values. (Marten Veldthuis)
|
2440
|
+
|
2441
|
+
* \#1505 `Model.delete_all/destroy_all` now take either a :conditions hash or
|
2442
|
+
the attributes directly.
|
2443
|
+
|
2444
|
+
* \#1504 `Model.recursively_embeds_many` now accepts a :cascade_callbacks
|
2445
|
+
option. (Pavel Pravosud)
|
2446
|
+
|
2447
|
+
* \#1496 Mongoid now casts strings back to symbols for symbol fields that
|
2448
|
+
get saved as strings by another application.
|
2449
|
+
|
2450
|
+
* \#1454, \#900 Associations now have an `after_build` callback that gets
|
2451
|
+
executed after `.build` or `build_` methods are called.
|
2452
|
+
(Jeffrey Jones, Ryan Townsend)
|
2453
|
+
|
2454
|
+
* \#1451 Ranges can now be any range value, not just numbers. (aupajo)
|
2455
|
+
|
2456
|
+
* \#1448 Localization is now used when sorting. (Hans Hasselberg)
|
2457
|
+
|
2458
|
+
* \#1422 Mongoid raises an error at yaml load if no environment is found.
|
2459
|
+
(Tom Stuart)
|
2460
|
+
|
2461
|
+
* \#1413 $not support added to criteria symbol methods. (Marc Weil)
|
2462
|
+
|
2463
|
+
* \#1403 Added configuration option `scope_overwrite_exception` which defaults to
|
2464
|
+
false for raising an error when defining a named scope with the same name of
|
2465
|
+
an existing method. (Christoph Grabo)
|
2466
|
+
|
2467
|
+
* \#1388 `model.add_to_set` now supports adding multiple values and performs an
|
2468
|
+
$addToSet with $each under the covers. (Christian Felder)
|
2469
|
+
|
2470
|
+
* \#1387 Added `Model#cache_key` for use in Rails caching. (Seivan Heidari)
|
2471
|
+
|
2472
|
+
* \#1380 Calling Model.find(id) will now properly convert to and from any type
|
2473
|
+
based on the type of the _id field.
|
2474
|
+
|
2475
|
+
* \#1363 Added fallbacks and default support to localized fields, and added
|
2476
|
+
ability to get and set all translations at once.
|
2477
|
+
|
2478
|
+
* \#1362 Aliased fields now properly typecast in criteria.
|
2479
|
+
|
2480
|
+
* \#1337 Array fields, including HABTM many foreign keys now have smarter dirty
|
2481
|
+
checking and no longer perform a simple $set if the array has changed. If
|
2482
|
+
items have only been added to the array, it performs a $pushAll. If items
|
2483
|
+
have only been removed, it performs a $pullAll. If both additions and
|
2484
|
+
removals have occurred it performs a $set to avoid conflicting mods.
|
2485
|
+
|
2486
|
+
### Resolved Issues
|
2487
|
+
|
2488
|
+
* Calling `Document#as_document` on a frozen document on Rubinius returns the
|
2489
|
+
attributes instead of nil.
|
2490
|
+
|
2491
|
+
* \#1554 Split application of default values into proc/non-procs, where
|
2492
|
+
non-procs get executed immediately during instantiation, and procs get
|
2493
|
+
executed after all other values are set.
|
2494
|
+
|
2495
|
+
* \#1553 Combinations of adding and removing values from an array use a $set
|
2496
|
+
on the current contents of the array, not the new values.
|
2497
|
+
|
2498
|
+
* \#1546 Dirty changes should be returned in a hash with indifferent access.
|
2499
|
+
|
2500
|
+
* \#1542 Eager loading now respects the options (ie skip, limit) provided to
|
2501
|
+
the criteria when fetch the associations.
|
2502
|
+
|
2503
|
+
* \#1530 Don't duplicate added values to arrays via dirty tracking if the
|
2504
|
+
array is a foreign key field.
|
2505
|
+
|
2506
|
+
* \#1529 Calling `unscoped` on relational associations now works properly.
|
2507
|
+
|
2508
|
+
* \#1524 Allow access to relations in overridden field setters by pre-setting
|
2509
|
+
foreign key default values.
|
2510
|
+
|
2511
|
+
* \#1523 Allow disabling of observers via `disable`. (Jonas Schneider)
|
2512
|
+
|
2513
|
+
* \#1522 Fixed create indexes rake task for Rails 3.2. (Gray Manley)
|
2514
|
+
|
2515
|
+
* \#1517 Fix Mongoid documents to properly work with RSpec's stub_model.
|
2516
|
+
(Tiago Rafael Godinho)
|
2517
|
+
|
2518
|
+
* \#1516 Don't duplicate relational many documents on bind.
|
2519
|
+
|
2520
|
+
* \#1515 Mongoid no longer attempts to serialize custom fields on complex
|
2521
|
+
criteria by default.
|
2522
|
+
|
2523
|
+
* \#1503 Has many relation substitution now handles any kind of mix of existing
|
2524
|
+
and new docs.
|
2525
|
+
|
2526
|
+
* \#1502 Nested attributes on embedded documents respects if the child is
|
2527
|
+
paranoid.
|
2528
|
+
|
2529
|
+
* \#1497 Use provided message on failing uniqueness validation. (Justin Etheredge)
|
2530
|
+
|
2531
|
+
* \#1491 Return nil when no default set on localized fields. (Tiago Rafael Godinho)
|
2532
|
+
|
2533
|
+
* \#1483 Sending module includes at runtime which add new fields to a parent
|
2534
|
+
document, also have the fields added to subclasses.
|
2535
|
+
|
2536
|
+
* \#1482 Applying new sorting options does not merge into previously
|
2537
|
+
chained criteria. (Gerad Suyderhoud)
|
2538
|
+
|
2539
|
+
* \#1481 Fix invalid query when accessing many-to-many relations before
|
2540
|
+
defaults are set.
|
2541
|
+
|
2542
|
+
* \#1480 Mongoid's internal serialized field types renamespaced to Internal in order
|
2543
|
+
to not conflict with ruby core classes in custom serializable types.
|
2544
|
+
|
2545
|
+
* \#1479 Don't duplicate ids on many-to-many when using create or create!
|
2546
|
+
|
2547
|
+
* \#1469 When extract_id returns nil, get the document out of the identity map
|
2548
|
+
by the criteria selector.
|
2549
|
+
|
2550
|
+
* \#1467 Defining a field named metadata now properly raises an invalid field
|
2551
|
+
error.
|
2552
|
+
|
2553
|
+
* \#1463 Batch insert consumers are now scoped to collection to avoid persistence
|
2554
|
+
of documents to other collections in callbacks going to the wrong place.
|
2555
|
+
|
2556
|
+
* \#1462 Assigning has many relations via nested attribtues `*_attributes=` does
|
2557
|
+
not autosave the relation.
|
2558
|
+
|
2559
|
+
* \#1461 Fixed serialization of foreign key fields in complex criteria not to
|
2560
|
+
escape the entire hash.
|
2561
|
+
|
2562
|
+
* \#1458 Versioning no longer skips fields that have been protected from mass
|
2563
|
+
assignment.
|
2564
|
+
|
2565
|
+
* \#1455, \#1456 Calling destroy on any document now temporarily marks it as
|
2566
|
+
flagged for destroy until the operation is complete. (Nader Akhnoukh)
|
2567
|
+
|
2568
|
+
* \#1453 `Model#to_key` should return a value when the document is destroyed.
|
2569
|
+
|
2570
|
+
* \#1449 New documents no longer get persisted when replaced on a has one as
|
2571
|
+
a side effect. (jasonsydes)
|
2572
|
+
|
2573
|
+
* \#1439 embedded? should return true when relation defined as cyclic.
|
2574
|
+
|
2575
|
+
* \#1433 Polymorphic nested attributes for embedded and relational 1-1 now
|
2576
|
+
update properly.
|
2577
|
+
|
2578
|
+
* \#1426 Frozen documents can now be cloned. (aagrawal2001)
|
2579
|
+
|
2580
|
+
* \#1382 Raise proper error when creating indexes via rake task if index
|
2581
|
+
definition is incorrect. (Mathieu Ravaux)
|
2582
|
+
|
2583
|
+
* \#1381, \#1371 The identity map now functions properly with inherited
|
2584
|
+
documents. (Paul Canavese)
|
2585
|
+
|
2586
|
+
* \#1370 Split concat on embedded arrays into its own method to handle the
|
2587
|
+
batch processing due to after callback run execution issues.
|
2588
|
+
|
2589
|
+
* \#1366 Array and hash values now get deep copied for dirty tracking.
|
2590
|
+
|
2591
|
+
* \#1359 Provide ability to not have default scope applied to all named
|
2592
|
+
scopes via using lambdas.
|
2593
|
+
|
2594
|
+
* \#1333 Fixed errors with custom types that exist in namespaces. (Peter Gumeson)
|
2595
|
+
|
2596
|
+
* \#1259 Default values are treated as dirty if they differ from the database
|
2597
|
+
state.
|
2598
|
+
|
2599
|
+
* \#1255 Ensure embedded documents respect the defined default scope.
|
2600
|
+
|
2601
|
+
## 2.3.4
|
2602
|
+
|
2603
|
+
* \#1445 Prevent duplicate documents in the loaded array on the target
|
2604
|
+
enumerable for relational associations.
|
2605
|
+
|
2606
|
+
* \#1442 When using create_ methods for has one relations, the appropriate
|
2607
|
+
destructive methods now get called when replacing an existing document.
|
2608
|
+
|
2609
|
+
* \#1431 Enumerable context should add to the loaded array post yield, so
|
2610
|
+
that methods like #any? that short circuit based on the value of the block
|
2611
|
+
dont falsely have extra documents.
|
2612
|
+
|
2613
|
+
* \#1418 Documents being loaded from the database for revision purposes
|
2614
|
+
no longer get placed in the identity map.
|
2615
|
+
|
2616
|
+
* \#1399 Allow conversion of strings to integers in foreign keys where the
|
2617
|
+
id is defined as an int.
|
2618
|
+
|
2619
|
+
* \#1397 Don't add default sorting criteria on first if they sort criteria
|
2620
|
+
already exists.
|
2621
|
+
|
2622
|
+
* \#1394 Fix exists? to work when count is greater than 1. (Nick Hoffman)
|
2623
|
+
|
2624
|
+
* \#1392 Return 0 on aggregation functions where field is nonexistant.
|
2625
|
+
|
2626
|
+
* \#1391 Uniqueness validation now works properly on embedded documents that are
|
2627
|
+
using primary key definitions.
|
2628
|
+
|
2629
|
+
* \#1390 When _type field is lower case class camelize before constantizing.
|
2630
|
+
|
2631
|
+
* \#1383 Fix cast on read for serializable fields that are subclassed.
|
2632
|
+
|
2633
|
+
* \#1357 Delayed atomic sets from update_attributes on embedded documents
|
2634
|
+
multiple levels deep now properly persist.
|
2635
|
+
|
2636
|
+
* \#1326 Ensure base document on HABTM gets its keys saved after saving a newly
|
2637
|
+
build child document.
|
2638
|
+
|
2639
|
+
* \#1301 Don't overwrite base metadata on embedded in relations if already set.
|
2640
|
+
|
2641
|
+
* \#1221 HABTM with inverse nil is allowed again on embedded documents.
|
2642
|
+
|
2643
|
+
* \#1208 Don't auto-persist child documents via the setter when setting from
|
2644
|
+
an embedded_in.
|
2645
|
+
|
2646
|
+
* \#791 Root document updates its timestamps when only embedded documents have
|
2647
|
+
changed.
|
2648
|
+
|
2649
|
+
## 2.3.3
|
2650
|
+
|
2651
|
+
### Resolved Issues
|
2652
|
+
|
2653
|
+
* \#1386 Lowered mongo/bson dependency to 1.3
|
2654
|
+
|
2655
|
+
* \#1377 Fix aggregation functions to properly handle nil or indefined values.
|
2656
|
+
(Maxime Garcia)
|
2657
|
+
|
2658
|
+
* \#1373 Warn if a scope overrides another scope.
|
2659
|
+
|
2660
|
+
* \#1372 Never persist when binding inside of a read attribute for validation.
|
2661
|
+
|
2662
|
+
* \#1364 Fixed reloading of documents with non bson object id ids.
|
2663
|
+
|
2664
|
+
* \#1360 Fixed performance of Mongoid's observer instantiation by hooking into
|
2665
|
+
Active Support's load hooks, a la AR.
|
2666
|
+
|
2667
|
+
* \#1358 Fixed type error on many to many synchronization when inverse_of is
|
2668
|
+
set to nil.
|
2669
|
+
|
2670
|
+
* \#1356 $in criteria can now be chained to non-complex criteria on the same
|
2671
|
+
key without error.
|
2672
|
+
|
2673
|
+
* \#1350, \#1351 Fixed errors in the string conversions of double quotes and
|
2674
|
+
tilde when paramterizing keys.
|
2675
|
+
|
2676
|
+
* \#1349 Mongoid documents should not blow up when including Enumerable.
|
2677
|
+
(Jonas Nicklas)
|
2678
|
+
|
2679
|
+
## 2.3.2
|
2680
|
+
|
2681
|
+
### Resolved Issues
|
2682
|
+
|
2683
|
+
* \#1347 Fix embedded matchers when provided a hash value that does not have a
|
2684
|
+
modifier as a key.
|
2685
|
+
|
2686
|
+
* \#1346 Dup default sorting criteria when calling first/last on a criteria.
|
2687
|
+
|
2688
|
+
* \#1343 When passing no arguments to `Criteria#all_of` return all documents.
|
2689
|
+
(Chris Leishman)
|
2690
|
+
|
2691
|
+
* \#1339 Ensure destroy callbacks are run on cascadable children when deleting via
|
2692
|
+
nested attributes.
|
2693
|
+
|
2694
|
+
* \#1324 Setting `inverse_of: nil` on a many-to-many referencing the same class
|
2695
|
+
returns nil for the inverse foreign key.
|
2696
|
+
|
2697
|
+
* \#1323 Allow both strings and symbols as ids in the attributes array for
|
2698
|
+
nested attributes. (Michael Wood)
|
2699
|
+
|
2700
|
+
* \#1312 Setting a logger on the config now accepts anything that quacks like a
|
2701
|
+
logger.
|
2702
|
+
|
2703
|
+
* \#1297 Don't hit the database when accessing relations if the base is new.
|
2704
|
+
|
2705
|
+
* \#1239 Allow appending of referenced relations in create blocks, post default set.
|
2706
|
+
|
2707
|
+
* \#1236 Ensure all models are loaded in rake tasks, so even in threadsafe mode
|
2708
|
+
all indexes can be created.
|
2709
|
+
|
2710
|
+
* \#736 Calling #reload on embedded documents now works properly.
|
2711
|
+
|
2712
|
+
## 2.3.1
|
2713
|
+
|
2714
|
+
### Resolved Issues
|
2715
|
+
|
2716
|
+
* \#1338 Calling #find on a scope or relation checks that the document in the
|
2717
|
+
identity map actually matches other scope parameters.
|
2718
|
+
|
2719
|
+
* \#1321 HABTM no longer allows duplicate entries or keys, instead of the previous
|
2720
|
+
inconsistencies.
|
2721
|
+
|
2722
|
+
* \#1320 Fixed errors in perf benchmark.
|
2723
|
+
|
2724
|
+
* \#1316 Added a separate Rake task "db:mongoid:drop" so Mongoid and AR can coexist.
|
2725
|
+
(Daniel Vartanov)
|
2726
|
+
|
2727
|
+
* \#1311 Fix issue with custom field serialization inheriting from hash.
|
2728
|
+
|
2729
|
+
* \#1310 The referenced many enumerable target no longer duplicates loaded and
|
2730
|
+
added documents when the identity map is enabled.
|
2731
|
+
|
2732
|
+
* \#1295 Fixed having multiple includes only execute the eager loading of the first.
|
2733
|
+
|
2734
|
+
* \#1287 Fixed max versions limitation with versioning.
|
2735
|
+
|
2736
|
+
* \#1277 attribute_will_change! properly flags the attribute even if no change occured.
|
2737
|
+
|
2738
|
+
* \#1063 Paranoid documents properly run destroy callbacks on soft destroy.
|
2739
|
+
|
2740
|
+
* \#1061 Raise `Mongoid::Errors::InvalidTime` when time serialization fails.
|
2741
|
+
|
2742
|
+
* \#1002 Check for legal bson ids when attempting conversion.
|
2743
|
+
|
2744
|
+
* \#920 Allow relations to be named target.
|
2745
|
+
|
2746
|
+
* \#905 Return normalized class name in metadata if string was defined with a
|
2747
|
+
prefixed ::.
|
2748
|
+
|
2749
|
+
* \#861 accepts_nested_attributes_for is no longer needed to set embedded documents
|
2750
|
+
via a hash or array of hashes directly.
|
2751
|
+
|
2752
|
+
* \#857 Fixed cascading of dependent relations when base document is paranoid.
|
2753
|
+
|
2754
|
+
* \#768 Fixed class_attribute definitions module wide.
|
2755
|
+
|
2756
|
+
* \#408 Embedded documents can now be soft deleted via `Mongoid::Paranoia`.
|
2757
|
+
|
2758
|
+
## 2.3.0
|
2759
|
+
|
2760
|
+
### New Features
|
2761
|
+
|
2762
|
+
* Mongoid now supports basic localized fields, storing them under the covers as a
|
2763
|
+
hash of locale => value pairs. `field :name, localize: true`
|
2764
|
+
|
2765
|
+
* \#1275 For applications that default safe mode to true, you can now tell a
|
2766
|
+
single operation to persist without safe mode via #unsafely:
|
2767
|
+
`person.unsafely.save`, `Person.unsafely.create`. (Matt Sanders)
|
2768
|
+
|
2769
|
+
* \#1256 Mongoid now can create indexes for models in Rails engines. (Caio Filipini)
|
2770
|
+
|
2771
|
+
* \#1228 Allow pre formatting of compsoite keys by passing a block to #key.
|
2772
|
+
(Ben Hundley)
|
2773
|
+
|
2774
|
+
* \#1222 Scoped mass assignment is now supported. (Andrew Shaydurov)
|
2775
|
+
|
2776
|
+
* \#1196 Timestamps can now be turned off on a call-by-call basis via the use
|
2777
|
+
of #timeless: `person.timeless.save`, `Person.timeless.create(:title => "Sir")`.
|
2778
|
+
|
2779
|
+
* \#1103 Allow developers to create their own custom complex criteria. (Ryan Ong)
|
2780
|
+
|
2781
|
+
* Mongoid now includes all defined fields in `serializable_hash` and `to_json`
|
2782
|
+
results even if the fields have no values to make serialized documents easier
|
2783
|
+
to use by ActiveResource clients.
|
2784
|
+
|
2785
|
+
* Support for MongoDB's $and operator is now available in the form of:
|
2786
|
+
`Criteria#all_of(*args)` where args is multiple hash expressions.
|
2787
|
+
|
2788
|
+
* \#1250, \#1058 Embedded documents now can have their callbacks fired on a parent
|
2789
|
+
save by setting `:cascade_callbacks => true` on the relation.
|
2790
|
+
(pyromanic, Paul Rosania, Jak Charlton)
|
2791
|
+
|
2792
|
+
### Major Changes
|
2793
|
+
|
2794
|
+
* Mongoid now depends on Active Model 3.1 and higher.
|
2795
|
+
|
2796
|
+
* Mongoid now depends on the Mongo Ruby Driver 1.4 and higher.
|
2797
|
+
|
2798
|
+
* Mongoid requires MongoDB 2.0.0 and higher.
|
2799
|
+
|
2800
|
+
### Resolved Issues
|
2801
|
+
|
2802
|
+
* \#1308 Fixed scoping of HABTM finds.
|
2803
|
+
|
2804
|
+
* \#1300 Namespaced models should handle recursive embedding properly.
|
2805
|
+
|
2806
|
+
* \#1299 Self referenced documents with versioning no longer fail when inverse_of
|
2807
|
+
is not defined on all relations.
|
2808
|
+
|
2809
|
+
* \#1296 Renamed internal building method to _building.
|
2810
|
+
|
2811
|
+
* \#1288, \#1289 _id and updated_at should not be part of versioned attributes.
|
2812
|
+
|
2813
|
+
* \#1273 Mongoid.preload_models now checks if preload configuration option is set,
|
2814
|
+
where Mongoid.load_models always loads everything. (Ryan McGeary)
|
2815
|
+
|
2816
|
+
* \#1244 Has one relations now adhere to default dependant behaviour.
|
2817
|
+
|
2818
|
+
* \#1225 Fixed delayed persistence of embedded documents via $set.
|
2819
|
+
|
2820
|
+
* \#1166 Don't load config in Railtie if no env variables defined. (Terence Lee)
|
2821
|
+
|
2822
|
+
* \#1052 `alias_attribute` now works again as expected.
|
2823
|
+
|
2824
|
+
* \#939 Apply default attributes when upcasting via #becomes. (Christos Pappas)
|
2825
|
+
|
2826
|
+
* \#932 Fixed casting of integer fields with leading zeros.
|
2827
|
+
|
2828
|
+
* \#948 Reset version number on clone if versions existed.
|
2829
|
+
|
2830
|
+
* \#763 Don't merge $in criteria arrays when chaining named scopes.
|
2831
|
+
|
2832
|
+
* \#730 Existing models that have relations added post persistence of originals
|
2833
|
+
can now have new relations added with no migrations.
|
2834
|
+
|
2835
|
+
* \#726 Embedded documents with compound keys not validate uniqueness correctly.
|
2836
|
+
|
2837
|
+
* \#582 Cyclic non embedded relations now validate uniqueness correctly.
|
2838
|
+
|
2839
|
+
* \#484 Validates uniqueness with multiple scopes of all types now work properly.
|
2840
|
+
|
2841
|
+
* Deleting versions created with `Mongoid::Versioning` no longer fires off
|
2842
|
+
dependent cascading on relations.
|
2843
|
+
|
2844
|
+
## 2.2.5
|
2845
|
+
|
2846
|
+
* This was a small patch release to address 2.2.x Heroku errors during asset
|
2847
|
+
compilation.
|
2848
|
+
|
2849
|
+
## 2.2.4
|
2850
|
+
|
2851
|
+
* \#1377 Fix aggregation functions to properly handle nil or indefined values.
|
2852
|
+
(Maxime Garcia)
|
2853
|
+
|
2854
|
+
* \#1373 Warn if a scope overrides another scope.
|
2855
|
+
|
2856
|
+
* \#1372 Never persist when binding inside of a read attribute for validation.
|
2857
|
+
|
2858
|
+
* \#1358 Fixed type error on many to many synchronization when inverse_of is
|
2859
|
+
set to nil.
|
2860
|
+
|
2861
|
+
* \#1356 $in criteria can now be chained to non-complex criteria on the same
|
2862
|
+
key without error.
|
2863
|
+
|
2864
|
+
* \#1350, \#1351 Fixed errors in the string conversions of double quotes and
|
2865
|
+
tilde when paramterizing keys.
|
2866
|
+
|
2867
|
+
* \#1349 Mongoid documents should not blow up when including Enumerable.
|
2868
|
+
(Jonas Nicklas)
|
2869
|
+
|
2870
|
+
## 2.2.3
|
2871
|
+
|
2872
|
+
* \#1295 Fixed having multiple includes only execute the eager loading of the first.
|
2873
|
+
|
2874
|
+
* \#1225 Fixed delayed persistence of embedded documents via $set.
|
2875
|
+
|
2876
|
+
* \#1002 Fix BSON object id conversion to check if legal first.
|
2877
|
+
|
2878
|
+
## 2.2.2
|
2879
|
+
|
2880
|
+
* This release removes the restriction of a dependency on 1.3.x of the mongo
|
2881
|
+
ruby driver. Users may now use 1.3.x through 1.4.x.
|
2882
|
+
|
2883
|
+
## 2.2.1
|
2884
|
+
|
2885
|
+
### Resolved Issues
|
2886
|
+
|
2887
|
+
* \#1210, \#517 Allow embedded document relation queries to use dot notation.
|
2888
|
+
(Scott Ellard)
|
2889
|
+
|
2890
|
+
* \#1198 Enumerable target should use criteria count if loaded has no docs.
|
2891
|
+
|
2892
|
+
* \#1164 Get rid of remaining no method in_memory errors.
|
2893
|
+
|
2894
|
+
* \#1070 Allow custom field serializers to have their own constructors.
|
2895
|
+
|
2896
|
+
* \#1176 Allow access to parent documents from embedded docs in after_destroy
|
2897
|
+
callbacks.
|
2898
|
+
|
2899
|
+
* \#1191 Context group methods (min, max, sum) no longer return NaN but instead
|
2900
|
+
return nil if field doesn't exist or have values.
|
2901
|
+
|
2902
|
+
* \#1193, \#1271 Always return Integers for integer fields with .000 precisions,
|
2903
|
+
not floats.
|
2904
|
+
|
2905
|
+
* \#1199 Fixed performance issues of hash and array field access when reading
|
2906
|
+
multiple times.
|
2907
|
+
|
2908
|
+
* \#1218 Fixed issues with relations referencing models with integer foreign keys.
|
2909
|
+
|
2910
|
+
* \#1219 Fixed various conflicting modifications issues when pushing and pulling
|
2911
|
+
from the same embedded document in a single call.
|
2912
|
+
|
2913
|
+
* \#1220 Metadata should not get overwritten by nil on binding.
|
2914
|
+
|
2915
|
+
* \#1231 Renamed Mongoid's atomic set class to Sets to avoid conflicts with Ruby's
|
2916
|
+
native Set after document inclusion.
|
2917
|
+
|
2918
|
+
* \#1232 Fix access to related models during before_destroy callbacks when
|
2919
|
+
cascading.
|
2920
|
+
|
2921
|
+
* \#1234 Fixed HABTM foreign key synchronization issues when destroying
|
2922
|
+
documents.
|
2923
|
+
|
2924
|
+
* \#1243 Polymorphic relations dont convert to object ids when querying if the
|
2925
|
+
ids are defined as strings.
|
2926
|
+
|
2927
|
+
* \#1247 Force Model.first to sort by ascending id to guarantee first document.
|
2928
|
+
|
2929
|
+
* \#1248 Added #unscoped to embedded many relations.
|
2930
|
+
|
2931
|
+
* \#1249 Destroy flags in nested attributes now actually destroy the document
|
2932
|
+
for has_many instead of just breaking the relation.
|
2933
|
+
|
2934
|
+
* \#1272 Don't modify configuration options in place when creating replica set
|
2935
|
+
connections.
|
2936
|
+
|
2937
|
+
## 2.2.0
|
2938
|
+
|
2939
|
+
### New Features
|
2940
|
+
|
2941
|
+
* Mongoid now contains eager loading in the form of `Criteria#includes(*args)`.
|
2942
|
+
This works on has_one, has_many, belongs_to associations and requires the identity map to
|
2943
|
+
be enabled in order to function. Set `identity_map_enabled: true` in your
|
2944
|
+
`mongoid.yml`. Ex: `Person.where(title: "Sir").includes(:posts, :game)`
|
2945
|
+
|
2946
|
+
* Relations can now take a module as a value to the `:extend` option. (Roman
|
2947
|
+
Shterenzon)
|
2948
|
+
|
2949
|
+
* Capped collections can be created by passing the options to the `#store_in`
|
2950
|
+
macro: `Person.store_in :people, capped: true, max: 1000000`
|
2951
|
+
|
2952
|
+
* Mongoid::Collection now supports `collection.find_and_modify`
|
2953
|
+
|
2954
|
+
* `Document#has_attribute?` now aliases to `Document#attribute_present?`
|
2955
|
+
|
2956
|
+
* \#930 You can now turn off the Mongoid logger via the mongoid.yml by
|
2957
|
+
doing `logger: false`
|
2958
|
+
|
2959
|
+
* \#909 We now raise a `Mongoid::Errors::Callback` exception if persisting with
|
2960
|
+
a bang method and a callback returns false, instead of the uninformative
|
2961
|
+
validations error from before.
|
2962
|
+
|
2963
|
+
### Major Changes
|
2964
|
+
|
2965
|
+
* \#1173 has_many relations no longer delete all documents on a set of the relation
|
2966
|
+
(= [ doc_one, doc_two ]) but look to the dependent option to determine what
|
2967
|
+
behaviour should occur. :delete and :destroy will behave as before, :nullify and
|
2968
|
+
no option specified will both nullify the old documents without deleting.
|
2969
|
+
|
2970
|
+
* \#1142, \#767 Embedded relations no longer immediately persist atomically
|
2971
|
+
when accessed via a parent attributes set. This includes nested attributes setting
|
2972
|
+
and `attributes=` or `write_attributes`. The child changes then remain dirty and
|
2973
|
+
atomically update when save is called on them or the parent document.
|
2974
|
+
|
2975
|
+
### Resolved Issues
|
2976
|
+
|
2977
|
+
* \#1190 Fixed the gemspec errors due to changing README and CHANGELOG to markdown.
|
2978
|
+
|
2979
|
+
* \#1180, \#1084, \#955 Mongoid now checks the field types rather than if the name
|
2980
|
+
contains `/id/` when trying to convert to object ids on criteria.
|
2981
|
+
|
2982
|
+
* \#1176 Enumerable targets should always return the in memory documents first,
|
2983
|
+
when calling `#first`
|
2984
|
+
|
2985
|
+
* \#1175 Make sure both sides of many to many relations are in sync during a create.
|
2986
|
+
|
2987
|
+
* \#1172 Referenced enumerable relations now properly handle `#to_json`
|
2988
|
+
(Daniel Doubrovkine)
|
2989
|
+
|
2990
|
+
* \#1040 Increased performance of class load times by removing all delegate calls
|
2991
|
+
to self.class.
|
2992
|
+
|
2993
|
+
## 2.1.9
|
2994
|
+
|
2995
|
+
### Resolved Issues
|
2996
|
+
|
2997
|
+
* \#1159 Fixed build blocks not to cancel out each other when nested.
|
2998
|
+
|
2999
|
+
* \#1154 Don't delete many-to-many documents on empty array set.
|
3000
|
+
|
3001
|
+
* \#1153 Retain parent document reference in after callbacks.
|
3002
|
+
|
3003
|
+
* \#1151 Fix associated validation infinite loop on self referencing documents.
|
3004
|
+
|
3005
|
+
* \#1150 Validates associated on `belongs_to` is `false` by default.
|
3006
|
+
|
3007
|
+
* \#1149 Fixed metadata setting on `belongs_to` relations.
|
3008
|
+
|
3009
|
+
* \#1145 Metadata inverse should return `nil` if `inverse_of` was set as `nil`.
|
3010
|
+
|
3011
|
+
* \#1139 Enumerable targets now quack like arrays.
|
3012
|
+
|
3013
|
+
* \#1136 Setting `belongs_to` parent to `nil` no longer deletes the parent.
|
3014
|
+
|
3015
|
+
* \#1120 Don't call `in_memory` on relations if they don't respond to it.
|
3016
|
+
|
3017
|
+
* \#1075 Set `self` in default procs to the document instance.
|
3018
|
+
|
3019
|
+
* \#1072 Writing attributes for nested documents can take a hash or array of hashes.
|
3020
|
+
|
3021
|
+
* \#990 Embedded documents can use a single `embedded_in` with multiple parent definitions.
|
3022
|
+
|
3023
|
+
## 2.1.8
|
3024
|
+
|
3025
|
+
### Resolved Issues
|
3026
|
+
|
3027
|
+
* \#1148 Fixed `respond_to?` on all relations to return properly.
|
3028
|
+
|
3029
|
+
* \#1146 Added back the Mongoid destructive fields check when defining fields.
|
3030
|
+
|
3031
|
+
* \#1141 Fixed conversions of `nil` values in criteria.
|
3032
|
+
|
3033
|
+
* \#1131 Verified Mongoid/Kaminari paginating correctly.
|
3034
|
+
|
3035
|
+
* \#1105 Fixed atomic update consumer to be scoped to class.
|
3036
|
+
|
3037
|
+
* \#1075 `self` in default lambdas and procs now references the document instance.
|
3038
|
+
|
3039
|
+
* \#740 Removed `embedded_object_id` configuration parameter.
|
3040
|
+
|
3041
|
+
* \#661 Fixed metadata caching on embedded documents.
|
3042
|
+
|
3043
|
+
* \#595 Fixed relation reload flagging.
|
3044
|
+
|
3045
|
+
* \#410 Moving documents from one relation to another now works as expected.
|
3046
|
+
|
3047
|
+
## 2.1.7
|
3048
|
+
|
3049
|
+
This was a specific release to fix MRI 1.8.7 breakages introduced by 2.1.6.
|
3050
|
+
|
3051
|
+
## 2.1.6
|
3052
|
+
|
3053
|
+
### Resolved Issues
|
3054
|
+
|
3055
|
+
* \#1126 Fix setting of relations with other relation proxies.
|
3056
|
+
|
3057
|
+
* \#1122 Hash and array fields now properly flag as dirty on access and change.
|
3058
|
+
|
3059
|
+
* \#656 Fixed reload breaking relations on unsetting of already loaded associations.
|
3060
|
+
|
3061
|
+
* \#647 Prefer `#unset` to `#remove_attribute` for removing values.
|
3062
|
+
|
3063
|
+
* \#290 Verify pushes into deeply embedded documents.
|
3064
|
+
|
3065
|
+
## 2.1.5
|
3066
|
+
|
3067
|
+
### Resolved Issues
|
3068
|
+
|
3069
|
+
* \#1116 Embedded children retain reference to parent in destroy callbacks.
|
3070
|
+
|
3071
|
+
* \#1110, \#1115 Don't memoize metadata related helpers on documents.
|
3072
|
+
|
3073
|
+
* \#1112 `db:create_indexes` no longer indexes subclasses multiple times.
|
3074
|
+
|
3075
|
+
* \#1111, \#1098 Don't set `_id` in `$set` operations.
|
3076
|
+
|
3077
|
+
* \#1007 Update attribute properly tracks array changes.
|
3078
|
+
|
3079
|
+
## 2.1.4
|
3080
|
+
|
3081
|
+
This was a specific release to get a Psych generated gemspec so no more parse errors would occur on those rubies that were using the new YAML parser.
|
3082
|
+
|
3083
|
+
## 2.1.3
|
3084
|
+
|
3085
|
+
### Resolved Issues
|
3086
|
+
|
3087
|
+
* \#1109 Fixed validations not loading one to ones into memory.
|
3088
|
+
|
3089
|
+
* \#1107 Mongoid no longer wants required `mongoid/railtie` in `application.rb`.
|
3090
|
+
|
3091
|
+
* \#1102 Fixed nested attributes deletion.
|
3092
|
+
|
3093
|
+
* \#1097 Reload now runs `after_initialize` callbacks.
|
3094
|
+
|
3095
|
+
* \#1079 Embeds many no longer duplicates documents.
|
3096
|
+
|
3097
|
+
* \#1078 Fixed array criteria matching on embedded documents.
|
3098
|
+
|
3099
|
+
* \#1028 Implement scoped on one-to-many and many-to-many relations.
|
3100
|
+
|
3101
|
+
* \#988 Many-to-many clear no longer deletes the child documents.
|
3102
|
+
|
3103
|
+
* \#977 Autosaving relations works also through nested attributes.
|
3104
|
+
|
3105
|
+
* \#972 Recursive embedding now handles namespacing on generated names.
|
3106
|
+
|
3107
|
+
* \#943 Don't override `Document#attributes`.
|
3108
|
+
|
3109
|
+
* \#893 Verify count is not caching on many to many relations.
|
3110
|
+
|
3111
|
+
* \#815 Verify `after_initialize` is run in the correct place.
|
3112
|
+
|
3113
|
+
* \#793 Verify `any_of` scopes chain properly with any other scope.
|
3114
|
+
|
3115
|
+
* \#776 Fixed mongoid case quality when dealing with subclasses.
|
3116
|
+
|
3117
|
+
* \#747 Fixed complex criteria using its keys to render its string value.
|
3118
|
+
|
3119
|
+
* \#721 `#safely` now properly raises validation errors when they occur.
|
3120
|
+
|
3121
|
+
## 2.1.2
|
3122
|
+
|
3123
|
+
### Resolved Issues
|
3124
|
+
|
3125
|
+
* \#1082 Alias `size` and `length` to `count` on criteria. (Adam Greene)
|
3126
|
+
|
3127
|
+
* \#1044 When multiple relations are defined for the same class, always return the default inverse first if `inverse_of` is not defined.
|
3128
|
+
|
3129
|
+
* \#710 Nested attributes accept both `id` and `_id` in hashes or arrays.
|
3130
|
+
|
3131
|
+
* \#1047 Ignore `nil` values passed to `embeds_man` pushes and substitution. (Derick Bailey)
|
3132
|
+
|
3133
|
+
## 2.1.1
|
3134
|
+
|
3135
|
+
### Resolved Issues
|
3136
|
+
|
3137
|
+
* \#1021, \#719 Many to many relations dont trigger extra database queries when pushing new documents.
|
3138
|
+
|
3139
|
+
* \#607 Calling `create` on large associations does not load the entire relation.
|
3140
|
+
|
3141
|
+
* \#1064 `Mongoid::Paranoia` should respect `unscoped` and `scoped`.
|
3142
|
+
|
3143
|
+
* \#1026 `model#update_attribute` now can update booleans to `false`.
|
3144
|
+
|
3145
|
+
* \#618 Crack XML library breaks Mongoid by adding `#attributes` method to the `String` class. (Stephen McGinty)
|
3146
|
+
|
3147
|
+
## 2.1.0
|
3148
|
+
|
3149
|
+
### Major Changes
|
3150
|
+
|
3151
|
+
* Mongoid now requires MongoDB 1.8.x in order to properly support the `#bit` and `#rename` atomic operations.
|
3152
|
+
|
3153
|
+
* Traditional slave support has been removed from Mongoid. Replica sets should be used in place of traditional master and slave setups.
|
3154
|
+
|
3155
|
+
* Custom field serialization has changed. Please see [serializable](https://github.com/mongoid/mongoid/blob/master/lib/mongoid/fields/serializable.rb) for changes.
|
3156
|
+
|
3157
|
+
* The dirty attribute tracking has been switched to use ActiveModel, this brings many bug fixes and changes:
|
3158
|
+
|
3159
|
+
* \#756 After callbacks and observers see what was changed instead of changes just made being in previous_changes
|
3160
|
+
|
3161
|
+
* \#434 Documents now are flagged as dirty when brand new or the state on instantiation differs from the database state. This is consistent with ActiveRecord.
|
3162
|
+
|
3163
|
+
* \#323 Mongoid now supports [field]_will_change! from ActiveModel::Dirty
|
3164
|
+
|
3165
|
+
* Mongoid model preloading in development mode now defaults to `false`.
|
3166
|
+
|
3167
|
+
* `:autosave => true` on relational associations now saves on update as well as create.
|
3168
|
+
|
3169
|
+
* Mongoid now has an identity map for simple `find_by_id` queries. See the website for documentation.
|
3170
|
+
|
3171
|
+
### New Features
|
3172
|
+
|
3173
|
+
* \#1067 Fields now accept a `:versioned` attribute to be able to disable what fields are versioned with `Mongoid::Versioning`. (Jim Benton)
|
3174
|
+
|
3175
|
+
* \#587 Added order preference to many and many to many associations. (Gregory Man)
|
3176
|
+
|
3177
|
+
* Added ability to chain `order_by` statements. (Gregory Man)
|
3178
|
+
|
3179
|
+
* \#961 Allow arbitrary `Mongo::Connection` options to pass through `Mongoid::Config::Database` object. (Morgan Nelson)
|
3180
|
+
|
3181
|
+
* Enable `autosave` for many to many references. (Dave Krupinski)
|
3182
|
+
|
3183
|
+
* The following explicit atomic operations have been added: `Model#bit`, `Model#pop`, `Model#pull`, `Model#push_all`, `Model#rename`, `Model#unset`.
|
3184
|
+
|
3185
|
+
* Added exception translations for Hindi. (Sukeerthi Adiga)
|
3186
|
+
|
3187
|
+
### Resolved Issues
|
3188
|
+
|
3189
|
+
* \#974 Fix `attribute_present?` to work correctly then attribute value is `false`, thanks to @nickhoffman. (Gregory Man)
|
3190
|
+
|
3191
|
+
* \#960 create indexes rake task is not recognizing a lot of mongoid models because it has problems guessing their model names from filenames. (Tobias Schlottke)
|
3192
|
+
|
3193
|
+
* \#874 Deleting from a M-M reference is one-sided. (nickhoffman, davekrupinski)
|
3194
|
+
|
3195
|
+
* Replace deprecated `class_inheritable_hash` dropped in Rails 3.1+. (Konstantin Shabanov)
|
3196
|
+
|
3197
|
+
* Fix inconsistent state when replacing an entire many to many relation.
|
3198
|
+
|
3199
|
+
* Don't clobber inheritable attributes when adding subclass field inheritance. (Dave Krupinski)
|
3200
|
+
|
3201
|
+
* \#914 Querying embedded documents with `$or` selector. (Max Golovnia)
|
3202
|
+
|
3203
|
+
* \#514 Fix marshaling of documents with relation extensions. (Chris Griego)
|
3204
|
+
|
3205
|
+
* `Metadata#extension` now returns a `Module`, instead of a `Proc`, when an extension is defined.
|
3206
|
+
|
3207
|
+
* \#837 When `allow_dynamic_fields` is set to `false` and loading an embedded document with an unrecognized field, an exception is raised.
|
3208
|
+
|
3209
|
+
* \#963 Initializing array of embedded documents via hash regressed (Chris Griego, Morgan Nelson)
|
3210
|
+
|
3211
|
+
* `Mongoid::Config.reset` resets the options to their default values.
|
3212
|
+
|
3213
|
+
* `Mongoid::Fields.defaults` is memoized for faster instantiation of models.
|