Skip to main content

Function: isIdColumn()

isIdColumn(name): boolean

Defined in: src/core/id_columns.ts:72

A join-key column: its last dotted segment marks an id (id, *_id, *_ids, athlete_id_1, id_play, drive_play_id_started, hometeam_teamid, playerId, homeTeamId; dotted start.team.id), or it is a listed id column (MLBAM: batter, on_1b, game_pk, ...; stats.nba.com hid / vid). The one id-name predicate: every surface and the parity harness use it.

Parameters​

name​

string

A column name, possibly dotted (participants.0.athlete.id); only the part after the last . is tested against the segment pattern, the whole name against the listed exact ids.

Returns​

boolean

true when the column holds ids and must be decimal strings (the v4 id rule).

Remarks​

Case matters: lower-case id must stand alone or touch _, camelCase needs the capital I, so valid, paid, idle, Idaho, width, event_idx, ID, ids, pk never match. The only words allowed after id_ / _id_ are a number, started, ended, play, drive; team_id_source, *_sportec_id_overwrite and player_id_list are not ids. tools/codegen/id-columns.mjs transpiles this file, so the generated row types use the same predicate.

Example​

import { isIdColumn } from "./id_columns.js";
isIdColumn("game_id"); // true
isIdColumn("start.team.id"); // true (last dotted segment)
isIdColumn("homeTeamId"); // true
isIdColumn("game_pk"); // true (listed MLBAM id)
isIdColumn("team_id_source"); // false