You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since gdscript doesn't support pointers or passing by reference, it would be more efficient and possibly safer to have query() return the actual recordset instead of a boolean. In the current implementation, the caller has to duplicate the recordset into an empty dictionary in order to preserve it or it gets deleted on the next query().
Current:
var my_result = {}
if db.query(sql_string):
my_result = db.query_result.duplicate() # adds more overhead if query_result is complex
New:
var my_result = {}
my_result = db.query(sql_string)
if my_result.empty():
# error handling
else
# do stuff with my_result without having to duplicate it or worry it will be overwritten by another query()
The text was updated successfully, but these errors were encountered:
I've implemented it like that because duplicating an Array creates considerable overhead (both in C++ and GDScript).
There are a lot of queries that do not require anything to be returned in which case this duplication would just be a duplication of an empty array.
This indicates that variables are in fact passed by reference (I was mistaken above) so unless there's some strange marshalling problem, the dictionary can be part of the C++ implementation?
Then instead of using Dictionary column_dict; to store the query and copying it to a query_result, you could just iterate over the query rows and put them directly into result?
Describe the solution you'd like
Since gdscript doesn't support pointers or passing by reference, it would be more efficient and possibly safer to have query() return the actual recordset instead of a boolean. In the current implementation, the caller has to duplicate the recordset into an empty dictionary in order to preserve it or it gets deleted on the next query().
Current:
New:
The text was updated successfully, but these errors were encountered: