Skip to content

Commit

Permalink
Fixed a segfault in SqliteStmt.toHashMap and changed select_from exam…
Browse files Browse the repository at this point in the history
…ple to utilize that method
  • Loading branch information
kuzux committed Nov 5, 2009
1 parent fda4872 commit ff67b69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions examples/select_from.ooc
@@ -1,17 +1,17 @@
use sqlite3
import sqlite3/[Sqlite3, ResultCodes]
import structs/HashMap

main: func {
db := Sqlite3 new("asd.db")
stmt := db prepare("select * from stuff")
stmt toString() println()
res := stmt step()
while(res==Sqlite3Code row){
stmt columnName(0) println()
stmt intColumn(0) toString() println()
stmt columnName(1) println()
stmt intColumn(1) toString() println()

h := stmt toHashMap()
h get("asd") toInt() toString() println()
h get("zxc") toInt() toString() println()

res = stmt step()
}
stmt finalize()
Expand Down
11 changes: 6 additions & 5 deletions sqlite3/Sqlite3.ooc
@@ -1,4 +1,5 @@
include sqlite3
import structs/HashMap

SqliteStruct: cover from sqlite3*
SqliteStmtStruct: cover from sqlite3_stmt*
Expand Down Expand Up @@ -51,14 +52,14 @@ SqliteStmt: cover from SqliteStmtStruct {
toString: extern(sqlite3_sql) func -> String

toHashMap: func -> HashMap<SqliteValue>{
res := HashMap<SqliteValue> new
n := this columnCount()+1
for(i in 1..n){
map := HashMap<SqliteValue> new()
n := this columnCount()
for(i in 0..n){
name := this columnName(i)
val := this valueColumn(i)
res put(name, val)
map put(name, val)
}
return res
return map
}
}

Expand Down

0 comments on commit ff67b69

Please sign in to comment.