feat(inspector): text primary keys collide and cannot be referenced — emit serial for varchar/char keys
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start in the schema inspector's handling of varchar and char primary keys, where they currently become random char[1..n] values, and in the ref[...] generation for foreign keys that point at them. Check how the database destination binds integers into varchar columns. Done when a text PK inspects as serial with the review comment, a child FK resolves against the parent, and a Northwind-style schema loads without duplicate or missing-key errors. Composite and non-key text columns must stay unchanged.
Written by the indexing model from the issue text.
Description
Summary
A primary key on a text column (varchar(n) / char(n)) is inspected as random char[1..n] with # UNIQUE/PRIMARY KEY not enforced — values may collide. Two consequences:
- The parent table collides on its own PK — with
char[1..5]many values are 1–2 chars long, so duplicates come within the first batch:
ERROR: duplicate key value violates unique constraint "pk_customer_demographics" — Key (customer_type_id)=(L) already exists - Children can never match it — the FK side is inspected as
ref[customers.customer_id, 1..count], which emits integers, while the parent holds random strings:
ERROR: ... violates foreign key constraint "fk_orders_customers" — Key (customer_id)=(33) is not present in table "customers"
Text keys are common (Northwind: customers.customer_id varchar(5), territories.territory_id varchar(20), customer_demographics.customer_type_id varchar(5); ISO codes, SKUs, legacy schemas), and this breaks every FK pointing at them.
Observation
The tools already exist: the database destination binds an integer into a varchar key column without complaint (PostgreSQL assignment cast — verified with serial into varchar(5)), and ref[parent.key, 1..N] over a serial parent produces matching values. So a text PK inspected as serial (or unique[...] for a non-dense key) gives a collision-free parent and FK children that resolve, with no new type.
Suggested fix
- Text PK / UNIQUE column of width
n→serial(dense) with a review comment:# text key generated as numeric strings — max 10^n − 1 rows(ties into the capacity work in #440). - Leave composite keys with text parts, and non-key text columns, as they are today.
- Optional, later: a formatted string key (prefix / zero-padding) so values look like the source system's (
ALFKI-style codes need a deterministic string permutation; out of scope here).
Workaround
Hand-edit the text PK fields to serial. Keep the parent's row count within the column width (varchar(5) → ≤ 99 999 rows).
Related: #440.
Update (2026-11-04) — verified on 4 vendors
Throw-away probe through the real JdbcTypeMapper (setLong):
| PostgreSQL 16 | MySQL 8.4 | SQL Server 2022 | Oracle Free | |
|---|---|---|---|---|
integer into VARCHAR(5) PK, text FK child |
OK | OK | OK | OK |
integer into CHAR(5) PK (padded) + FK |
OK | OK | OK | OK |
123456 into VARCHAR(5) |
fails | fails | fails | fails |
So serial for text keys needs no new type, but it needs the width ceiling (serial[1..10^n − 1], see #440 part 2). The same text keys appear in every vendor's Northwind (nchar(5) / varchar(5) / VARCHAR2(5) CustomerID). For UNIQUE text columns with a semantic hint (e.g. email), see #455.
Phase B (optional): formatted string keys (C00042) so JSON/Avro keep string types — needs the parent-aware references of #442.
- Dominant language
- Java
- Stars
- 3
- Forks
- 4
- Avg merge
- 8h 10m
- Merged PRs (30d)
- 9
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mferretti/SeedStream
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mferretti/SeedStream#443 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mferretti/SeedStream#438 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 56/100
mferretti/SeedStream#459 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 4/5 1-2 days Newbie friendliness 57/100
mferretti/SeedStream#458 ·
Maintainers usually reply within 4 days
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
mferretti/SeedStream#457 ·
Maintainers usually reply within 4 days
All issues in mferretti/SeedStream
Similar issues
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
MCP add-on: JSON responses with non-ASCII characters are truncated (wrong Content-Length)Possibly taken @dhanushbs10 claimed this today. Openadd-on bug in:mcp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
vaadin-map
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vaadin/flow-components#10586 ·
Maintainers usually reply within 1 day
-
WeReadInstaller writes the launcher database on the main thread at handover (Activity pause timeout)Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
wpilibsuite/SystemcoreTesting#446 ·
Maintainers usually reply within 1 day