INT column 0 vs NULL

QuestionsINT column 0 vs NULL
Sunny Kim asked 8 months ago

I have a MYSQL table with a column defined as “INT” with DEFAULT NULL.

And the grid for this column has:

  • isnull = true
  • editrules: required=false, number=true

Problem:

  • When I enter “0”, it gets inserted into the DB as NULL.

So then I changed “isnull” to FALSE.  Then “0” gets inserted as 0.  Good!   But now an empty value gets inserted as “0”.

There must be an obvious fix to this.  But I just can’t figure it out.  Help please!

 

5 Answers
Abu Ghufran Staff answered 8 months ago

Thanks for reporting this issue. We’ll update our build to fix this.

I can see the records that you requested refund due to missing requirements in Nov 2018 and contract was cancelled. After that no new contract is made. To have continued support you should have active contract.

Also, just as a note, it’s illegal to use the paid package after the refund and cause possible legal action.

If you think you have purchased license with some different account, let us know.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Sunny Kim replied 8 months ago

Thanks for the quick reply. Wow… I’m surprised this issue was never brought up in the past. Very much looking forward to the update. ETA on the next build? As for the purchased license, I’m currently still evaluating the software (after realizing phpgrid from another vendor wasn’t going to work out). Full intention is to purchase once all of my tests pass. I hope that’s acceptable?

Sunny Kim replied 8 months ago

Btw, just to make clarify…. since the refund, I had been using the grid software from phpgrid.com. Our needs have changed and required additional features that were lacking, which is why I started evaluating your grid software again. In fact, I believe the above may be the only outstanding issue remaining. Thank you!

Abu Ghufran Staff answered 8 months ago

After some research, I come to this conclusion. Mysql does not allow blank string to be stored in not-null integer field. If you try to insert ”, It will be converted to 0 by mysql. There are some alternate ways as well, but they are not in recommended ways.

Ref: https://stackoverflow.com/questions/28606483/how-to-allow-empty-string-for-integer-in-mysql

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Sunny Kim answered 8 months ago

But in my case, my INT column was defined with “DEFAUT NULL”. It was NOT  not-null integer field.  So if I leave a cell blank, then it should get saved as NULL or that entering “0” should get saved as 0. But currently:

  • When grid is set to isnull = true:
    • entering “0” gets inserted into the DB as NULL.
  • When isnull = false:
    • an empty value gets inserted as “0”.

0’s getting interpreted as NULL and empty value getting interpreted as “0” is a hug bug. I would appreciate your review again.  Thank you!

Sunny Kim answered 7 months ago

Hi.  Any update on this?  Anyone else running into this issue?   Defining a DB column as “INT DEFAULT NULL”, you’ll get one of two behaviors:

  1. an empty value gets updated into the DB as “0”
  2. “0” value gets updated into the DB as NULL

This is a critical bug.  Thankfully we were testing on a dev DB.  Otherwise, it would have completely corrupted our database. Be aware!

Abu Ghufran Staff answered 7 months ago

Thanks for reporting and it’s fixed in latest build.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

12 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?