Default value for datetime type not working for sqlite #6019

Open
opened 2026-01-22 15:24:51 +01:00 by admin · 3 comments
Owner

Originally created by @elfin-sbreuers on GitHub (Jul 13, 2018).

The following annotation

    /**
     * @ORM\Column(name="changed_at", type="datetime", options={"default": 0})
     */
    private $changedAt;

should produce this outcome in sqlite

changed_at DATETIME DEFAULT CURRENT_TIMESTAMP

but produces

changed_at DATETIME DEFAULT '0' NOT NULL

in version 2.6.2.

Did something change in the API or is this a bug?

Thanks in advance.

Originally created by @elfin-sbreuers on GitHub (Jul 13, 2018). The following annotation ``` /** * @ORM\Column(name="changed_at", type="datetime", options={"default": 0}) */ private $changedAt; ``` should produce this outcome in sqlite `changed_at DATETIME DEFAULT CURRENT_TIMESTAMP` but produces `changed_at DATETIME DEFAULT '0' NOT NULL` in version 2.6.2. Did something change in the API or is this a bug? Thanks in advance.
Author
Owner

@caciobanu commented on GitHub (Jul 13, 2018):

You have to change your annotation to:

    /**
     * @ORM\Column(name="changed_at", type="datetime", options={"default": "CURRENT_TIMESTAMP"})
     */
    private $changedAt;
@caciobanu commented on GitHub (Jul 13, 2018): You have to change your annotation to: ```php /** * @ORM\Column(name="changed_at", type="datetime", options={"default": "CURRENT_TIMESTAMP"}) */ private $changedAt; ```
Author
Owner

@Majkl578 commented on GitHub (Jul 13, 2018):

0 definitely doesn't look correct, was it ever working before?
There were some changes affecting CURRENT_TIMESTAMP, see https://github.com/doctrine/doctrine2/issues/6698 / https://github.com/doctrine/dbal/issues/2859, but those should be resolved as of DBAL 2.7.

@Majkl578 commented on GitHub (Jul 13, 2018): `0` definitely doesn't look correct, was it ever working before? There were some changes affecting `CURRENT_TIMESTAMP`, see https://github.com/doctrine/doctrine2/issues/6698 / https://github.com/doctrine/dbal/issues/2859, but those should be resolved as of DBAL 2.7.
Author
Owner

@elfin-sbreuers commented on GitHub (Jul 16, 2018):

@caciobanu: Thanks. Works like a charm.

@elfin-sbreuers commented on GitHub (Jul 16, 2018): @caciobanu: Thanks. Works like a charm.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6019