Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value for datetime type not working for sqlite #7309

Open
elfin-sbreuers opened this issue Jul 13, 2018 · 3 comments
Open

Default value for datetime type not working for sqlite #7309

elfin-sbreuers opened this issue Jul 13, 2018 · 3 comments

Comments

@elfin-sbreuers
Copy link

elfin-sbreuers commented 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.

@caciobanu
Copy link
Contributor

You have to change your annotation to:

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

@Majkl578
Copy link
Contributor

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

@elfin-sbreuers
Copy link
Author

@caciobanu: Thanks. Works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants