Bug #37257

NULL on IntegerConverter

Added by Carsten Bleicker about 9 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Could have
Category:
Property
Start date:
2012-05-17
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Yes
Complexity:

Description

hi folks,
f.e. i have a model wich holds a property "maxOrders".
NULL represents "unlimited"
0 represents 0
1 represents 1
...

so i have an input field where the user should be able to empty it with the
result that db field contains NULL (unlimited)

so in my humble oppinion the integer converter should convert nothing to null.
maybe in combination with a check of @ORM\Column(nullable=true)?
maybe the combination with @ORM\Column(nullable=true) could be also in any other converter?

kind regards
carsten


Files

IntegerConverter.php (1.75 KB) IntegerConverter.php Carsten Bleicker, 2012-05-18 14:20
PropertyMapper.php (13.9 KB) PropertyMapper.php Carsten Bleicker, 2012-05-24 17:23
PropertyMapper.php (14.1 KB) PropertyMapper.php Carsten Bleicker, 2012-05-24 18:20
#1

Updated by Christian Müller about 9 years ago

Indeed there should be a difference between "no entry made" and 0. For your usecase I would probably go a pragmatic way and set maxOrders to the heighest possible integer value instead of NULL, but still I think there should be a way to find out if someone entered nothing or 0.

#2

Updated by Carsten Bleicker about 9 years ago

Christian Mueller wrote:

Indeed there should be a difference between "no entry made" and 0. For your usecase I would probably go a pragmatic way and set maxOrders to the heighest possible integer value instead of NULL, but still I think there should be a way to find out if someone entered nothing or 0.

To find out whats needed NULL, 0, 1, ... or what else i tried the attached TypeConverter ('NULL' is wrong in the attached Class. Just think there is NULL instead of 'NULL' :) )
It returns NULL as expected but the Action Argument of persisted Elements does not recognize this NULL value
and does not overwrite the existing value. NULL seems to be handeled as "This is NULL ... Drop it"

I tried to figure out where exactly this happens and i think it must be somewhere in MVC Mapping.
I digged deep but didnt find the position to give it a patch try :(

Kind regards
carsten

#3

Updated by Carsten Bleicker about 9 years ago

So just trying to figure out the general mapping of null if @ORM\Column(nullable=true).
Do you agree with the comment in line LINE 172?

#4

Updated by Carsten Bleicker about 9 years ago

Tried to patch it by reflectionService.
Is it okay to do it this way?

#5

Updated by Karsten Dambekalns almost 9 years ago

  • Status changed from New to Needs Feedback
  • Target version set to 2.0 beta 1
  • Has patch changed from No to Yes
#6

Updated by Christian Müller over 8 years ago

  • Tracker changed from Feature to Bug
  • Status changed from Needs Feedback to Resolved
  • Priority changed from -- undefined -- to Could have
  • % Done changed from 50 to 100

The behaviour for Integer and Float was fixed in I178f616d0dd4acea90938384fb21600dd0f7c252

I think the PropertyMapper shouldn't know about ORM\Column annotations, what if you don't use doctrine. Wrong behaviour is fixed, so I will close this ticket for now.

Also available in: Atom PDF