Home » Database » DB_DataObject » Bug #6772
Postgres REAL (in database as float4) field is not supported by generator
Details
| Submitted | 2006-02-13 17:04 UTC |
|---|---|
| From | dmitry dot poltaryonok at gmail dot com |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 5.1.2 |
| OS | GNU/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