Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read 32-bit and 64-bit integer from sqlite database #167

Open
avl93 opened this issue Jun 21, 2017 · 2 comments
Open

Unable to read 32-bit and 64-bit integer from sqlite database #167

avl93 opened this issue Jun 21, 2017 · 2 comments

Comments

@avl93
Copy link

avl93 commented Jun 21, 2017

Sqlite in neko can only read 31-bit integers from sqlite. Example:

class Main
{
	public static function main(){
		var connection = sys.db.Sqlite.open("test.db");
		
		var max31bit: haxe.Int64 = 0x40000000 - 1 ;
		
		var values : Array<haxe.Int64> = [ max31bit, max31bit+1, max31bit<<33];

		connection.request('create table if not exists test (column1 int)');
		connection.request('delete from test');
		for (currValue in values) {
			connection.request('insert into test values ($currValue)');
		}
		
		var rs : sys.db.ResultSet = connection.request("select * from test");
		while (rs.hasNext()){
			trace(rs.next());
		}
	}
}

Result:

Main.hx:18: { column1 => 1073741823 }
Main.hx:18: { column1 => -1073741824 }
Main.hx:18: { column1 => 0 }

Expected:

Main.hx:18: { column1 => 1073741823 }
Main.hx:18: { column1 => 1073741824 }
Main.hx:18: { column1 => 9223372028264841216 }

Though, Neko can correctly write 32-bit and even 64-bit integers to sqlite database, and I can read them using sqlite CLI:

>sqlite3 test.db
SQLite version 3.18.0 2017-03-28 18:48:43
Enter ".help" for usage hints.
sqlite> select * from test;
1073741823
1073741824
9223372028264841216

Tested on NekoVM 2.1.0 and Haxe Compiler 3.4.2.

@ncannasse
Copy link
Member

ncannasse commented Jun 24, 2017 via email

@andyli
Copy link
Member

andyli commented Dec 19, 2017

I fixed the int32 case, such that it outputs

Test.hx:18: { column1 => 1073741823 }
Test.hx:18: { column1 => 1073741824 }
Test.hx:18: { column1 => 0 }

No idea about int64. (#55?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants