Repository navigation
#3822: generated repositories keep the mainframe's key order - #3874
Merged
Merged
Conversation
A KSDS browse follows the key's EBCDIC bytes (lower case before upper, letters before digits); databases' default collations fold case and accents, so MySQL merged distinct COBOL keys on the primary key and every database browsed in another order. culture.key_collation: - ebcdic (default): a String key gets a <KEY>_SORT column -- its code-page bytes in hex, set by @PrePersist/@PreUpdate through the new CobolRecords.sortKey(key, codePage) -- and the STARTBR/READNEXT/READPREV finders range over and order by it; the services pass the sort key. - ebcdic and binary: String key columns (and group-key text parts) collate byte-wise: COLLATE "C" on PostgreSQL, utf8mb4_bin on MySQL. - database: the output of before. A porting rule orders keys by code-page bytes, never compareTo or the database's collation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3822 (epic #3819).
Problem: a KSDS browse or a DB2
ORDER BYfollows the key's EBCDIC bytes: lower case before upper case, letters before digits. The generated repositories left ordering to the database's default collation, which folds case and accents. On MySQL (utf8mb4_0900_ai_ci),ABC,abcandÀBCare the same key, so distinct COBOL keys collided on the primary key. On every database, browses came back in a different order from the mainframe's.What changes (
culture.key_collation, declared in #3849 and wired here):ebcdic(the default).<KEY>_SORTcolumn: the key's code-page bytes in hex (A001in cp037 isC1F0F0F1). It is filled on@PrePersist/@PreUpdateby the newCobolRecords.sortKey(key, codePage).findByAcctIdSortGreaterThanEqualOrderByAcctIdSortAsc.CobolRecords.sortKey(from, "cp037").Pageablestill works.ebcdicandbinary. String key columns, including the text parts of a group key, get a byte-wise collation:COLLATE "C"on PostgreSQL,utf8mb4_binon MySQL. H2 compares code points by default. DB2 and Oracle are left unchanged, because their defaults (the table's code page,NLS_SORT=BINARY) are already byte-wise.database. Output identical to before.String.compareToor the database's default collation.Limits
@EmbeddedIdisn't a derived query), and numeric keys already order correctly.Tests
tests/cobol_mainframe/test_key_collation.py, on the Java conversion: CICS FILE (VSAM) operations + FILE-CONTROL / IDCAMS -> Spring Data repositories #3617 estate re-keyed to aPIC X(8)key. It covers the generated entity, repository, service and key class for postgresql, mysql, binary and database. It also runsCobolRecords.sortKeyunder javac/java for cp037, cp273 and cp500 and compares the result against Python's byte order. The cp037 order is the one the issue gives:Ä001 a001 A 01 A-01 A001 1001.tests/cobol_mainframe: 794 passed.java_target_matrix.py --scan --only default plain-classes mysqlon that estate: all three generated projects compile with Maven.pr_gates.py --fast: 5/5 pass.Gemini's earlier draft only added
COLLATE "C"and kept the database's order. That order is ASCII, not EBCDIC: digits before letters, upper case before lower. This PR is a rewrite.🤖 Generated with Claude Code