mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-22 00:13:45 -05:00
Compare commits
1 Commits
js-proxy
...
fix/compil
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60b64e10ff |
@@ -161,6 +161,17 @@ describe('sheet language', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not strip inner regex dollar escapes in string literals', () => {
|
||||||
|
const result = generateSQLWithState(
|
||||||
|
q('transactions')
|
||||||
|
.filter({ 'payee.name': { $regexp: '\\$end' } })
|
||||||
|
.select(['id'])
|
||||||
|
.serialize(),
|
||||||
|
schemaWithRefs,
|
||||||
|
);
|
||||||
|
expect(result.sql).toMatch("REGEXP('\\\\$end', payees1.name)");
|
||||||
|
});
|
||||||
|
|
||||||
it('`select` allows selecting all fields with *', () => {
|
it('`select` allows selecting all fields with *', () => {
|
||||||
let result = generateSQLWithState(
|
let result = generateSQLWithState(
|
||||||
q('accounts').select(['*']).serialize(),
|
q('accounts').select(['*']).serialize(),
|
||||||
|
|||||||
@@ -462,7 +462,10 @@ function compileLiteral(value) {
|
|||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
// Allow user to escape $, and quote the string to make it a
|
// Allow user to escape $, and quote the string to make it a
|
||||||
// string literal in the output
|
// string literal in the output
|
||||||
value = value.replace(/\\\$/g, '$');
|
// Only unescape a leading "\$" so users can write literals starting
|
||||||
|
// with "$" without triggering field reference parsing. Do not
|
||||||
|
// unescape inner "\$" occurrences to preserve regex escaping.
|
||||||
|
value = value.replace(/^\\\$/, '$');
|
||||||
return typed(value, 'string', { literal: true });
|
return typed(value, 'string', { literal: true });
|
||||||
} else if (typeof value === 'boolean') {
|
} else if (typeof value === 'boolean') {
|
||||||
return typed(value ? 1 : 0, 'boolean', { literal: true });
|
return typed(value ? 1 : 0, 'boolean', { literal: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user