(Probably?) MYSQL Connector (?) writes NULL values for unset or undefined properties.

8 views
Skip to first unread message

Lander Vanderstraeten-Sintobin

unread,
Jan 17, 2018, 2:37:03 AM1/17/18
to LoopbackJS
As the title says, when there are fields not-set or undefined they writes NULL values in the mysql database.

Example:

Step 1 - a POST request:  (works fine, data is inserted correct in the database)
{
name: lander,
created: 2018-01-09 00:00:00
modified: null
}


Step 2 - a PUT / upsert request:  (here will the created field be NULL in the mysql database)
{
name: lander,
modified: 2018-01-09 00:00:00
}

I tried also without success:
{
name: lander,
modified: 2018-01-09 00:00:00,
created: undefined
}

I am using follow versions of depencies:
"loopback": "^3.17.1",
"loopback-boot": "^2.27.0",
"loopback-component-explorer": "^5.2.0",
"loopback-component-storage": "^3.3.1",
"loopback-connector-mysql": "^5.2.0",
"loopback-datasource-juggler": "^3.14.0",

I have no idea where i have to start debugging?
Someone who have suggestions? would be fine!

Thanks a bunch in advantage,

Lander

Lander Vanderstraeten-Sintobin

unread,
Jan 17, 2018, 5:02:09 PM1/17/18
to loopb...@googlegroups.com
After some headache, i found the solution.

PUT endpoints are mapped to replace methods in 3.0 and PATCH endpoints are introduced to expose the old update/patch methods.

The replaceonputflag in my model definition file was the solution:
Reply all
Reply to author
Forward
0 new messages