mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56: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
|
||||
*/
|
||||
public function describe($model) {
|
||||
$table = $this->fullTableName($model, false);
|
||||
$cache = parent::describe($table);
|
||||
$table = $this->fullTableName($model, false, false);
|
||||
$fulltable = $this->fullTableName($model, false, true);
|
||||
|
||||
$cache = parent::describe($fulltable);
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
$table = $this->fullTableName($model, false, false);
|
||||
$schema = $model->schemaName;
|
||||
|
||||
$cols = $this->_execute(
|
||||
"SELECT
|
||||
COLUMN_NAME as Field,
|
||||
DATA_TYPE as Type,
|
||||
COL_LENGTH('" . $table . "', COLUMN_NAME) as Length,
|
||||
COL_LENGTH('" . ($schema ? $fulltable : $table) . "', COLUMN_NAME) as Length,
|
||||
IS_NULLABLE As [Null],
|
||||
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
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_NAME = '" . $table . "'" . ($schema ? " AND TABLE_SCHEMA = '" . $schema . "'" : '')
|
||||
);
|
||||
|
||||
if (!$cols) {
|
||||
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->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']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -204,7 +204,13 @@ class Hash {
|
|||
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.
|
||||
if ($op === '=' && $val && $val[0] === '/') {
|
||||
|
|
Loading…
Add table
Reference in a new issue