Skip to content

Commit 793d0b3

Browse files
fix: allow inline comments on index declarations
The regex matching index lines in table definitions required exact end-of-line after the closing paren, rejecting valid declarations like `index(y, z) # for efficient coronal slice queries`. Updated regex to accept optional trailing comments and strip them before passing to compile_index. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1c99dc2 commit 793d0b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/datajoint/declare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ def prepare_declare(
370370
adapter,
371371
fk_attribute_map,
372372
)
373-
elif re.match(r"^(unique\s+)?index\s*\(.*\)$", line, re.I): # index
374-
compile_index(line, index_sql, adapter)
373+
elif re.match(r"^(unique\s+)?index\s*\(.*\)\s*(#.*)?$", line, re.I): # index
374+
compile_index(re.sub(r"\s*#.*$", "", line), index_sql, adapter)
375375
else:
376376
name, sql, store, comment = compile_attribute(line, in_key, foreign_key_sql, context, adapter)
377377
if store:

0 commit comments

Comments
 (0)