mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Fixing support for nchar and nvarchar fields in SQL server.
These fields report their length as double of what its defined.
This commit is contained in:
parent
1df0801c33
commit
1a155c80c0
2 changed files with 19 additions and 0 deletions
|
@ -439,6 +439,9 @@ class Sqlserver extends DboSource {
|
|||
if ($length->Length == -1 && strpos($length->Type, 'char') !== false) {
|
||||
return null;
|
||||
}
|
||||
if (in_array($length->Type, array('nchar', 'nvarchar'))) {
|
||||
return floor($length->Length / 2);
|
||||
}
|
||||
return $length->Length;
|
||||
}
|
||||
return parent::length($length);
|
||||
|
|
|
@ -415,6 +415,15 @@ class SqlserverTest extends CakeTestCase {
|
|||
'Null' => 'YES',
|
||||
'Size' => ''
|
||||
),
|
||||
(object) array(
|
||||
'Default' => '',
|
||||
'Field' => 'id',
|
||||
'Key' => 1,
|
||||
'Type' => 'nchar',
|
||||
'Length' => 72,
|
||||
'Null' => 'NO',
|
||||
'Size' => ''
|
||||
)
|
||||
));
|
||||
$this->db->executeResultsStack = array($SqlserverTableDescription);
|
||||
$dummyModel = $this->model;
|
||||
|
@ -437,6 +446,13 @@ class SqlserverTest extends CakeTestCase {
|
|||
'null' => true,
|
||||
'default' => '',
|
||||
'length' => null
|
||||
),
|
||||
'id' => array(
|
||||
'type' => 'string',
|
||||
'null' => false,
|
||||
'default' => '',
|
||||
'length' => 36,
|
||||
'key' => 'primary'
|
||||
)
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
|
Loading…
Add table
Reference in a new issue