Skip to content
This repository
Browse code

Add support for biginteger on SQLserver.

  • Loading branch information...
commit d4ee62be617b3f567e5d85cb681fe77912e68844 1 parent 8d8f4b5
Mark Story authored August 30, 2012
24  lib/Cake/Model/Datasource/Database/Sqlserver.php
@@ -86,16 +86,17 @@ class Sqlserver extends DboSource {
86 86
  */
87 87
 	public $columns = array(
88 88
 		'primary_key' => array('name' => 'IDENTITY (1, 1) NOT NULL'),
89  
-		'string'	=> array('name' => 'nvarchar', 'limit' => '255'),
90  
-		'text'		=> array('name' => 'nvarchar', 'limit' => 'MAX'),
91  
-		'integer'	=> array('name' => 'int', 'formatter' => 'intval'),
92  
-		'float'		=> array('name' => 'numeric', 'formatter' => 'floatval'),
93  
-		'datetime'	=> array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
  89
+		'string' => array('name' => 'nvarchar', 'limit' => '255'),
  90
+		'text' => array('name' => 'nvarchar', 'limit' => 'MAX'),
  91
+		'integer' => array('name' => 'int', 'formatter' => 'intval'),
  92
+		'biginteger' => array('name' => 'bigint'),
  93
+		'float' => array('name' => 'numeric', 'formatter' => 'floatval'),
  94
+		'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
94 95
 		'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
95  
-		'time'		=> array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
96  
-		'date'		=> array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
97  
-		'binary'	=> array('name' => 'varbinary'),
98  
-		'boolean'	=> array('name' => 'bit')
  96
+		'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
  97
+		'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
  98
+		'binary' => array('name' => 'varbinary'),
  99
+		'boolean' => array('name' => 'bit')
99 100
 	);
100 101
 
101 102
 /**
@@ -399,6 +400,9 @@ public function column($real) {
399 400
 		if ($col == 'bit') {
400 401
 			return 'boolean';
401 402
 		}
  403
+		if (strpos($col, 'bigint') !== false) {
  404
+			return 'biginteger';
  405
+		}
402 406
 		if (strpos($col, 'int') !== false) {
403 407
 			return 'integer';
404 408
 		}
@@ -643,7 +647,7 @@ public function insertMulti($table, $fields, $values) {
643 647
  */
644 648
 	public function buildColumn($column) {
645 649
 		$result = parent::buildColumn($column);
646  
-		$result = preg_replace('/(int|integer)\([0-9]+\)/i', '$1', $result);
  650
+		$result = preg_replace('/(bigint|int|integer)\([0-9]+\)/i', '$1', $result);
647 651
 		$result = preg_replace('/(bit)\([0-9]+\)/i', '$1', $result);
648 652
 		if (strpos($result, 'DEFAULT NULL') !== false) {
649 653
 			if (isset($column['default']) && $column['default'] === '') {
8  lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php
@@ -553,6 +553,14 @@ public function testBuildColumn() {
553 553
 		$result = $this->db->buildColumn($column);
554 554
 		$expected = "[checked] bit DEFAULT '1'";
555 555
 		$this->assertEquals($expected, $result);
  556
+
  557
+		$column = array(
  558
+			'name' => 'huge',
  559
+			'type' => 'biginteger',
  560
+		);
  561
+		$result = $this->db->buildColumn($column);
  562
+		$expected = "[huge] bigint";
  563
+		$this->assertEquals($expected, $result);
556 564
 	}
557 565
 
558 566
 /**

0 notes on commit d4ee62b

Please sign in to comment.
Something went wrong with that request. Please try again.