Skip to content
Permalink
Browse files

Fix UUID primary key columns not being reflected properly.

When UUID columns are converted into varchar(36) they should also be
default = null, null = false.

Fixes #4695
  • Loading branch information...
markstory committed Sep 24, 2014
1 parent d7c4d3b commit 1877cab341abe95c833cfdb4ddd72069de95b318
@@ -249,6 +249,7 @@ public function describe($model) {
}
if (
$fields[$c->name]['default'] === 'NULL' ||
$c->default === null ||
preg_match('/nextval\([\'"]?([\w.]+)/', $c->default, $seq)
) {
$fields[$c->name]['default'] = null;
@@ -1099,6 +1099,26 @@ public function testLimit() {
$this->assertNotContains($scientificNotation, $result);
}
/**
* Test that postgres describes UUID columns correctly.
*
* @return void
*/
public function testDescribeUuid() {
$db = $this->Dbo;
$db->execute('CREATE TABLE test_uuid_describe (id UUID PRIMARY KEY, name VARCHAR(255))');
$data = $db->describe('test_uuid_describe');
$expected = array(
'type' => 'string',
'null' => false,
'default' => null,
'length' => 36,
);
$this->assertSame($expected, $data['id']);
$db->execute('DROP TABLE test_uuid_describe');
}
/**
* Test describe() behavior for timestamp columns.
*

0 comments on commit 1877cab

Please sign in to comment.
You can’t perform that action at this time.