diff --git a/lib/sql_generator.js b/lib/sql_generator.js index 242b08c..6f45032 100644 --- a/lib/sql_generator.js +++ b/lib/sql_generator.js @@ -204,7 +204,7 @@ function applyTokens(sql, tokens) { } // build a SQL WHERE clause string from a slice object -// validates all keys against the allowed dimension column list +// only dimension columns are included; unrecognised keys are silently skipped function buildWhere(slice, dimCols) { if (!slice || Object.keys(slice).length === 0) return 'TRUE'; @@ -212,9 +212,7 @@ function buildWhere(slice, dimCols) { const parts = []; for (const [col, val] of Object.entries(slice)) { - if (!allowed.has(col)) { - throw new Error(`"${col}" is not a dimension column`); - } + if (!allowed.has(col)) continue; if (Array.isArray(val)) { const escaped = val.map(v => esc(v)); parts.push(`"${col}" IN ('${escaped.join("', '")}')`); @@ -223,7 +221,7 @@ function buildWhere(slice, dimCols) { } } - return parts.join('\nAND '); + return parts.length ? parts.join('\nAND ') : 'TRUE'; } // build AND iter NOT IN (...) from a version's exclude_iters array diff --git a/routes/operations.js b/routes/operations.js index 7bb11d0..be397fe 100644 --- a/routes/operations.js +++ b/routes/operations.js @@ -82,7 +82,6 @@ module.exports = function(pool) { try { const ctx = await getContext(parseInt(req.params.id), 'baseline'); if (!guardOpen(ctx.version, res)) return; - const sql = applyTokens(ctx.sql, { fc_table: ctx.table, version_id: ctx.version.id, @@ -138,7 +137,6 @@ module.exports = function(pool) { try { const ctx = await getContext(parseInt(req.params.id), 'reference'); if (!guardOpen(ctx.version, res)) return; - const sql = applyTokens(ctx.sql, { fc_table: ctx.table, version_id: ctx.version.id, diff --git a/ui/index.html b/ui/index.html index 830671e..79bf1b9 100644 --- a/ui/index.html +++ b/ui/index.html @@ -4,7 +4,8 @@ -
New values for dimensions to replace. Leave blank to keep.
+ {dimCols.map(c => ( +Override dimensions on cloned rows. Leave blank to keep.
+ {dimCols.map(c => ( +