SQL error when using generator

SQL error when using generator

tnaeschertnaescher Posts: 22Questions: 6Answers: 0

Hello everyone

When using Datatables Editor Code Generator (https://editor.datatables.net/generator/index), a SQL Error appears under certain circumstances - when run on datatables.net Server as well as when downloaded and run locally.

An SQL error occurred: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect decimal value: '' for column editor_generator.3cc313b6-fa34-11ec-b9ab-002590dcfa5d.integer at row 1

It is very easy to reproduce: Go to Generator -> PHP/MariaDB -> Add a text field -> Add any field with integer type -> Run it

now, when adding a new record without entering anything in the integer field -> Error.

Shouldn't the SQL field be nullable?

Thanks!

Best Regards
Tim

P.S. I made a demo here: https://editor.datatables.net/generator/run/table.3cc313b6-fa34-11ec-b9ab-002590dcfa5d.html
But i believe it will be offline after 1 hour?

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Hi Tim,

    Argeed! It should be nullable and then formatter should set it to be null when empty. Thanks for pointing that out. I'm away this week but will fix it upon my return.

    Allan

  • tnaeschertnaescher Posts: 22Questions: 6Answers: 0

    Hi Allan,

    thanks for your response. I worked around this issue by defaulting to 0 (as in zero) if no value is entered - couldn't figure out how to set it to null (as in no value given). Can you point me in the right direction?

    Best Regards
    Tim

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Absolutely, have a look at the "Empty values" section on this page.

    Allan

Sign In or Register to comment.