cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Phalcon 2.0.10 MetaData Bug Default Values

Open renatogabrielbr opened this issue 10 years ago • 3 comments

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

renatogabrielbr avatar Mar 31 '16 03:03 renatogabrielbr

*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']);

renatogabrielbr avatar Mar 31 '16 04:03 renatogabrielbr

~~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()

hisorange avatar Apr 07 '16 10:04 hisorange

here if is the primary key does not have a auto-increment, default values dont load

renatogabrielbr avatar Apr 08 '16 04:04 renatogabrielbr