make C constants values
This commit is contained in:
@@ -53,11 +53,16 @@ pub extern column-count(^stmt: any): int
|
|||||||
|
|
||||||
pub extern column-type(^stmt: any, col: int32): int32
|
pub extern column-type(^stmt: any, col: int32): int32
|
||||||
c "kk_sqlite3_column_type"
|
c "kk_sqlite3_column_type"
|
||||||
pub extern int32/integer(): int32 { c inline "SQLITE_INTEGER" }
|
extern make-sqlite-integer(): int32 { c inline "SQLITE_INTEGER" }
|
||||||
pub extern int32/float(): int32 { c inline "SQLITE_FLOAT" }
|
pub val int32/integer = make-sqlite-integer()
|
||||||
pub extern int32/blob(): int32 { c inline "SQLITE_BLOB" }
|
extern make-sqlite-float(): int32 { c inline "SQLITE_FLOAT" }
|
||||||
pub extern int32/null(): int32 { c inline "SQLITE_NULL" }
|
pub val int32/float = make-sqlite-float()
|
||||||
pub extern int32/text(): int32 { c inline "SQLITE_TEXT" }
|
extern make-sqlite-blob(): int32 { c inline "SQLITE_BLOB" }
|
||||||
|
pub val int32/blob = make-sqlite-blob()
|
||||||
|
extern make-sqlite-null(): int32 { c inline "SQLITE_NULL" }
|
||||||
|
pub val int32/null = make-sqlite-null()
|
||||||
|
extern make-sqlite-text(): int32 { c inline "SQLITE_TEXT" }
|
||||||
|
pub val int32/text = make-sqlite-text()
|
||||||
|
|
||||||
//TODO(zephyr): waiting on a proper bytes type in koka
|
//TODO(zephyr): waiting on a proper bytes type in koka
|
||||||
// pub extern column-blob(^stmt: any, col: int32): maybe<bytes>
|
// pub extern column-blob(^stmt: any, col: int32): maybe<bytes>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Low level wrapper around a modern subset of the SQLite3 API.
|
// Low level wrapper around a modern subset of the SQLite3 API.
|
||||||
//
|
//
|
||||||
// Using this module involves manual resource management.
|
// Using this module involves manual resource management.
|
||||||
//
|
// Statements must be finalized and databases must be closed.
|
||||||
module sqlite/sqlite3
|
module sqlite/sqlite3
|
||||||
|
|
||||||
import sqlite/capi
|
import sqlite/capi
|
||||||
@@ -143,10 +143,10 @@ pub type sqlite3-type
|
|||||||
// The leftmost column is numbered 0.
|
// The leftmost column is numbered 0.
|
||||||
pub fun statment/column-type(stmt: statement, col: int): sqlite3-type
|
pub fun statment/column-type(stmt: statement, col: int): sqlite3-type
|
||||||
val t = capi/column-type(stmt.cref, col.int32)
|
val t = capi/column-type(stmt.cref, col.int32)
|
||||||
if t == int32/integer() then Integer
|
if t == capi/int32/integer then Integer
|
||||||
else if t == int32/float() then Float
|
else if t == capi/int32/float then Float
|
||||||
else if t == int32/blob() then Blob
|
else if t == capi/int32/blob then Blob
|
||||||
else if t == int32/text() then Text
|
else if t == capi/int32/text then Text
|
||||||
// If the DB gives us something unimaginable, pretend it's nothing.
|
// If the DB gives us something unimaginable, pretend it's nothing.
|
||||||
else Null
|
else Null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user