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

SQLite SELECT Query Error if record not found. #895

Closed
dimensionscape opened this issue Apr 8, 2020 · 7 comments
Closed

SQLite SELECT Query Error if record not found. #895

dimensionscape opened this issue Apr 8, 2020 · 7 comments

Comments

@dimensionscape
Copy link
Contributor

"Invalid sqlite result" error when I check to see if the result length is >0. Works right on other platforms. Should I be handling this differently or is this a bug?

@sonygod
Copy link

sonygod commented Apr 30, 2020

@jonasmalacofilho will you take a look?

@jonasmalacofilho
Copy link
Member

Can't reproduce it locally.

$ cat Test.hx 
class Test {
	static function main() {
		var cnx = sys.db.Sqlite.open(":memory:");
		var res = cnx.request("SELECT 1 foo, 'b' bar");
		if (res.length > 0)
			trace(res.next());
		cnx.close();
	}
}

$ haxe --cpp bin --main Test
[...]

$ bin/Test 
Test.hx:6: { foo => 1, bar => b }

Will need a minimal reproduceable example as well as Haxe and Hxcpp versions. Probably best to mention the OS in use as well.

@dimensionscape
Copy link
Contributor Author

Sure, I will post the code when I am able to get back into the office. To clarify, as pointed out in the subject, the error is incurred when the record is not found.
if (res.length > 0) else trace("record not found");

It works on Neko, but for cpp we had to work around it with try/catch. hxcpp 4.0.64, haxe 4, windows 10

@jonasmalacofilho
Copy link
Member

@dimensionscape

Ok, by changing to your hxcpp version I can also reproduce the problem. It's something that has already been fixed, but the patch hasn't reached a stable hxcpp release yet: #856 ("Handle .length and .nfields on empty result sets").

The fix is already available on the master branch, so if you manually install (and build) hxcpp from git you should be set.


@sonygod

Please point me in the correct direction when you ping me for something that you know has been solved. Even if I'm the author of a commit that fixes something doesn't mean that I'll immediately remember about it, and I can easily spend a bunch time rediscovering the same fix again.

@dimensionscape
Copy link
Contributor Author

Sorry, I didn't mean to waste your time, thanks so much for the quick reply.

@jonasmalacofilho
Copy link
Member

Don't worry about it.

And @sonygod, perhaps I ended up being more harsh than I intended. Please don't worry too much about it either.

@sonygod
Copy link

sonygod commented May 8, 2020

@jonasmalacofilho ,sorry for delay .

I post my code here

#900

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