PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #6772

Postgres REAL (in database as float4) field is not supported by generator

Details

Submitted2006-02-13 17:04 UTC
Fromdmitry dot poltaryonok at gmail dot com
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version5.1.2
OSGNU/Linux
Roadmaps(Not assigned)

Comments

[2006-02-13 17:04 UTC] dmitry dot poltaryonok at gmail dot com

Description:
------------
Generator places incorect field type values in database.ini file if postgres uses float4 for real data type.

Test script:
---------------
CREATE TABLE tariff_retailer_commission
(
retailer_commission_id serial NOT NULL,
tariff_id int8 NOT NULL,
first_installment float4 NOT NULL,
commission float4 NOT NULL,

);
Run the generator. Fields of type float4 will be marked as timestamp & notnull [& int] etc. (That is $type of previous field is stored)
Patch
Index: Generator.php
===================================================================
--- Generator.php.orig
+++ Generator.php
@@ -326,7 +326,11 @@
foreach($defs as $t) {

$n=0;
-
+ /*
+ * to prevent .ini file errors when type not listed in switch
+ * encountered
+ */
+ $type = DB_DATAOBJECT_STR;
switch (strtoupper($t->type)) {

case 'INT':
@@ -350,6 +354,7 @@
case 'DOUBLE':
case 'DOUBLE PRECISION': // double precision (firebird)
case 'FLOAT':
+ case 'FLOAT4': // postgres (real)
case 'FLOAT8': // double precision (postgres)
case 'DECIMAL':
case 'MONEY': // mssql and maybe others

Expected result:
----------------
in database.ini file
[tariff_retailer_commission]
retailer_commission_id = 129
tariff_id = 129
first_installment = 129
commission = 129

Actual result:
--------------
in database.ini file
[tariff_retailer_commission]
retailer_commission_id = 129
tariff_id = 129
first_installment = 257
commission = 385