Skip to content

Commit 8d3e4d3

Browse files
review: bigint-unsigned warning names the real hazard (describe round-trip) and the lossless escape hatch (decimal(20,0)); fix the match-vs-fullmatch comment
1 parent 84d1401 commit 8d3e4d3

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/datajoint/heading.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,10 @@ def _init_from_database(self) -> None:
484484
in_key=(attr["key"] == "PRI"),
485485
nullable=attr["nullable"], # Already boolean from parse_column_info
486486
autoincrement=bool(re.search(r"auto_increment", attr["extra"], flags=re.I)),
487-
# NOTE: these use prefix matching, unlike match_type() which requires a
488-
# full match. attr["type"] is reported by the server and is not
489-
# normalized, so PostgreSQL spellings such as "double precision" and
490-
# "timestamp without time zone" are matched on their leading word.
487+
# NOTE: .match() here is equivalent to .fullmatch() — every pattern in
488+
# these tuples is anchored with $ — so this is not prefix matching.
489+
# Server-reported spellings match because the patterns themselves cover
490+
# them, not because of the matching mode.
491491
numeric=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("DECIMAL", "NUMERIC", "INTEGER", "FLOAT")),
492492
string=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("ENUM", "TEMPORAL", "STRING")),
493493
is_blob=any(TYPE_PATTERN[t].match(attr["type"]) for t in ("BYTES", "NATIVE_BLOB")),

src/datajoint/migrate.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,13 @@ def analyze_columns(schema: Schema) -> dict:
202202
logger.warning(
203203
f"Column `{col_info['table']}`.`{col_info['column']}` is "
204204
"`bigint unsigned` and will be labeled `int64`. DataJoint 2.0 "
205-
"provides no unsigned integer types; values above 2**63-1 do "
206-
"not fit in int64. Verify the stored range before migrating."
205+
"provides no unsigned integer types. The physical column and "
206+
"stored data are unchanged by migration, but `describe()` will "
207+
"report `int64`, so a describe->recreate->copy round trip "
208+
"produces a signed column: values above 2**63-1 do not survive "
209+
"that copy. Verify the stored range before migrating; if the "
210+
"full unsigned range is in use, declare the attribute as "
211+
"decimal(20,0), which holds it losslessly."
207212
)
208213
result["needs_migration"].append(col_info)
209214
# Types that don't need migration (varchar, date, datetime, json, etc.)

0 commit comments

Comments
 (0)