datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

`current_timestamp()` not treated as sql literal

Open christoph-blessing opened this issue 2 years ago • 4 comments
trafficstars

Bug Report

Description

@schema
class Table(dj.Manual):
    definition = """
        t = CURRENT_TIMESTAMP : timestamp
    """

@schema  # pymysql.err.OperationalError: (1067, "Invalid default value for 't'")
class Copy(dj.Manual):
    definition = (Table().heading)  # or 'Table().describe()'

In my case the server returns current_timestamp() as the default value for t but that value is not treated as a sql literal by datajoint. Therefore datajoint surrounds the value with quotation marks making it an invalid default value and leading to the error. One fix is to add current_timestamp() to the list of literals here. I would be happy to make a PR if you agree with that fix.

Reproducibility

  • DataJoint Version 0.14.1
  • MariaDB Version 10.3.38

christoph-blessing avatar Oct 04 '23 15:10 christoph-blessing

This doesn't happen when using mysql 5.7.33.

christoph-blessing avatar Oct 05 '23 13:10 christoph-blessing