mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge branch 'master' into 2.5
This commit is contained in:
commit
bf9c3029cb
4 changed files with 50 additions and 7 deletions
|
@ -199,26 +199,30 @@ class Sqlserver extends DboSource {
|
||||||
* @throws CakeException
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe($model) {
|
||||||
$table = $this->fullTableName($model, false);
|
$table = $this->fullTableName($model, false, false);
|
||||||
$cache = parent::describe($table);
|
$fulltable = $this->fullTableName($model, false, true);
|
||||||
|
|
||||||
|
$cache = parent::describe($fulltable);
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = array();
|
$fields = array();
|
||||||
$table = $this->fullTableName($model, false, false);
|
|
||||||
$schema = $model->schemaName;
|
$schema = $model->schemaName;
|
||||||
|
|
||||||
$cols = $this->_execute(
|
$cols = $this->_execute(
|
||||||
"SELECT
|
"SELECT
|
||||||
COLUMN_NAME as Field,
|
COLUMN_NAME as Field,
|
||||||
DATA_TYPE as Type,
|
DATA_TYPE as Type,
|
||||||
COL_LENGTH('" . $table . "', COLUMN_NAME) as Length,
|
COL_LENGTH('" . ($schema ? $fulltable : $table) . "', COLUMN_NAME) as Length,
|
||||||
IS_NULLABLE As [Null],
|
IS_NULLABLE As [Null],
|
||||||
COLUMN_DEFAULT as [Default],
|
COLUMN_DEFAULT as [Default],
|
||||||
COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key],
|
COLUMNPROPERTY(OBJECT_ID('" . ($schema ? $fulltable : $table) . "'), COLUMN_NAME, 'IsIdentity') as [Key],
|
||||||
NUMERIC_SCALE as Size
|
NUMERIC_SCALE as Size
|
||||||
FROM INFORMATION_SCHEMA.COLUMNS
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
WHERE TABLE_NAME = '" . $table . "'" . ($schema ? " AND TABLE_SCHEMA = '" . $schema . "'" : '')
|
WHERE TABLE_NAME = '" . $table . "'" . ($schema ? " AND TABLE_SCHEMA = '" . $schema . "'" : '')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table));
|
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3487,7 +3487,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
$this->tablePrefix = $db->config['prefix'];
|
$this->tablePrefix = $db->config['prefix'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->schemaName = $db->getSchemaName();
|
$this->schemaName = (empty($this->schemaName) ? $db->getSchemaName() : $this->schemaName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -835,6 +835,39 @@ class HashTest extends CakeTestCase {
|
||||||
$this->assertEquals(5, $result[3]['id']);
|
$this->assertEquals(5, $result[3]['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test extracting based on attributes with boolean values.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testExtractAttributeBoolean() {
|
||||||
|
$users = array(
|
||||||
|
array(
|
||||||
|
'id' => 2,
|
||||||
|
'username' => 'johndoe',
|
||||||
|
'active' => true
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 5,
|
||||||
|
'username' => 'kevin',
|
||||||
|
'active' => true
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 9,
|
||||||
|
'username' => 'samantha',
|
||||||
|
'active' => false
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$result = Hash::extract($users, '{n}[active=false]');
|
||||||
|
$this->assertCount(1, $result);
|
||||||
|
$this->assertEquals($users[2], $result[0]);
|
||||||
|
|
||||||
|
$result = Hash::extract($users, '{n}[active=true]');
|
||||||
|
$this->assertCount(2, $result);
|
||||||
|
$this->assertEquals($users[0], $result[0]);
|
||||||
|
$this->assertEquals($users[1], $result[1]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that attribute matchers don't cause errors on scalar data.
|
* Test that attribute matchers don't cause errors on scalar data.
|
||||||
*
|
*
|
||||||
|
|
|
@ -204,7 +204,13 @@ class Hash {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$prop = isset($data[$attr]) ? $data[$attr] : null;
|
$prop = null;
|
||||||
|
if (isset($data[$attr])) {
|
||||||
|
$prop = $data[$attr];
|
||||||
|
}
|
||||||
|
if ($prop === true || $prop === false) {
|
||||||
|
$prop = $prop ? 'true' : 'false';
|
||||||
|
}
|
||||||
|
|
||||||
// Pattern matches and other operators.
|
// Pattern matches and other operators.
|
||||||
if ($op === '=' && $val && $val[0] === '/') {
|
if ($op === '=' && $val && $val[0] === '/') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue