mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
limiting the regex to consume only words in default value in PostgreSQL after ::
added tests showing the old behavior was broken.
This commit is contained in:
parent
5b57a1e926
commit
23e38aeaf0
2 changed files with 21 additions and 1 deletions
|
@ -251,7 +251,7 @@ class Postgres extends DboSource {
|
||||||
'default' => preg_replace(
|
'default' => preg_replace(
|
||||||
"/^'(.*)'$/",
|
"/^'(.*)'$/",
|
||||||
"$1",
|
"$1",
|
||||||
preg_replace('/::.*/', '', $c->default)
|
preg_replace('/::[\w\s]+/', '', $c->default)
|
||||||
),
|
),
|
||||||
'length' => $length,
|
'length' => $length,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1218,4 +1218,24 @@ class PostgresTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->assertEquals('"col1" uuid', $result);
|
$this->assertEquals('"col1" uuid', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that postgres describes default columns with functions correctly.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testDescribeFunctionDefault() {
|
||||||
|
$db = $this->Dbo;
|
||||||
|
$db->execute('CREATE TABLE test_function_default_describe (id integer PRIMARY KEY, year int default date_part(\'year\'::text, now()))');
|
||||||
|
$data = $db->describe('test_function_default_describe');
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'null' => true,
|
||||||
|
'default' => 'date_part(\'year\', now())',
|
||||||
|
'length' => null,
|
||||||
|
);
|
||||||
|
$this->assertSame($expected, $data['year']);
|
||||||
|
$db->execute('DROP TABLE test_function_default_describe');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue