Ticket #829 (new defect)

Opened 6 months ago

Last modified 2 months ago

Handling null values for numeric columns in ScaffoldEditView

Reported by: xkuba Owned by: xue
Priority: normal Milestone: 3.1.3
Component: Prado Framework v3 Version: 3.1
Severity: minor Keywords:
Cc:

Description

Hi,

I came accross this bug - when I have table definition including numeric column (int, numeric, ...) which can be set to null than invalid sql is generated in case of editing row with null in this column, e.g.

update xxx set int_column = where ...

This fails on PostgreSQL because is not valid number. I guess this works on MySQL or Oracle...

Empty string is generated in controls getText() method - there is used code like this: return $this->getViewState($name, );

I "fixed" this bug(?) for me in TPgsqlScaffoldInput.php in getControlValue() with code:

   protected function getControlValue($container, $column, $record)
   {
       $val = null;
      
      switch(strtolower($column->getDbType()))
      {
         case 'boolean':
            $val = $container->findControl(self::DEFAULT_ID)->getChecked();
         case 'date':
            $val = $container->findControl(self::DEFAULT_ID)->getDate();
         case 'time without time zone':
            $val = $this->getTimeValue($container, $column, $record);
         case 'timestamp without time zone':
            $val = $this->getDateTimeValue($container,$column, $record);
         default:
            $val = $this->getDefaultControlValue($container,$column, $record);
      }
      if ($val === "") $val = null;
      
      return $val;
   }

I know this is not perfect - maybe for text fields it should return empty string instead of null in some cases but for my usage it's better like this.

Kuba

Change History

Changed 2 months ago by knut

  • milestone set to 3.1.3
Note: See TracTickets for help on using tickets.