MySQL TIMESTAMP with fractional second part is reflected incorrectly

Issue #3602 resolved
immerrr again created an issue

It happens because sqlalchemy.dialects.mysql.base.TIMESTAMP has timezone kwarg as its first argument, so TIMESTAMP(3) is incorrectly parsed as TIMESTAMP(timezone=3) instead of TIMESTAMP(fsp=3).

Reproduced on sqlalchemy-1.0.9.

Comments (7)

  1. immerrr again reporter

    Sure. I guess I have spent too much time (more than I should be) writing bug reports recently and this one felt too obvious. Is this OK:

    >>> engine.execute('create table foobar(ts timestamp(3));')
    <sqlalchemy.engine.result.ResultProxy at 0x7f990fc2ba50>
    >>> sa.inspect(engine).get_columns('foobar')
    [{'default': None,
      'name': u'ts',
      'nullable': False,
      'type': TIMESTAMP(timezone=3)}]
    
  2. Mike Bayer repo owner
    • Fixed bug in MySQL reflection where the "fractional sections portion" of the :class:.mysql.DATETIME, :class:.mysql.TIMESTAMP and :class:.mysql.TIME types would be incorrectly placed into the timestamp attribute, which is unused by MySQL, instead of the fsp attribute. fixes #3602

    → <<cset 3f42743d6aa1>>

  3. Mike Bayer repo owner
    • Fixed bug in MySQL reflection where the "fractional sections portion" of the :class:.mysql.DATETIME, :class:.mysql.TIMESTAMP and :class:.mysql.TIME types would be incorrectly placed into the timestamp attribute, which is unused by MySQL, instead of the fsp attribute. fixes #3602

    (cherry picked from commit 3f42743d6aa1326a80a0ed720a92266aa5fbf209)

    → <<cset f3137aa45998>>

  4. immerrr again reporter

    Thank you for the quick fix! (there's a typo in the changelog message: the attribute is timezone, not timestamp)

  5. Log in to comment