Problem with CURRENT_TIMESTAMP and editor

Problem with CURRENT_TIMESTAMP and editor

panzrampanzram Posts: 27Questions: 10Answers: 0
edited June 2019 in DataTables

Hi,

I have a site that's been running great for a while. Yesterday, our mysql database got migrated into a strict version. I've been able to locate and fix most issues, but one thing still remain and can't get my head around it.

The field that's given me grief is a timestamp with a default set to CURRENT_TIMESTAMP. When I insert a new record, by the use of the editor modal, I get this error:
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: current_timestamp() for column created_at

The sql is:
The SQL statement executed was: INSERT INTO mytable (created_at, name) VALUES (:yp0, :yp1)

When I run the same sql (replacing the parameters :yp0 and :yp1 with values), it works brilliantly, so the error must either come from my client- or server-side scripts. I don't know how to debug and see what the :yp0 and :yp1 values are, would really like to take closer peek at those.

The related client-side script is:

{ data: "created_at" },

The related server-side script is:

Field::inst( created_at ), `
    /*`
    Field::inst( created_at )
        ->validator( Validate::dateFormat, array(
            "format"  => Format::DATE_ISO_8601,
            "message" => "Please enter a date in the format yyyy-mm-dd"
        ) )
        ->getFormatter( Format::date_sql_to_format, Format::DATE_ISO_8601 )
        ->setFormatter( Format::date_format_to_sql, Format::DATE_ISO_8601 ),
    */

I've tried both the rem:ed part and the other part, but nothing seems to work.

Any comments or ideas is greatly appreciated.

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 12,116Questions: 0Answers: 2,059
    Answer ✓

    Hi @panzram ,

    A good way would be to look at the network tab in the developer's tool of the browser, and see what the Editor client is sending back to the client. Could you also post the client-side code for that field, please.

    Cheers,

    Colin

  • panzrampanzram Posts: 27Questions: 10Answers: 0

    Thx, Colin. I know about the network tab, but in this case I couldn't explore the data.

    I solved it now by going in another direction. If anyone is interested, I put the field default from CURRENT_TIMESTAMP to "0000-00-00 00:00:00" and set the date manually from my server-side instead. I still don't understand why it didn't work as it was.

Sign In or Register to comment.