Combo default value set to "" throws SQL error

Talk about foreign keys

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

saanobhaai
Junior
Junior
Posts: 18
Joined: Nov 9th, '10, 18:03

Re: Combo default value set to "" throws SQL error

Postby saanobhaai » Dec 30th, '10, 17:35

Same setup as discussed previously. My field:

Code: Select all

      "qa_processor" => array("header" => "QA'd by", "type" => "foreign_key", "req_type" => "si"),
Error only comes when you don't select a value.

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Combo default value set to "" throws SQL error

Postby administrator » Dec 31st, '10, 08:37

Ok, try to define default value for your field as "0" indatabase.

saanobhaai
Junior
Junior
Posts: 18
Joined: Nov 9th, '10, 18:03

Re: Combo default value set to "" throws SQL error

Postby saanobhaai » Dec 31st, '10, 16:58

Thanks, administrator. I did so, and still the UPDATE string generated is:

Code: Select all

UPDATE sdr_dirs_features SET id_featuretype = '3' , processor = '1' , notes = 'some notes' , qa_processor = '' , qa_date = NULL WHERE id_feature = '10'
so at the time of submission $this->dataSet->tableInfo() thinks the INT field is a string (verified with a print_r() in GetFieldOffset()). Everything else is fine, just
qa_processor = ''
should be
qa_processor = 0
or
qa_processor = NULL

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Combo default value set to "" throws SQL error

Postby administrator » Jan 8th, '11, 15:41

We'll check this again, thanks.

lcisetti
Senior
Senior
Posts: 25
Joined: Sep 6th, '10, 21:46

Re: Combo default value set to "" throws SQL error

Postby lcisetti » Jan 21st, '11, 13:35

Any solution about this issue ?
Thanks

Luca

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Combo default value set to "" throws SQL error

Postby administrator » Jan 23rd, '11, 09:18

This issue was fixed in 6.4.1 for fields, defined as numeric fields.
For example, you have country_id, defined as int(10) that inked with countries.id

Check AddRow() method in datagrid.class.php, it has following part of code:

Code: Select all

                            }else{
                                if(trim($fldValue) != ""){
                                    if($this->dbHandler->phptype == "oci8") $sql .= $fldValue;
                                    else $sql .=  "'".$fldValue."'";
                                }else if($this->IsFieldRequired($fldName)){
                                    $sql .= '0';   
                                }else{
                                    $sql .= 'NULL';   
                                }                       
                            }


Return to “Field type: "foreign key"”