yiisoft / yiisoft/db

Inconsistent behavior of datetime/timestamp in v2

Open
#1,168 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:ready for adoption type:bug
Dominant language
PHP
Stars
216
Forks
51
Avg merge
3d 10h
Merged PRs (30d)
2

Description

Description

Columns created as $columnBuilderClass::timestamp(6) are parsed back as

  • ColumnType::TIMESTAMP - in MySQL, SQLite.
  • ColumnType::DATETIME — in MSSQL, PostgreSQL, Oracle

Also, it seems a bit strange that default for timestamp/datetime is 0, not null reducing precision to 1 second instead of max supported.

    public static function timestamp(?int $size = 0): ColumnInterface
    public static function datetime(?int $size = 0): ColumnInterface
Package version

2.0

PHP version

8.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the column-builder entry points timestamp(?int $size = 0) and datetime(?int $size = 0), then trace how MySQL, SQLite, MSSQL, PostgreSQL, and Oracle parse the resulting columns. Compare the type and default-precision behavior across drivers; the issue is done when the intended type and default semantics are consistent and covered by regression tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php, postgresql, sql, sqlite
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.