diff --git a/.gitignore b/.gitignore index 45315ea0c..e2b80f60e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ test/std/arm64 test/std/cpp32 test/std/cpp64 test/std/mybase.db +test/std/hxcpp.db test/opMatrix/Ops.hx test/opMatrix/cpp test/haxe/cpp @@ -25,4 +26,4 @@ hxcpp.n *.pdb *.ilk -.vscode \ No newline at end of file +.vscode diff --git a/src/hx/libs/sqlite/Sqlite.cpp b/src/hx/libs/sqlite/Sqlite.cpp index f4ca20b42..1fbfa1081 100644 --- a/src/hx/libs/sqlite/Sqlite.cpp +++ b/src/hx/libs/sqlite/Sqlite.cpp @@ -323,7 +323,7 @@ Dynamic _hx_sqlite_result_next(Dynamic handle) case SQLITE_BLOB: { int size = sqlite3_column_bytes(r->r,i); - f = String::create((const char *)sqlite3_column_blob(r->r,i),size); + f = Array_obj::fromData((const unsigned char *)sqlite3_column_blob(r->r,i),size); break; } default: diff --git a/test/std/Test.hx b/test/std/Test.hx index 3cfe0d6f3..8a4b6ba6e 100644 --- a/test/std/Test.hx +++ b/test/std/Test.hx @@ -104,38 +104,47 @@ class Test v("connected :" + cnx); if (cnx.dbName() == "SQLite") { cnx.request(" - CREATE TABLE IF NOT EXISTS User ( + CREATE TABLE IF NOT EXISTS UserPwd ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, - money DOUBLE + money DOUBLE, + password BLOB )"); } else { cnx.request(" - CREATE TABLE IF NOT EXISTS User ( + CREATE TABLE IF NOT EXISTS UserPwd ( id INTEGER NOT NULL AUTO_INCREMENT, name TEXT, age INTEGER, money DOUBLE, + password BLOB, PRIMARY KEY(id) )"); } - var dels = cnx.request("DELETE FROM User"); + var dels = cnx.request("DELETE FROM UserPwd"); if (dels.nfields != 0) return error("Bad DELETE'd result"); v("deleted " + dels.length + " existing rows"); - cnx.request("INSERT INTO User (name,age,money) VALUES ('John',32,100.45)"); - cnx.request("INSERT INTO User (name,age,money) VALUES ('Bob',14,4.50)"); + cnx.request("INSERT INTO UserPwd (name,age,money,password) VALUES ('John',32,100.45,X'c0ffee')"); + cnx.request("INSERT INTO UserPwd (name,age,money,password) VALUES ('Bob',14,4.50,X'deadbeef01020304')"); - var rset = cnx.request("SELECT * FROM User"); + var rset = cnx.request("SELECT * FROM UserPwd"); var length = rset.length; v("found "+length+" users"); if (length!=2) return error("Bad user count"); for( row in rset ) - v(" user "+row.name+" is "+row.age+" years old "); + { + var pass:Dynamic = row.password; + var password = Std.is(pass, haxe.io.BytesData) ? haxe.io.Bytes.ofData(pass) : pass; + var md5 = haxe.crypto.Md5.make(password).toHex().substr(0,8); + v(" user "+row.name+" is "+row.age+" years old, password:" + md5); + if (md5!="5f80e231" && md5!="8ed0b363") + return error("Bad binary blob store"); + } return 0; }