@@ -114,12 +114,12 @@ def build_foreign_key_parser():
114
114
return arrow + options + ref_table
115
115
116
116
117
- def build_attribute_parser (parse_metadata = False ):
117
+ def build_attribute_parser ():
118
118
quoted = pp .QuotedString ('"' ) ^ pp .QuotedString ("'" )
119
119
colon = pp .Literal (":" ).suppress ()
120
- attribute_name = pp .Word (
121
- pp . srange ( f"[a-z { '_' if parse_metadata else '' } ]" ), pp . srange ( "[a-z0-9_]" )
122
- ). setResultsName ( "name" )
120
+ attribute_name = pp .Word (pp . srange ( "[a-z]" ), pp . srange ( "[a-z0-9_]" )). setResultsName (
121
+ "name"
122
+ )
123
123
data_type = (
124
124
pp .Combine (pp .Word (pp .alphas ) + pp .SkipTo ("#" , ignore = quoted ))
125
125
^ pp .QuotedString ("<" , endQuoteChar = ">" , unquoteResults = False )
@@ -134,7 +134,6 @@ def build_attribute_parser(parse_metadata=False):
134
134
foreign_key_parser_old = build_foreign_key_parser_old ()
135
135
foreign_key_parser = build_foreign_key_parser ()
136
136
attribute_parser = build_attribute_parser ()
137
- metadata_attribute_parser = build_attribute_parser (parse_metadata = True )
138
137
139
138
140
139
def is_foreign_key (line ):
@@ -246,7 +245,6 @@ def prepare_declare(definition, context):
246
245
foreign_key_sql = []
247
246
index_sql = []
248
247
external_stores = []
249
- metadata_attributes = ["_timestamp = CURRENT_TIMESTAMP : timestamp" ]
250
248
251
249
for line in definition :
252
250
if not line or line .startswith ("#" ): # ignore additional comments
@@ -274,12 +272,6 @@ def prepare_declare(definition, context):
274
272
if name not in attributes :
275
273
attributes .append (name )
276
274
attribute_sql .append (sql )
277
- for line in metadata_attributes :
278
- name , sql , store = compile_attribute (
279
- line , in_key , foreign_key_sql , context , is_metadata = True
280
- )
281
- attributes .append (name )
282
- attribute_sql .append (sql )
283
275
284
276
return (
285
277
table_comment ,
@@ -316,6 +308,7 @@ def declare(full_table_name, definition, context):
316
308
index_sql ,
317
309
external_stores ,
318
310
) = prepare_declare (definition , context )
311
+ attribute_sql .extend (["`_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" ])
319
312
320
313
if not primary_key :
321
314
raise DataJointError ("Table must have a primary key" )
@@ -504,22 +497,18 @@ def substitute_special_type(match, category, foreign_key_sql, context):
504
497
assert False , "Unknown special type"
505
498
506
499
507
- def compile_attribute (line , in_key , foreign_key_sql , context , is_metadata = False ):
500
+ def compile_attribute (line , in_key , foreign_key_sql , context ):
508
501
"""
509
502
Convert attribute definition from DataJoint format to SQL
510
503
511
504
:param line: attribution line
512
505
:param in_key: set to True if attribute is in primary key set
513
506
:param foreign_key_sql: the list of foreign key declarations to add to
514
507
:param context: context in which to look up user-defined attribute type adapterss
515
- :param is_metadata: flag to use an alternate parser for metadata attributes
516
508
:returns: (name, sql, is_external) -- attribute name and sql code for its declaration
517
509
"""
518
510
try :
519
- if is_metadata :
520
- match = metadata_attribute_parser .parseString (line + "#" , parseAll = True )
521
- else :
522
- match = attribute_parser .parseString (line + "#" , parseAll = True )
511
+ match = attribute_parser .parseString (line + "#" , parseAll = True )
523
512
except pp .ParseException as err :
524
513
raise DataJointError (
525
514
"Declaration error in position {pos} in line:\n {line}\n {msg}" .format (
0 commit comments