nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gamnit: make `SpriteSet` public so clients can use its services
[nit.git]
/
lib
/
sqlite3
/
sqlite3.nit
diff --git
a/lib/sqlite3/sqlite3.nit
b/lib/sqlite3/sqlite3.nit
index
31c585f
..
daa980b
100644
(file)
--- a/
lib/sqlite3/sqlite3.nit
+++ b/
lib/sqlite3/sqlite3.nit
@@
-57,8
+57,8
@@
class Sqlite3DB
# Prepare and return a `Statement`, return `null` on error
fun prepare(sql: Text): nullable Statement
do
# Prepare and return a `Statement`, return `null` on error
fun prepare(sql: Text): nullable Statement
do
- var native_stmt = native_connection.prepare(sql.to_s)
- if native_stmt == null then return null
+ var native_stmt = native_connection.prepare(sql.to_cstring)
+ if native_stmt.address_is_null then return null
var stmt = new Statement(native_stmt)
open_statements.add stmt
var stmt = new Statement(native_stmt)
open_statements.add stmt
@@
-68,7
+68,7
@@
class Sqlite3DB
# Execute the `sql` statement and return `true` on success
fun execute(sql: Text): Bool
do
# Execute the `sql` statement and return `true` on success
fun execute(sql: Text): Bool
do
- var err = native_connection.exec(sql.to_s)
+ var err = native_connection.exec(sql.to_cstring)
return err.is_ok
end
return err.is_ok
end
@@
-99,7
+99,7
@@
class Sqlite3DB
do
if not native_connection.is_valid then
var err = sys.sqlite_open_error
do
if not native_connection.is_valid then
var err = sys.sqlite_open_error
- if err == null then return null
+ if err.is_ok then return null
return err.to_s
end
return err.to_s
end
@@
-155,6
+155,17
@@
class StatementRow
# Statement linked to `self`
var statement: Statement
# Statement linked to `self`
var statement: Statement
+ # Maps the column name to its value
+ fun map: Map[String, nullable Sqlite3Data]
+ do
+ var ret = new ArrayMap[String, nullable Sqlite3Data]
+ for i in [0 .. length[ do
+ var st = self[i]
+ ret[st.name] = st.value
+ end
+ return ret
+ end
+
# Number of entries in this row
#
# require: `self.statement.is_open`
# Number of entries in this row
#
# require: `self.statement.is_open`
@@
-182,7
+193,9
@@
class StatementEntry
var name: String is lazy do
assert statement_closed: statement.is_open
var name: String is lazy do
assert statement_closed: statement.is_open
- return statement.native_statement.column_name(index)
+ var cname = statement.native_statement.column_name(index)
+ assert not cname.address_is_null
+ return cname.to_s
end
# Get the value of this entry according to its Sqlite type
end
# Get the value of this entry according to its Sqlite type
@@
-237,9
+250,9
@@
class StatementEntry
do
assert statement_closed: statement.is_open
do
assert statement_closed: statement.is_open
- var native_string = statement.native_statement.column_text(index)
- if native_string.address_is_null then return ""
- return native_string.to_s_with_copy
+ var c_string = statement.native_statement.column_text(index)
+ if c_string.address_is_null then return ""
+ return c_string.to_s
end
# Get this entry as `Blob`
end
# Get this entry as `Blob`