支持在json数据查询中增加对escape字符
This commit is contained in:
parent
90a4b1c0a3
commit
0ff0f385e7
|
|
@ -411,7 +411,8 @@ class MySqlTranslator extends sqlTranslator_1.SqlTranslator {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 继续子对象解构
|
// 继续子对象解构
|
||||||
const part = translateInner(o[attr2], `${p}.${attr2}`);
|
const attr3 = attr2.startsWith('.') ? attr2.slice(1) : attr2;
|
||||||
|
const part = translateInner(o[attr2], `${p}.${attr3}`);
|
||||||
if (stmt2) {
|
if (stmt2) {
|
||||||
stmt2 += ' and ';
|
stmt2 += ' and ';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,8 @@ export class MySqlTranslator<ED extends EntityDict & BaseEntityDict> extends Sql
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 继续子对象解构
|
// 继续子对象解构
|
||||||
const part = translateInner(o[attr2], `${p}.${attr2}`);
|
const attr3 = attr2.startsWith('.') ? attr2.slice(1) : attr2;
|
||||||
|
const part = translateInner(o[attr2], `${p}.${attr3}`);
|
||||||
if (stmt2) {
|
if (stmt2) {
|
||||||
stmt2 += ' and ';
|
stmt2 += ' and ';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1443,6 +1443,55 @@ describe('test mysqlstore', function () {
|
||||||
assert(row2.length === 0, JSON.stringify(row2));
|
assert(row2.length === 0, JSON.stringify(row2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('[1.11.3]json escape', async () => {
|
||||||
|
const context = new TestContext(store);
|
||||||
|
await context.begin();
|
||||||
|
|
||||||
|
const id = await generateNewIdAsync();
|
||||||
|
await store.operate('oper', {
|
||||||
|
id: await generateNewIdAsync(),
|
||||||
|
action: 'create',
|
||||||
|
data: {
|
||||||
|
id,
|
||||||
|
action: 'test',
|
||||||
|
data: {
|
||||||
|
$or: [{
|
||||||
|
name: 'xc',
|
||||||
|
}, {
|
||||||
|
name: {
|
||||||
|
$includes: 'xc',
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
targetEntity: 'bbb',
|
||||||
|
}
|
||||||
|
}, context, {});
|
||||||
|
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
const row = await store.select('oper', {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
data: {
|
||||||
|
name: 1,
|
||||||
|
price: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
id,
|
||||||
|
data: {
|
||||||
|
'.$or': {
|
||||||
|
$contains: {
|
||||||
|
name: 'xc',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}, context, {});
|
||||||
|
|
||||||
|
await context.commit();
|
||||||
|
assert(row.length === 1);
|
||||||
|
});
|
||||||
|
|
||||||
it('[1.12]complicated json filter', async () => {
|
it('[1.12]complicated json filter', async () => {
|
||||||
const context = new TestContext(store);
|
const context = new TestContext(store);
|
||||||
await context.begin();
|
await context.begin();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue