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

Edakos’s picture

This 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;

jcnventura’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Versions 6.x of the module are no longer supported.