loopbackio / loopbackio/loopback-next
Execute a MySQL command with named parameters
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
Steps to reproduce
- Install node v12.19.0
- Install package "loopback-connector-mysql": "6.0.0"
- use repository that extends
DefaultCrudRepositoryand run:
await repo.execute("SELECT * FROM table WHERE name = :name", {name: "John Doe"})
Current Behavior
Receive error:
strong-error-handler Handling AssertionError [ERR_ASSERTION]: params must be an array
Expected Behavior
According to doc the type NamedParameters is supported, so object should be handled
Additional information
My stack trace:
strong-error-handler Handling AssertionError [ERR_ASSERTION]: params must be an array
at MySQL.SQLConnector.execute (/api/node_modules/loopback-connector-mysql/node_modules/loopback-connector/lib/sql.js:566:3)
at /api/node_modules/loopback-datasource-juggler/lib/datasource.js:2711:39
at new Promise (<anonymous>)
at MainDBDataSource.DataSource.execute (/api/node_modules/loopback-datasource-juggler/lib/datasource.js:2710:10)
at MySQLRepository.execute (/api/node_modules/@loopback/repository/dist/repositories/legacy-juggler-bridge.js:363:46)
at MySQLRepository.query (/api/dist/repositories/mysql.repository.js:16:21)
at MyTestController.finances (/api/dist/controllers/my-test.controller.js:63:37)
at invokeTargetMethod (/api/node_modules/@loopback/context/dist/invocation.js:156:49)
at /api/node_modules/@loopback/context/dist/invocation.js:138:16
at Object.transformValueOrPromise (/api/node_modules/@loopback/context/dist/value-promise.js:257:16)
at invokeTargetMethodWithInjection (/api/node_modules/@loopback/context/dist/invocation.js:133:28)
at InterceptedInvocationContext.invokeTargetMethod (/api/node_modules/@loopback/context/dist/invocation.js:83:20)
at targetMethodInvoker (/api/node_modules/@loopback/context/dist/interceptor.js:241:57)
at /api/node_modules/@loopback/context/dist/interceptor-chain.js:110:20
at Object.transformValueOrPromise (/api/node_modules/@loopback/context/dist/value-promise.js:257:16)
at GenericInterceptorChain.invokeNextInterceptor (/api/node_modules/@loopback/context/dist/interceptor-chain.js:105:32)
node -e 'console.log(process.platform, process.arch, process.versions.node)'
Outputs: linux x64 12.19.0
npm ls --prod --depth 0 | grep loopback
Outputs:
├── @loopback/authentication@7.0.2
├── @loopback/authorization@0.7.2
├── @loopback/boot@3.0.2
├── @loopback/context@3.12.0
├── @loopback/core@2.11.0
├── @loopback/openapi-v3@5.0.0
├── @loopback/repository@3.1.0
├── @loopback/rest@8.0.0
├── @loopback/security@0.3.2
├── @loopback/service-proxy@3.0.2
├── loopback-connector-kv-redis@4.0.0
├── loopback-connector-mysql@6.0.0
├── loopback-connector-rest@3.7.0
Related Issues
I have found https://github.com/strongloop/loopback-next/issues/5264 which is related if the problem is in documentation
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 with DefaultCrudRepository.execute and the NamedParameters API documentation, then trace the call through legacy-juggler-bridge.js to loopback-connector/lib/sql.js, as shown in the stack trace. Compare the documented parameter contract with the MySQL connector behavior; done means named parameters either execute successfully or the documentation accurately states the supported form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, node.js, typescript
- Domain
- api, backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100