-
-
Notifications
You must be signed in to change notification settings - Fork 620
Open
Description
const field = "name, JSON_EXTRACT(info, '$.age') AS age";
在我这里这样写不行,必须是下面才行
const field = "name, JSON_EXTRACT(info, '$.age') AS info";
select(options, cache) {
if (!this.config.jsonFormat) {
return super.select(options, cache);
}
return Promise.all([
super.select(options, cache),
this.schema.getSchema()
]).then(([data, schema]) => {
const keys = Object.keys(schema).filter(key => schema[key].tinyType === 'json');
(Array.isArray(data) ? data : [data]).forEach(row => {
keys.filter(key => row[key] !== undefined).forEach(key => {
row[key] = JSON.parse(row[key]);
});
});
return data;
});
}
keys 返回的是 [info]
而 row 里返回的 age:{}
keys.filter(key => row[key] !== undefined)
row[info] 必然是 undefined。
Metadata
Metadata
Assignees
Labels
No labels