mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing describing of table columns for postgres
This commit is contained in:
parent
3f0c79f7f9
commit
d0fc2fd171
2 changed files with 9 additions and 9 deletions
|
@ -199,15 +199,15 @@ class DboPostgres extends DboSource {
|
|||
|
||||
foreach ($cols as $c) {
|
||||
$type = $c->type;
|
||||
if (!empty($c->char_length)) {
|
||||
$length = intval($c->char_length);
|
||||
} elseif (!empty($c->oct_length)) {
|
||||
if (!empty($c->oct_length) && $c->char_length === null) {
|
||||
if ($c->type == 'character varying') {
|
||||
$length = null;
|
||||
$type = 'text';
|
||||
} else {
|
||||
$length = intval($c->oct_length);
|
||||
}
|
||||
} elseif (!empty($c->char_length)) {
|
||||
$length = intval($c->char_length);
|
||||
} else {
|
||||
$length = $this->length($c->type);
|
||||
}
|
||||
|
|
|
@ -556,12 +556,12 @@ class DboPostgresTest extends CakeTestCase {
|
|||
$db1 = ConnectionManager::getDataSource('test');
|
||||
$db1->cacheSources = false;
|
||||
$db1->reconnect(array('persistent' => false));
|
||||
$db1->query('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' (
|
||||
$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatypes') . ' (
|
||||
id serial NOT NULL,
|
||||
"varchar" character varying(40) NOT NULL,
|
||||
"full_length" character varying NOT NULL,
|
||||
"timestamp" timestamp without time zone,
|
||||
date date,
|
||||
"date" date,
|
||||
CONSTRAINT test_data_types_pkey PRIMARY KEY (id)
|
||||
)');
|
||||
$model = new Model(array('name' => 'Datatype', 'ds' => 'test'));
|
||||
|
@ -570,21 +570,21 @@ class DboPostgresTest extends CakeTestCase {
|
|||
'connection' => 'test',
|
||||
'models' => array('Datatype')
|
||||
));
|
||||
$schema->tables = array('datatypes' => $result['tables']['datatypes']);
|
||||
|
||||
$schema->tables = array('datatypes' => $result['tables']['missing']['datatypes']);
|
||||
$result = $db1->createSchema($schema, 'datatypes');
|
||||
$db1->rawQuery('DROP TABLE ' . $db1->fullTableName('datatypes'));
|
||||
|
||||
$this->assertNoPattern('/timestamp DEFAULT/', $result);
|
||||
$this->assertPattern('/\"full_length\"\s*text\s.*,/', $result);
|
||||
$this->assertPattern('/timestamp\s*,/', $result);
|
||||
|
||||
$db1->query('DROP TABLE ' . $db1->fullTableName('datatypes'));
|
||||
|
||||
$db1->query($result);
|
||||
$result2 = $schema->read(array(
|
||||
'connection' => 'test',
|
||||
'models' => array('Datatype')
|
||||
));
|
||||
$schema->tables = array('datatypes' => $result2['tables']['datatypes']);
|
||||
$schema->tables = array('datatypes' => $result2['tables']['missing']['datatypes']);
|
||||
$result2 = $db1->createSchema($schema, 'datatypes');
|
||||
$this->assertEqual($result, $result2);
|
||||
|
||||
|
|
Loading…
Reference in a new issue