Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for biginteger on SQLserver.

  • Loading branch information...
commit d4ee62be617b3f567e5d85cb681fe77912e68844 1 parent 8d8f4b5
Mark Story markstory authored
24 lib/Cake/Model/Datasource/Database/Sqlserver.php
View
@@ -86,16 +86,17 @@ class Sqlserver extends DboSource {
*/
public $columns = array(
'primary_key' => array('name' => 'IDENTITY (1, 1) NOT NULL'),
- 'string' => array('name' => 'nvarchar', 'limit' => '255'),
- 'text' => array('name' => 'nvarchar', 'limit' => 'MAX'),
- 'integer' => array('name' => 'int', 'formatter' => 'intval'),
- 'float' => array('name' => 'numeric', 'formatter' => 'floatval'),
- 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'string' => array('name' => 'nvarchar', 'limit' => '255'),
+ 'text' => array('name' => 'nvarchar', 'limit' => 'MAX'),
+ 'integer' => array('name' => 'int', 'formatter' => 'intval'),
+ 'biginteger' => array('name' => 'bigint'),
+ 'float' => array('name' => 'numeric', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
- 'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
- 'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
- 'binary' => array('name' => 'varbinary'),
- 'boolean' => array('name' => 'bit')
+ 'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
+ 'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ 'binary' => array('name' => 'varbinary'),
+ 'boolean' => array('name' => 'bit')
);
/**
@@ -399,6 +400,9 @@ public function column($real) {
if ($col == 'bit') {
return 'boolean';
}
+ if (strpos($col, 'bigint') !== false) {
+ return 'biginteger';
+ }
if (strpos($col, 'int') !== false) {
return 'integer';
}
@@ -643,7 +647,7 @@ public function insertMulti($table, $fields, $values) {
*/
public function buildColumn($column) {
$result = parent::buildColumn($column);
- $result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', $result);
+ $result = preg_replace('/(bigint|int|integer)\([0-9]+\)/i', '$1', $result);
$result = preg_replace('/(bit)\([0-9]+\)/i', '$1', $result);
if (strpos($result, 'DEFAULT NULL') !== false) {
if (isset($column['default']) && $column['default'] === '') {
8 lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php
View
@@ -553,6 +553,14 @@ public function testBuildColumn() {
$result = $this->db->buildColumn($column);
$expected = "[checked] bit DEFAULT '1'";
$this->assertEquals($expected, $result);
+
+ $column = array(
+ 'name' => 'huge',
+ 'type' => 'biginteger',
+ );
+ $result = $this->db->buildColumn($column);
+ $expected = "[huge] bigint";
+ $this->assertEquals($expected, $result);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.