2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
947 stars 82 forks source link

gd-extension: Error retrieving accented characters #87

Closed Loxtir closed 2 years ago

Loxtir commented 2 years ago

Environment:

Issue description:

Accented characters are not retrieved correctly from the database. This worked fine on Godot 3.X **Steps to reproduce:** ``` db.query("CREATE TABLE \"Test\" (\"name\" TEXT NOT NULL, PRIMARY KEY(\"name\"))") db.query("insert into Test (name) values (\"ÁéÍóÚ\")") db.query("select * from Test") print(db.query_result[0]["name"]) ``` Expected this to print "ÁéÍóÚ", got "ÁéÍóÃ" instead. Inspecting the database with DBBrowser shows the value is being saved correctly. **Minimal reproduction project:** [SqliteTest.zip](https://github.com/2shady4u/godot-sqlite/files/9410111/SqliteTest.zip) **Additional context** I hope the bug isn't on my end, it's my first opened issue
2shady4u commented 2 years ago

Hello @Loxtir

I would expect this to be an issue that is either related to Godot 4.0 or to godot-cpp, but I'm not sure? I'll do some research and I'll get back to this...

2shady4u commented 2 years ago

https://github.com/godotengine/godot-cpp/issues/784 might be related?

2shady4u commented 2 years ago

You can definitely leave this open until we figure out the cause of this issue 😄 I'm currently quite busy with other things so this might take a while... My apologies for that 🙇

Loxtir commented 2 years ago

godotengine/godot-cpp#784 might be related?

So in case it helps someone, undoing this change as discussed in that issue and compiling godot-cpp and the plugin myself fixes the issue.

lightyears1998 commented 2 years ago

I encountered a similar issue. By changing this line in gdsqlite.cpp to column_value = Variant(String::utf8((char *)sqlite3_column_text(stmt, i))); and compiling the plugin fix the issue for me.

2shady4u commented 2 years ago

I encountered a similar issue. By changing this line in gdsqlite.cpp to column_value = Variant(String::utf8((char *)sqlite3_column_text(stmt, i))); and compiling the plugin fix the issue for me.

Thanks for finding and reporting this! 😄 I'll look into it as soon as I have some time

2shady4u commented 2 years ago

@lightyears1998 I've seen that you fixed the error on your fork 👀

Is it working correctly on your end? If yes, would you be willing to open a pull request with your fix? 😅

lightyears1998 commented 2 years ago

@lightyears1998 I've seen that you fixed the error on your fork 👀

Is it working correctly on your end? If yes, would you be willing to open a pull request with your fix? 😅

It is working correctly on my side. However, I had only tested it for unicode column value. I'd like to do some more additional tests before submitting my PR. It may take a while. 😁

2shady4u commented 2 years ago

This has now been fixed by #90!