Skip to content

Commit efc04bc

Browse files
committed
update user guide
1 parent 472d954 commit efc04bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

user_guide_src/source/models/model.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,19 @@ converted to strings with the format defined in ``dateFormat['datetime']`` and
648648
.. note:: Prior to v4.5.0, the date/time formats were hard coded as ``Y-m-d H:i:s``
649649
and ``Y-m-d`` in the Model class.
650650

651+
Primary Key Validation
652+
----------------------
653+
654+
.. versionadded:: 4.7.0
655+
656+
The ``insert()``, ``insertBatch()`` (when `$useAutoIncrement`_ is ``false``), ``update()``,
657+
and ``delete()`` methods validate primary key values before executing database queries.
658+
Invalid values such as ``null``, ``0``, ``'0'``, empty strings, booleans, empty arrays,
659+
or nested arrays will throw an ``InvalidArgumentException`` with a specific error message.
660+
661+
If you need to customize this behavior (e.g., to allow ``0`` as a valid primary key for
662+
legacy systems), you can override the ``validateID()`` method in your model.
663+
651664
Deleting Data
652665
=============
653666

0 commit comments

Comments
 (0)