loopbackio / loopbackio/loopback-connector-mysql
empty string is converted to empty object in LoopBack3
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 126
- Forks
- 181
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 12
Description
## Steps to reproduce
LookBack version: 3.28.0
loopback-connector-mysql version: 7.0.5
This bug occurred after we upgraded the version of loopback-connector-mysql from 4.1.0 to 7.0.5.
define a nullable property in lb3 model like this:
```
"properties": {
"id": {
"type": "string",
"required": false,
"length": 255,
"precision": null,
"scale": null,
"default":null,
"mysql": {
"columnName": "id",
"dataType": "VARCHAR",
"dataLength": 255,
"dataPrecision": null,
"dataScale": null,
"nullable": "Y"
}
}
}
```
And then simply get this model from lb.
## Bbserved Result
If id is an empty string, it will be converted to empty object. If id is null or non-empty string, it will be returned directly.
## Expected Behavior
Empty string shouldn't be converted to empty object, and should be returned directly as null or non-empty string.
## Additional information
node -e 'console.log(process.platform, process.arch, process.versions.node)'
> darwin arm64 20.9.0
npm ls --prod --depth 0 | grep loopback
> npm WARN config production Use `--omit=dev` instead.
├── loopback-boot@3.3.1
├── loopback-component-explorer@6.5.1
├── loopback-component-storage@3.7.0
├── loopback-connector-mongodb@5.6.0
├── loopback-connector-mysql@7.0.5
├── loopback-connector-rest@2.1.0
├── loopback-filters@1.1.1
├── loopback-i18n@1.1.4
├── loopback@3.28.0
Contributor guide
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
Start by reproducing the behavior with LoopBack 3.28.0, loopback-connector-mysql 7.0.5, and the nullable string id model described here. Trace the MySQL connector path used when reading that property; done means an empty string remains an empty string while null and non-empty strings retain their existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql, node.js
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100