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

Bug: DuckDB binds BLOBs as TEXT when inserting data into SQLite #97

Closed
2 tasks done
asg017 opened this issue May 25, 2024 · 1 comment
Closed
2 tasks done

Bug: DuckDB binds BLOBs as TEXT when inserting data into SQLite #97

asg017 opened this issue May 25, 2024 · 1 comment

Comments

@asg017
Copy link
Contributor

asg017 commented May 25, 2024

What happens?

When you attach a SQLite database from DuckDB, and you try to insert BLOBs into a SQLite table, the values get bound as TEXT instead of BLOBs.

To Reproduce

import duckdb

db = duckdb.connect(":memory:")
db.execute("load sqlite;")
db.execute("attach 'tmp.db' as target (type sqlite);")
db.execute("create table target.x(a blob);")
db.execute("insert into target.x(a) select encode('my_string_with_ü')");
db.close()

import sqlite3
db = sqlite3.connect("tmp.db")
print(db.execute("select typeof(a) from x").fetchone()[0])

The final line prints text, which means a was bound as TEXT and not a BLOB.

I believe this is because of this code, where SQLiteStatement::BindValue binds BLOBs with BindText, and a new BindBlob option could be added. https://github.com/duckdb/sqlite_scanner/blob/50b7870be099186f195bc72bac5e9e11247ee2f9/src/sqlite_stmt.cpp#L154-L157

OS:

MacOS aarch64

SQLite Version:

3.44.2

DuckDB Version:

0.10.3

DuckDB Client:

Python

Full Name:

Alex Garcia

Affiliation:

self

Have you tried this on the latest main branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree
@Mytherin
Copy link
Contributor

Mytherin commented Sep 4, 2024

Fixed in #98

@Mytherin Mytherin closed this as completed Sep 4, 2024
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