Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #16017 Postgres default field value metadata
Submitted: 2009-03-11 12:37 UTC
From: slj Assigned:
Status: Duplicate Package: MDB2
PHP Version: 5.2.5 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2009-03-11 12:37 UTC] slj (Simon L Jackson)
Description: ------------ In Validate.php the function validateDataFieldValue checks the length of a $field_value against the size of the column. However, some field values such as default values will include quotation characters and/or some form of casting suffix eg: ' '::character varying The actual length of the above is 1, not 21 The Horde 1.2.2 upgrade script crashes with the message: Loading database module... Updating database... [ ERROR! ] Reading the existing table structure failed. Error messages: MDB2_Schema Error: schema validation error default value of "pref_scope" is incorrect: "''::character varying" is larger than "16"

Comments

 [2009-03-11 12:59 UTC] slj (Simon L Jackson)
Changing the source as follows did solve the problem, but I'm not sure that this is suitable as is for patching the source. # diff /usr/local/horde/pear/MDB2/Schema/Validate.php /usr/local/horde/pear/MDB2/Schema/Validate.php.orig 836,840c836 < if ( preg_match ( "/^'(.*)'::(.*)$/", $field_value, $parts )) < $field_value_inner = $parts[1]; < else < $field_value_inner = $field_value; < if (!empty($field_def['length']) && strlen($field_value_inner) > $field_def['length']) { --- > if (!empty($field_def['length']) && strlen($field_value) > $field_def['length']) {
 [2009-03-12 03:44 UTC] ifeghali (Igor Feghali)
Hello Simon, what RDBMS is that ? I am not sure putting database specific checks in there is the best way to go. Let me think about that a bit more. Perhaps you could create your own Validate class and pass it as a option ? Regards, Igor Feghali.
 [2009-03-12 11:00 UTC] slj (Simon L Jackson)
This is with PostgreSQL 8.2. I haven't tried this with any other versions of PostgreSQL or any versions of MySQL yet. A default value of a single space comes back as the rather long: ' '::character varying Alternatively, it might be possible/better to persuade MDB2_Driver_pgsql to just pass back the actual default value (i.e. the single space) rather than the fully enquoted and cast value. This would remove the need to modify MDB2_Schema. On the other hand if one is reverse engineering the metadata, it would be best to know the full defaults value. I confess I'm not sure which is the best way to proceed.
 [2009-05-25 01:41 UTC] ifeghali (Igor Feghali)
-Summary: Issue with field validation length +Summary: Postgres default field value metadata -Package: MDB2_Schema +Package: MDB2
Im looping this to the MDB2 guys so we can get their thoughts on it. Best, ~IF.
 [2009-10-03 15:37 UTC] quipo (Lorenzo Alberton)
-Status: Open +Status: Feedback
Can I have an example or a reproducing test case?
 [2010-01-17 14:41 UTC] hschletz (Holger Schletz)
This looks like a duplicate of bug #16281 for which a solution is available.
 [2010-03-02 15:36 UTC] doconnor (Daniel O'Connor)
-Status: Feedback +Status: Duplicate