think-model-mysql jsonFormat 不能去掉双引号
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 614
- PR merge metrics
- No merged PRs in 30d
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。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The affected entry point is the select(options, cache) method shown in the issue; reproduce it with JSON_EXTRACT(info, '$.age') AS age while JSON formatting is enabled. Trace how returned aliases are matched against the schema's JSON keys. Done means JSON values returned under an alias are parsed correctly rather than being skipped because the schema field name is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100