bugphpGroupWare - Bugs: bug #9828, TranslateDefault not called for...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #9828: TranslateDefault not called for "number-like" defaults for pgsql setup

Submitted by:  Geoff Robinson <gymsocks>
Submitted on:  Fri 30 Jul 2004 07:43:08 PM UTC  
 
Item Group: SVN trunk (dev code)Category: API - Setup
Severity: 3 - NormalPriority: 5 - Normal
Status: InvalidPrivacy: Public
Assigned to: Dave Hall <skwashd>Open/Closed: Closed
Component Version: SVNOperating System: GNU/Linux - RedHat/Fedora
Reproducibility: Every TimePlanned Release: None
Fixed Release: 0.9.16.001

Fri 30 Jul 2004 09:41:42 PM UTC, comment #2:

This has been fixed in cvs some time ago. Closing

Dave Hall <skwashd>
Project AdministratorIn charge of this item.
Fri 30 Jul 2004 07:48:19 PM UTC, comment #1:

patch is for phpgwapi/class.schema_proc.inc.php, by the way...

Geoff Robinson <gymsocks>
Fri 30 Jul 2004 07:43:08 PM UTC, original submission:

On initial setup with pgsql, table creation produces the following error:

-------------------DEBUG OUT----------------------
_GetFieldSQL(): Incoming ARRAY: array(4) { ["type"]=> string(7) "varchar" ["precision"]=> int(40) ["nullable"]=> bool(false) ["default"]=> string(17) "+1 (000) 000-0000" }
_GetFieldSQL(): Default="+1 (000) 000-0000"
_GetFieldSQL(): Outgoing SQL: varchar(40) NOT NULL DEFAULT +1 (000) 000-0000

{snip}

Making sequence using: CREATE SEQUENCE seq_phpgw_addressbookDatabase error: Invalid SQL: CREATE TABLE phpgw_addressbook (id int4 NOT NULL DEFAULT nextval('seq_phpgw_addressbook'), lid varchar(32), tid char(1), owner int8, access varchar(7), cat_id varchar(32), fn varchar(64), n_family varchar(64), n_given varchar(64), n_middle varchar(64), n_prefix varchar(64), n_suffix varchar(64), sound varchar(64), bday varchar(32), note text, tz varchar(8), geo varchar(32), url varchar(128), pubkey text, org_name varchar(64), org_unit varchar(64), title varchar(64), adr_one_street varchar(64), adr_one_locality varchar(64), adr_one_region varchar(64), adr_one_postalcode varchar(64), adr_one_countryname varchar(64), adr_one_type varchar(32), label text, adr_two_street varchar(64), adr_two_locality varchar(64), adr_two_region varchar(64), adr_two_postalcode varchar(64), adr_two_countryname varchar(64), adr_two_type varchar(32), tel_work varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_home varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_voice varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_fax varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_msg varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_cell varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_pager varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_bbs varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_modem varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_car varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_isdn varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_video varchar(40) NOT NULL DEFAULT +1 (000) 000-0000, tel_prefer varchar(32), email varchar(64), email_type varchar(32) NOT NULL DEFAULT 'INTERNET', email_home varchar(64), email_home_type varchar(32) NOT NULL DEFAULT 'INTERNET', last_mod int4 NOT NULL, PRIMARY KEY(id))
PostgreSQL Error: 1 (ERROR: syntax error at or near "(" at character 879)
--------------------------------------------------

This is because the default phone numbers for the tel_* fields are not being escaped with quotes. That is, TranslateDefault is not called because '+1 (000) 000-0000' is detected as numeric.

A possible patch:

-----------------PATCH---------------------
433c433
< elseif(intval($sDefault) == 0 && $sDefault != '')
---

> elseif(is_numeric($sDefault) == 0 && $sDefault != '')

-----------------PATCH---------------------

After the patch:

-------------------DEBUG OUT----------------------
_GetFieldSQL(): Incoming ARRAY: array(4) { ["type"]=> string(7) "varchar" ["precision"]=> int(40) ["nullable"]=> bool(false) ["default"]=> string(17) "+1 (000) 000-0000" }
_GetFieldSQL(): Default="+1 (000) 000-0000"
_GetFieldSQL(): Calling TranslateDefault for "+1 (000) 000-0000"
_GetFieldSQL(): Outgoing SQL: varchar(40) NOT NULL DEFAULT '+1 (000) 000-0000'
--------------------------------------------------

This also affects default '1970-01-01' in sequence seq_phpgw_vfs.

Setup appears to function normally after the patch is applied, but I have not tested it thoroughly.

Geoff Robinson <gymsocks>

 

Attached Files
file #1426:  patch_class.schema_proc.inc.php added by gymsocks (128B - application/octet-stream - patch for line 432)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 5 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Fri 30 Jul 2004 09:41:42 PM UTCskwashdStatusNone=>Invalid
  Assigned toNone=>skwashd
  Open/ClosedOpen=>Closed
  Fixed Release=>0.9.16.001
Fri 30 Jul 2004 07:43:08 PM UTCgymsocksAttached File-=>Added patch_class.schema_proc.inc.php, #1545

Back to the top


Powered by Savane 3.1-cleanup1