loopbackio / loopbackio/loopback-connector-mysql

Empty body on update generates an MySQL error

Open
#478 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
126
Forks
181
Avg merge
4d 7h
Merged PRs (30d)
12

Description

Steps to reproduce

Generate a new project (ex: loopback example todo-list), change DB from memory objecto to MySQL, create MySQL database and config connector. Seed database with some data.

Make a PATCH request that uses updateById repository's method, with an empty body (ex: updatebyId(existingId, {}).

Current Behavior

Query fails with an SQL syntax error: "Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='3db97b64-a616-11ec-8940-0db8a28d8117'".

This error does not occur when using a memory database.

Query sent to DB (without params) is: "UPDATE ModelA SET WHERE id=?"

Expected Behavior

A - No query should be sent to DB
B - Send correct (but useless) query to DB

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MySQL connector's updateById path and reproduce the PATCH request using an existing record and an empty body. Verify that the connector no longer emits malformed UPDATE SQL and that the behavior matches one of the expected outcomes described in the issue.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.