Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Changed PostgreSQL's getTableColumns. #1174

Merged
merged 1 commit into from

2 participants

@gpongelli

Now returns object with "Default" property instead of "default", as MySQL and other driver 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.

@gpongelli gpongelli 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.
dd5ee04
@LouisLandry LouisLandry merged commit ae0730b into joomla:staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 27, 2012
  1. @gpongelli

    Changed getTableColumns to return object with "Default" property instead

    gpongelli authored
    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.
This page is out of date. Refresh to see the latest.
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(
Something went wrong with that request. Please try again.