Skip to content

Commit 8fc5963

Browse files
committed
fix(V2): replace _.snakeCase with digit-safe camelToSnake converter
Lodash _.snakeCase splits on letter-to-digit transitions, producing cad_trust_aef_t_1_submission_id instead of cad_trust_aef_t1_submission_id for AEF field names. This caused getRecordField to silently miss FK references on AEF tables, bypassing ownership checks.
1 parent 57f823e commit 8fc5963

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/models/v2/staging-v2.model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,16 @@ class StagingV2 extends Model {
196196
];
197197
}
198198

199+
static camelToSnake(str) {
200+
return str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
201+
}
202+
199203
static getRecordField(record, fieldName) {
200204
const plainRecord = typeof record?.get === 'function'
201205
? record.get({ plain: true })
202206
: record?.dataValues ?? record;
203207

204-
return plainRecord?.[fieldName] ?? plainRecord?.[_.snakeCase(fieldName)];
208+
return plainRecord?.[fieldName] ?? plainRecord?.[StagingV2.camelToSnake(fieldName)];
205209
}
206210

207211
static hasOwnershipFields(record, table) {

0 commit comments

Comments
 (0)