T-74: M1.1i — Pass 3/4/6 match & conflict report: pure in-memory Markdown + CSV generator and override seed-SQL template (no DB I/O)
This commit is contained in:
parent
cbabb17094
commit
83ec301220
3 changed files with 251 additions and 43 deletions
|
|
@ -913,6 +913,9 @@ describe('generateOverrideSeedSql & generateOverrideTemplateSql', () => {
|
|||
expect(sql).toContain("AND l.ticker_root = 'AAPL'");
|
||||
expect(sql).toContain("AND l.class_suffix = ''");
|
||||
expect(sql).toContain("AND l.currency = 'USD'");
|
||||
expect(sql).toContain('WHERE matched.listing_id IS NOT NULL');
|
||||
expect(sql).not.toContain('ORDER BY l.listing_id');
|
||||
expect(sql).not.toContain('LIMIT 1');
|
||||
expect(sql).toContain('ON CONFLICT (source, source_id, valid_from) DO NOTHING;');
|
||||
|
||||
// Default validFrom and null validTo
|
||||
|
|
@ -973,12 +976,19 @@ describe('generateOverrideSeedSql & generateOverrideTemplateSql', () => {
|
|||
).toThrow(/Conflicting duplicate/);
|
||||
});
|
||||
|
||||
test('generateOverrideTemplateSql comments out every non-blank line, includes only source-attributed conflicts, and neutralizes newlines', () => {
|
||||
test('generateOverrideTemplateSql comments out every non-blank line, preserves CR/LF via E-string literals, warns on unstorable IDs, and omits Pass 6 conflicts', () => {
|
||||
const conflicts: UnifiedConflictRow[] = [
|
||||
{
|
||||
pass: 'stage_a',
|
||||
source: 'eod',
|
||||
sourceId: 'BAD\nDROP TABLE override;--',
|
||||
sourceId: "BAD\r\nDROP'\\TABLE override;--",
|
||||
conflictKind: 'isin_cusip_mismatch',
|
||||
detail: {},
|
||||
},
|
||||
{
|
||||
pass: 'stage_a',
|
||||
source: 'eod',
|
||||
sourceId: 'UNSTORABLE\0ID',
|
||||
conflictKind: 'isin_cusip_mismatch',
|
||||
detail: {},
|
||||
},
|
||||
|
|
@ -1019,8 +1029,19 @@ describe('generateOverrideSeedSql & generateOverrideTemplateSql', () => {
|
|||
}
|
||||
|
||||
const commentedInserts = templateSql.match(/-- INSERT INTO override/g) ?? [];
|
||||
expect(commentedInserts.length).toBe(3);
|
||||
expect(commentedInserts.length).toBe(4);
|
||||
expect(templateSql).not.toContain('ambiguous_otc_continuation');
|
||||
expect(templateSql).not.toContain('ORDER BY l.listing_id');
|
||||
expect(templateSql).not.toContain('LIMIT 1');
|
||||
expect(templateSql).toContain('-- WHERE matched.listing_id IS NOT NULL');
|
||||
|
||||
// CR/LF source_id is preserved via a single-line PostgreSQL E'...' literal
|
||||
expect(templateSql).toContain("-- E'BAD\\r\\nDROP''\\\\TABLE override;--',");
|
||||
// Unstorable NUL-byte source_id gets a diagnostic warning and placeholder instead of silent mangling
|
||||
expect(templateSql).toContain(
|
||||
'-- WARNING: Cannot store raw source_id in PostgreSQL (contains NUL byte); correct source_id before applying.'
|
||||
);
|
||||
expect(templateSql).toContain("-- 'TODO_CORRECT_SOURCE_ID',");
|
||||
|
||||
// Empty conflicts report still produces only comments
|
||||
const emptyTemplate = generateOverrideTemplateSql(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue