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

Can't save blobs with db.update_rows(...) #41

Closed
mrimvo opened this issue Mar 16, 2021 · 7 comments
Closed

Can't save blobs with db.update_rows(...) #41

mrimvo opened this issue Mar 16, 2021 · 7 comments

Comments

@mrimvo
Copy link

mrimvo commented Mar 16, 2021

Using db.update_rows(...), saving blobs does not work.

Output is:

UPDATE users SET myblob=[PoolByteArray] WHERE uid = 4026253021;
SQL error: no such column: PoolByteArray

But I think it should be something like:

UPDATE users SET myblob=x'789c....' WHERE uid = 4026253021;

I can save blobs with db.insert_row(...) though. But updating blobs doesn't work.


As a side note, I also tried

db.query_with_bindings(
    "UPDATE users SET ?=? WHERE uid = ?;",
    ["myblob", PoolByteArray([1,2]), uid])

But in the log it says:

UPDATE users SET ?=? WHERE uid = ?;
SQL error: near "?": syntax error

So there seems to be another issue with query_with_bindings

@2shady4u
Copy link
Owner

The first issue is known and is a duplicate of #32
This will hopefully be fixed in the next update (whenever I have some free time 😱 )

Your side note is actually a lot more interesting as this is unexpected behaviour.... will test ASAP and get back to you

@2shady4u
Copy link
Owner

2shady4u commented Mar 17, 2021

image

So I tested it somewhat and get the same error.
When not putting a "?" in for the data-column everything works perfectly.

I'll have to check, but I actually think you can't bind columns in this way.
So you'll have to change your query to this:

db.query_with_bindings("UPDATE users SET myblob=? WHERE uid = ?;", [PoolByteArray([1,2]), uid])

or if you still want the "myblob" value to be variable:

db.query_with_bindings("UPDATE users SET " + "myblob" +"=? WHERE uid = ?;", [PoolByteArray([1,2]), uid])

I'll have to check if there's anything in the documentation about this...

@2shady4u
Copy link
Owner

After a little bit of searching I found this:
http://sqlite.1065341.n5.nabble.com/Binding-a-column-name-td1045.html

So it's a SQLite restriction that applies here and not an issue of the plugin itself! 😅

@mrimvo
Copy link
Author

mrimvo commented Mar 17, 2021

Thank you so much, I wasn't aware of this at all. Using query_with_bindings, I should be able to update blobs, which makes the original issue less urgent. Thank you for investigating on that.

@2shady4u
Copy link
Owner

Can I close this issue then? Since this is a duplicate from #32 and the secondary issue is due to an SQLite restriction and doesn't directly relate to the Godot-SQLite plugin itself?

@mrimvo
Copy link
Author

mrimvo commented Mar 19, 2021 via email

@2shady4u
Copy link
Owner

will do!

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

2 participants