[BUG]: SQLite adapter does not support NOT NULL
columns with default values
#15180
Labels
bug
A bug report
NOT NULL
columns with default values
#15180
Describe the bug
When creating a new Model the Adapter will throw an Exception like the following, if:
The SQLite adapter will create the following statement:
NULL
is inserted for the 3 unset fields, becauseDb\Adapter\Pdo\Sqlite::getDefaultValue()
returnsnew RawValue('NULL')
for any unset fields that have default values inMetaData
(This works well for MySQL withRawValue('DEFAULT')
)To Reproduce
Tested here: https://github.com/phalcon/cphalcon/pull/15179/checks?check_run_id=1271542325
Proposed solution:
Modify
Db\Adapter::getDefaultValue()
to returnfalse
when it's not supported by the adapter. (Breaks BC, maybe a new method could be added until 6.0)Modify
Mvc\Model
not to include these fields in the statements when the adapter doesn't support it:cc @phalcon/core-team
The text was updated successfully, but these errors were encountered: