-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 8.0.2
-
Component/s: Persistence
-
Fully Compatible
There are two steps to this ticket:
when readonly? is true, prohibit saving/updating the document
change readonly? to be true, only when readonly! is called
The current implementation of readonly? is:
def readonly? __selected_fields != nil end
Original Ticket
--------------
example
class Foo include Mongoid::Document field :name, type: String def readonly? true end end x = Foo.create(name: 'test') x.name = 'something else' x.save # true # expected to raise a Mongoid::Errors::ReadonlyDocument exception
while
x = Foo.create(name: 'test')
x.destroy
properly raises an Mongoid::Errors::ReadonlyDocument exception
possibly related to https://jira.mongodb.org/browse/MONGOID-5072
- is related to
-
MONGOID-3535 Using mongoid 'only' or 'without' creates read-only objects
- Closed
-
MONGOID-5477 Document readonly? override
- Closed
-
MONGOID-5478 Use "read-only" in documentation
- Closed
- related to
-
MONGOID-4701 Allow writing fields omitted in #only
- Backlog