Closed (outdated)
Project:
Schema
Version:
6.x-1.7
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Jan 2012 at 20:50 UTC
Updated:
7 Dec 2021 at 14:35 UTC
Jump to comment: Most recent
On a PostgreSQL database, the default value of a timestamp field with now() default value is incorrect, returning 'ow('. This is because the first and last character are dropped when the default value isn't a number.
The solution I propose is to change the line 121 of engines/schema_pgsql.inc file:
- $col['default'] = substr($col['default'], 1, -1);
+ $d = $col['default'];
+ $col['default'] = (in_array($d[0], array("'", '"')) && $d[0] == $d[strlen($d) - 1]) ? substr($col['default'], 1, -1) : $d; // if the first character is ' or " and the first and last character are the same, only then drop the first and last character.
Comments
Comment #1
Edakos commentedThis is a bit better:
$d = $col['default'];
$col['default'] = (in_array($d[0], array("'", '"')) && $d[0] == $d[strlen($d) - 1]) ? substr($d, 1, -1) : $d;
Comment #2
jcnventuraVersions 6.x of the module are no longer supported.