Saving data to database causes error

Wappler Version : 4 beta 12
Operating System : Win 10
Server Model: NODE
Database Type: MySql
Hosting Type: WAMP

Expected behavior

Date value should save

…YOUR TEXT HERE …

Actual behavior

Error flagged

I have a login server action which is audited.
This has worked perfectly over a few months of development where auditable actions are logged by calling a library API action as below

On installing Beta 12 i now get an error

Hi Brian,
What’s the exact database type you are inserting the NOW_UTC value into?

it’s a datetime field
I have worked around it by simply setting the date/time at table level rather than at query level and all works well

SORRY, IGNORE LAST CORRECTION, ABOVE CORRECT, NEED COFFEE

The value you are sending to the timestamp field is not in the correct format, that’s why the mysql server thorws this error.

The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

https://dev.mysql.com/doc/refman/8.0/en/datetime.html

Sorry teodor, my erroneous correction has confused the matter, it’s not a timestamp, its is datetime.
Worked perfectly up to beta 11, beta 12 has led to error.
This is the simple table structure
image

There is nothing changed there. The NOW_UTC time has always returned the date in 2021-07-09T08:09:12Z format.

From mysql docs:

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD hh:mm:ss ’ format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' .

Sorry teodor but today:

This

into this

Generates this

All Wappler, no custom

It is an audit table with 298 previous, pre Beta 12, successful logins recorded
Something must have changed surely?

What is your exact mysql version?
Are you sure it hasn’t been updated recently? Check the sql_mode, probably it’s set to strict and doesn’t accept dates in 2021-07-09T08:09:12Z format.

I will take a look when i have time, got a deadline to hit BUT nothing changed between it working this morning then me updating to Beta 12 where it stopped working

1 Like

I can confirm that mode was set to strict and changing that does stop the error.
BUT it has been set to strict since installation weeks ago (It’s a local WAMP)
Had it not been working for weeks i would have suspected STRICT mode may be the cause but as it only started when I upgraded to Beta 12 (lets face it that’s a 5 minute install window max) I discounted that

Are you using PHP or NodeJS?

Good catch @patrick, i am jumping between a legacy PHP site and a Node site and got mixed up

This one is actually Node with DB via WAMP (it’s a dev platform), NOT PHP as I stated in the bug report (amended)

In PHP it was always been the way that the NOW_UTC returns the date with a Z at the end, in NodeJS we fixed this in last update. The Z indicates the timezone in the ISO 8601 standard. MySQL still doesn’t support timezones, you pass a localtime and internally it converts that to an UTC time. You could strip off the Z when you want to store it like that.

Thank you @patrick, i knew something must have changed. Now I know i can work with that

Why don’t you use NOW() as a default value on the column, then you don’t have to set it.

Yes, i could work with that, It’s an audit function so only i will be looking at it so it’s not that critical (plus server is in UK anyway)