@@ -499,6 +499,7 @@ def create(
499
499
query : bool = False ,
500
500
id_key : str = "id" ,
501
501
cast : bool = False ,
502
+ ignore_mass_assignment : bool = False ,
502
503
** kwargs ,
503
504
):
504
505
"""Specifies a dictionary that should be used to create new values.
@@ -518,7 +519,8 @@ def create(
518
519
# Update values with related record's
519
520
self ._creates .update (self ._creates_related )
520
521
# Filter __fillable/__guarded__ fields
521
- self ._creates = model .filter_mass_assignment (self ._creates )
522
+ if not ignore_mass_assignment :
523
+ self ._creates = model .filter_mass_assignment (self ._creates )
522
524
# Cast values if necessary
523
525
if cast :
524
526
self ._creates = model .cast_values (self ._creates )
@@ -1388,6 +1390,7 @@ def update(
1388
1390
dry : bool = False ,
1389
1391
force : bool = False ,
1390
1392
cast : bool = False ,
1393
+ ignore_mass_assignment : bool = False ,
1391
1394
):
1392
1395
"""Specifies columns and values to be updated.
1393
1396
@@ -1396,6 +1399,7 @@ def update(
1396
1399
dry {bool, optional}: Do everything except execute the query against the DB
1397
1400
force {bool, optional}: Force an update statement to be executed even if nothing was changed
1398
1401
cast {bool, optional}: Run all values through model's casters
1402
+ ignore_mass_assignment {bool, optional}: Whether the update should ignore mass assignment on the model
1399
1403
1400
1404
Returns:
1401
1405
self
@@ -1407,7 +1411,8 @@ def update(
1407
1411
if self ._model :
1408
1412
model = self ._model
1409
1413
# Filter __fillable/__guarded__ fields
1410
- updates = model .filter_mass_assignment (updates )
1414
+ if not ignore_mass_assignment :
1415
+ updates = model .filter_mass_assignment (updates )
1411
1416
1412
1417
if model and model .is_loaded ():
1413
1418
self .where (model .get_primary_key (), model .get_primary_key_value ())
0 commit comments