thobbs / phpcassa

PHP client library for Apache Cassandra
thobbs.github.com/phpcassa
MIT License
248 stars 78 forks source link

DateType insert giving error #63

Closed sunjith closed 12 years ago

sunjith commented 12 years ago

When you try to insert value to a DateType column with milliseconds value, it gives error: Expected 8 or 0 byte long for date

This patch fixes the problem:

0.8.a.2/columnfamily.php    2012-01-12 22:59:12.000000000 +0530
new/columnfamily.php    2012-03-21 12:40:53.000000000 +0530
@@ -771,7 +771,7 @@

     private static $TYPES = array('BytesType' => 1, 'LongType' => 1, 'IntegerType' => 1,
                                   'UTF8Type' => 1, 'AsciiType' => 1, 'LexicalUUIDType' => 1,
-                                  'TimeUUIDType' => 1);
+                                  'TimeUUIDType' => 1, 'DateType' => 1);

     private static function extract_type_name($type_string) {
         if ($type_string == null or $type_string == '')
@@ -995,7 +995,7 @@
     }

     private function pack($value, $data_type) {
-        if ($data_type == 'LongType')
+        if (($data_type == 'LongType') || ($data_type == 'DateType'))
             return self::pack_long($value);
         else if ($data_type == 'IntegerType')
             return pack('N', $value); // Unsigned 32bit big-endian
lafka commented 12 years ago

Pull request for 1.0.a.2 here abf3dcfa7de0f83300fbe66f2855a9696af36165

thobbs commented 12 years ago

DateType is supported in master now.