DDC-1292: Porting problem with timetamp between sqlite and mysql #1624

Closed
opened 2026-01-22 13:20:15 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 25, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user pejot:

There is a problem with the mapping of TIMESTAMP:
/****

  • @Table(name="users")
  • @Entity
    /
    class User {
    (...)
    /
    ***
    • @Column(name="register_date",columnDefinition="TIMESTAMP")
    • @var string
      */
      protected $registerDate;
      }

While using SQLITE you have to give an INT value otherwise you will get 1970-01-01 01:00:00 as the persisted timestamp,
on MySQL you have to put a string value eg 2011-01-01 00:00:00 otherwise you will get "0000-00-00 00:00:00"

Is quite a big problem when your testing env has other engine than production, than tests against those values are redundant.

Originally created by @doctrinebot on GitHub (Jul 25, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user pejot: There is a problem with the mapping of TIMESTAMP: /**** - @Table(name="users") - @Entity _/ class User { (...) /_*** - @Column(name="register_date",columnDefinition="TIMESTAMP") - @var string */ protected $registerDate; } While using SQLITE you have to give an INT value otherwise you will get 1970-01-01 01:00:00 as the persisted timestamp, on MySQL you have to put a string value eg 2011-01-01 00:00:00 otherwise you will get "0000-00-00 00:00:00" Is quite a big problem when your testing env has other engine than production, than tests against those values are redundant.
admin added the Bug label 2026-01-22 13:20:15 +01:00
admin closed this issue 2026-01-22 13:20:17 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 25, 2011):

Comment created by @beberlei:

As the docs say, columnDefinition is not portable. You should write your own type and convert it properly to a DateTime instance or something, see custom mapping type section in the docs.

@doctrinebot commented on GitHub (Jul 25, 2011): Comment created by @beberlei: As the docs say, columnDefinition is not portable. You should write your own type and convert it properly to a DateTime instance or something, see custom mapping type section in the docs.
Author
Owner

@doctrinebot commented on GitHub (Jul 25, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jul 25, 2011): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1624