From 4a4437b9efc0ea2b0422ef08a1a50c5e2bf3d9d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Wed, 16 Jul 2014 12:56:36 -0400 Subject: [PATCH] lib/sqlite3: use a precise type as return of column_type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/sqlite3/native_sqlite3.nit | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/sqlite3/native_sqlite3.nit b/lib/sqlite3/native_sqlite3.nit index 10cb886..f200b23 100644 --- a/lib/sqlite3/native_sqlite3.nit +++ b/lib/sqlite3/native_sqlite3.nit @@ -89,6 +89,7 @@ extern class NativeStatement `{sqlite3_stmt*`} return NativeString_to_s(ret); `} + # Number of bytes in the blob or string at row `i` fun column_bytes(i: Int) : Int `{ return sqlite3_column_bytes(recv, i); `} @@ -109,7 +110,8 @@ extern class NativeStatement `{sqlite3_stmt*`} return NativeString_to_s(ret); `} - fun column_type(i: Int) : Int `{ + # Type of the entry at row `i` + fun column_type(i: Int): DataType `{ return sqlite3_column_type(recv, i); `} @@ -169,3 +171,14 @@ extern class NativeSqlite3 `{sqlite3 *`} return sqlite3_errcode(recv); `} end + +# Sqlite data types +extern class DataType `{ int `} + fun is_integer: Bool `{ return recv == SQLITE_INTEGER; `} + fun is_float: Bool `{ return recv == SQLITE_FLOAT; `} + fun is_blob: Bool `{ return recv == SQLITE_BLOB; `} + fun is_null: Bool `{ return recv == SQLITE_NULL; `} + fun is_text: Bool `{ return recv == SQLITE_TEXT; `} + + fun to_i: Int `{ return recv; `} +end -- 1.7.9.5