MDL-52511 dml: add support for PostgreSQL 9.5

The default definition behaviour has changed for some int values.
This commit is contained in:
Petr Skoda 2015-12-15 13:17:49 +13:00 committed by Dan Poltawski
parent 9d5d9c64ff
commit 267ac1b9eb

View File

@ -478,7 +478,14 @@ class pgsql_native_moodle_database extends moodle_database {
$info->scale = null;
$info->not_null = ($rawcolumn->attnotnull === 't');
if ($info->has_default) {
$info->default_value = trim($rawcolumn->adsrc, '()');
// PG 9.5+ uses ::<TYPE> syntax for some defaults.
$parts = explode('::', $rawcolumn->adsrc);
if (count($parts) > 1) {
$info->default_value = reset($parts);
} else {
$info->default_value = $rawcolumn->adsrc;
}
$info->default_value = trim($info->default_value, "()'");
} else {
$info->default_value = null;
}
@ -496,7 +503,14 @@ class pgsql_native_moodle_database extends moodle_database {
$info->not_null = ($rawcolumn->attnotnull === 't');
$info->has_default = ($rawcolumn->atthasdef === 't');
if ($info->has_default) {
$info->default_value = trim($rawcolumn->adsrc, '()');
// PG 9.5+ uses ::<TYPE> syntax for some defaults.
$parts = explode('::', $rawcolumn->adsrc);
if (count($parts) > 1) {
$info->default_value = reset($parts);
} else {
$info->default_value = $rawcolumn->adsrc;
}
$info->default_value = trim($info->default_value, "()'");
} else {
$info->default_value = null;
}
@ -514,7 +528,14 @@ class pgsql_native_moodle_database extends moodle_database {
$info->not_null = ($rawcolumn->attnotnull === 't');
$info->has_default = ($rawcolumn->atthasdef === 't');
if ($info->has_default) {
$info->default_value = trim($rawcolumn->adsrc, '()');
// PG 9.5+ uses ::<TYPE> syntax for some defaults.
$parts = explode('::', $rawcolumn->adsrc);
if (count($parts) > 1) {
$info->default_value = reset($parts);
} else {
$info->default_value = $rawcolumn->adsrc;
}
$info->default_value = trim($info->default_value, "()'");
} else {
$info->default_value = null;
}