Skip to content

non-lower-case attribute types now fail  #547

@ixcat

Description

@ixcat

Looks like fbde1325c8 breaks anything that is using upper/mixed case for the datatype field.

#! /usr/bin/env python

import os
import datajoint as dj

schema = dj.schema('test_decimal')

@schema
class MyDecimal(dj.Manual):
    definition = '''
    id: int
    ---
    thing: Decimal(3,2)
    '''


schema.drop(force=True)

which previously worked, noow yields:

Connecting chris@localhost:3306
Traceback (most recent call last):
  File "./test-decimal.py", line 11, in <module>
    class MyDecimal(dj.Manual):
  File "/Users/chris/src/djc/datajoint-python/datajoint/schema.py", line 207, in __call__
    self.process_relation_class(cls, context=dict(context, self=cls, **{cls.__name__: cls}))
  File "/Users/chris/src/djc/datajoint-python/datajoint/schema.py", line 185, in process_relation_class
    instance.declare(context)
  File "/Users/chris/src/djc/datajoint-python/datajoint/table.py", line 63, in declare
    sql, uses_external = declare(self.full_table_name, self.definition, context)
  File "/Users/chris/src/djc/datajoint-python/datajoint/declare.py", line 231, in declare
    name, sql, is_external = compile_attribute(line, in_key, foreign_key_sql)
  File "/Users/chris/src/djc/datajoint-python/datajoint/declare.py", line 278, in compile_attribute
    raise DataJointError('DataJoint does not support datatype "{type}"'.format(**match))
datajoint.errors.DataJointError: DataJoint does not support datatype "Decimal(3,2)"

Downcasing the attribute type appears to resolve the issue:

index 1699999..9d45eeb 100644
--- a/datajoint/declare.py
+++ b/datajoint/declare.py
@@ -274,7 +274,7 @@ def compile_attribute(line, in_key, foreign_key_sql):
     acceptable_datatype_pattern = r'^(time|date|year|enum|(var)?char|float|real|double|decimal|numeric|' \
                                   r'(tiny|small|medium|big)?int|bool|' \
                                   r'(tiny|small|medium|long)?blob|external|attach)'
-    if re.match(acceptable_datatype_pattern, match['type']) is None:
+    if re.match(acceptable_datatype_pattern, match['type'].lower()) is None:
         raise DataJointError('DataJoint does not support datatype "{type}"'.format(**match))
 
     literals = ['CURRENT_TIMESTAMP']   # not to be enclosed in quotes```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions