Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 0f05c99

Browse files
author
Simone Mosciatti
committed
support for i64 integers
1 parent 49e12af commit 0f05c99

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

redisql_lib/src/sqlite.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub enum EntityType {
184184

185185
// TODO XXX explore it is possible to change these String into &str
186186
pub enum Entity {
187-
Integer { int: i32 },
187+
Integer { int: i64 },
188188
Float { float: f64 },
189189
Text { text: String },
190190
Blob { blob: String },
@@ -199,7 +199,7 @@ impl Entity {
199199
match get_entity_type(stmt.get_raw_stmt(), i) {
200200
EntityType::Integer => {
201201
let int = unsafe {
202-
ffi::sqlite3_column_int(stmt.get_raw_stmt(), i)
202+
ffi::sqlite3_column_int64(stmt.get_raw_stmt(), i)
203203
};
204204
Entity::Integer { int }
205205
}
@@ -215,9 +215,8 @@ impl Entity {
215215
stmt.get_raw_stmt(),
216216
i,
217217
)
218-
as *const c_char)
219-
.to_string_lossy()
220-
.into_owned()
218+
as *const c_char).to_string_lossy()
219+
.into_owned()
221220
};
222221
Entity::Text { text: value }
223222
}
@@ -228,9 +227,8 @@ impl Entity {
228227
stmt.get_raw_stmt(),
229228
i,
230229
)
231-
as *const c_char)
232-
.to_string_lossy()
233-
.into_owned()
230+
as *const c_char).to_string_lossy()
231+
.into_owned()
234232
};
235233
Entity::Blob { blob: value }
236234
}

test/correctness/test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,25 @@ def test_statements_copy_now_mem_from_mem(self):
621621
result = self.exec_naked("REDISQL.QUERY_STATEMENT", "DB2", "select1")
622622
self.assertEquals(result, [[1L]])
623623

624+
class TestBigInt(TestRediSQLWithExec):
625+
def test_big_int(self):
626+
with DB(self, "A"):
627+
done = self.exec_naked("REDISQL.EXEC", "A", "CREATE TABLE ip_to_asn(start INT8, end INT8, asn int, hosts int8)")
628+
self.assertEquals(done, ["DONE", 0L])
629+
630+
done = self.exec_naked("REDISQL.EXEC", "A", "insert into ip_to_asn values (2883484276228096000, 2883484280523063295, 265030, 4294967295)")
631+
self.assertEquals(done, ["DONE", 1L])
632+
633+
result = self.exec_naked("REDISQL.EXEC", "A", "SELECT * FROM ip_to_asn;")
634+
self.assertEquals(result, [
635+
[
636+
2883484276228096000,
637+
2883484280523063295,
638+
265030,
639+
4294967295]
640+
])
641+
642+
624643

625644
if __name__ == '__main__':
626645
unittest.main()

0 commit comments

Comments
 (0)