Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed getTableColumns to return object with "Default" property instead

of "default", as MySQL does.
Changed corresponding test.
Added conversion between PostgreSQL's null to PHP's null value,
default field containing "NULL::character varying" will be used as
string otherwise.
  • Loading branch information...
commit dd5ee04d13d49a11a5abcd216496d0e0e2b49848 1 parent 8fe0592
@gpongelli gpongelli authored
View
11 libraries/joomla/database/driver/postgresql.php
@@ -327,7 +327,7 @@ public function getTableColumns($table, $typeOnly = true)
END AS "null",
CASE WHEN pg_catalog.pg_get_expr(adef.adbin, adef.adrelid, true) IS NOT NULL
THEN pg_catalog.pg_get_expr(adef.adbin, adef.adrelid, true)
- END as "default",
+ END as "Default",
CASE WHEN pg_catalog.col_description(a.attrelid, a.attnum) IS NULL
THEN \'\'
ELSE pg_catalog.col_description(a.attrelid, a.attnum)
@@ -361,6 +361,15 @@ public function getTableColumns($table, $typeOnly = true)
}
}
+ /* Change Postgresql's NULL::* type with PHP's null one */
+ foreach ($fields as $field)
+ {
+ if (preg_match("/^NULL::*/", $field->Default))
+ {
+ $field->Default = null;
+ }
+ }
+
return $result;
}
View
8 tests/suites/database/driver/postgresql/JDatabasePostgresqlTest.php
@@ -331,28 +331,28 @@ public function testGetTableColumns()
$id->column_name = 'id';
$id->type = 'integer';
$id->null = 'NO';
- $id->default = 'nextval(\'jos_dbtest_id_seq\'::regclass)';
+ $id->Default = 'nextval(\'jos_dbtest_id_seq\'::regclass)';
$id->comments = '';
$title = new stdClass;
$title->column_name = 'title';
$title->type = 'character varying(50)';
$title->null = 'NO';
- $title->default = null;
+ $title->Default = null;
$title->comments = '';
$start_date = new stdClass;
$start_date->column_name = 'start_date';
$start_date->type = 'timestamp without time zone';
$start_date->null = 'NO';
- $start_date->default = null;
+ $start_date->Default = null;
$start_date->comments = '';
$description = new stdClass;
$description->column_name = 'description';
$description->type = 'text';
$description->null = 'NO';
- $description->default = null;
+ $description->Default = null;
$description->comments = '';
$this->assertThat(
Please sign in to comment.
Something went wrong with that request. Please try again.