Phalcon 2.0.10 MetaData Bug Default Values
If a table doenst have a auto-increment column metadata cannot read the defaults value, so when save get error column is required instead of read default values
So with auto-increment works fine but without all fields with default value ask to be filled
Example
column date_created = default_value = CURRENT_TIMESTAMP. column status = default_value = 'active'
so to work i created a ID column INT auto increment and set as Primary key.
Phalcon 2.0.10 + Nginx 1.9.3 + PHP 5.6 FPM + MariaDB 10.1
*Steps *
CREATE TABLE `test` (
`name` varchar(255) NOT NULL ,
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (`name`)
)
$model = new Test();
$test->save(['name' => 'hello']);
~~Happens on 2.1.0RC too, but in my case it goes a bit worse.~~ ~~When I save a relation like~~
$order->entries = [$entries];
$order->update();
~~It nulls the created_at on the order too.~~
Found the problem on my side, the dynamic update has be setted on every instance of the model, while I was using on the onConstruct()
here if is the primary key does not have a auto-increment, default values dont load