[Groonga-commit] groonga/groonga [master] Support Bool -> UInt8 cast

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Wed Feb 13 22:27:32 JST 2013


Kouhei Sutou	2013-02-13 22:27:32 +0900 (Wed, 13 Feb 2013)

  New Revision: 8d3dc5ad153ad3d0abbc705f779fbb6307271e28
  https://github.com/groonga/groonga/commit/8d3dc5ad153ad3d0abbc705f779fbb6307271e28

  Log:
    Support Bool -> UInt8 cast

  Added files:
    test/command/suite/load/bool/cast/uint8.expected
    test/command/suite/load/bool/cast/uint8.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+3 -0)
===================================================================
--- lib/db.c    2013-02-13 22:26:02 +0900 (b128296)
+++ lib/db.c    2013-02-13 22:27:32 +0900 (03d465e)
@@ -4215,6 +4215,9 @@ grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp)
   case GRN_DB_INT8 :
     GRN_INT8_SET(ctx, dest, GRN_BOOL_VALUE(src));
     break;
+  case GRN_DB_UINT8 :
+    GRN_UINT8_SET(ctx, dest, GRN_BOOL_VALUE(src));
+    break;
   default :
     SRC2RECORD();
   }

  Added: test/command/suite/load/bool/cast/uint8.expected (+49 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/load/bool/cast/uint8.expected    2013-02-13 22:27:32 +0900 (d8c95ac)
@@ -0,0 +1,49 @@
+table_create  Entries       TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Entries score COLUMN_SCALAR  UInt8
+[[0,0.0,0.0],true]
+load --table Entries
+[
+{"_key": "Special news!",  "score": true},
+{"_key": "Surprise news!", "score": false}
+]
+[[0,0.0,0.0],2]
+select Entries
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "score",
+          "UInt8"
+        ]
+      ],
+      [
+        1,
+        "Special news!",
+        1
+      ],
+      [
+        2,
+        "Surprise news!",
+        0
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/load/bool/cast/uint8.test (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/load/bool/cast/uint8.test    2013-02-13 22:27:32 +0900 (17beeba)
@@ -0,0 +1,10 @@
+table_create  Entries       TABLE_HASH_KEY ShortText
+column_create Entries score COLUMN_SCALAR  UInt8
+
+load --table Entries
+[
+{"_key": "Special news!",  "score": true},
+{"_key": "Surprise news!", "score": false}
+]
+
+select Entries
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index