mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #12653 from begnini/fix_describe_pgsql_function
limiting the regex to consume only words in default value in pgsql
This commit is contained in:
commit
2bdc04e53c
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