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

Wrong blob data returned in select statement #34762

Open
torfluor opened this issue Sep 26, 2024 · 0 comments
Open

Wrong blob data returned in select statement #34762

torfluor opened this issue Sep 26, 2024 · 0 comments

Comments

@torfluor
Copy link

In our .NET MAUI application we have seen a strange bug where it shows wrong thumbnail images for imported files. The thumbnails are stored as blobs in our SQLite database, and after investigating this it looks like the bug is in the Microsoft.Data.Sqlite package.
I will try to explain the issue in writing here, but I have also created a console program that demonstrates the issue. The code is available here: https://github.com/torfluor/Microsoft-SQLite-blob-bug

Issue description

We have two tables, CaseFactModel and CaseFileModel, which have a many to many relationship and are connected with a link table CaseFactModel_CaseFileModel.

CaseFactModel contains a blob called ImageData, and CaseFileModel contains a blob called ThumbnailData.

Using the following select statement we select rows from the link table and joins in CaseFactModel and CaseFileModel:

SELECT fact.Id, fact.ImageData, file.ThumbnailData 
FROM CaseFactModel_CaseFileModel link 
LEFT JOIN CaseFactModel fact ON link.CaseFactModelId = fact.Id 
LEFT JOIN CaseFileModel file ON link.CaseFileModelId = file.id

In the resulting rows all the ThumbnailData blobs contain the data of the ThumbnailData of row one instead of the actual blob data of the row!

When we run the same select statement in DB Browser for SQLite we get the expected result.

Version information

Microsoft.Data.Sqlite version: 8.0.8
Target framework: .NET 8.0
Operating system: Windows 11 Pro 23H2, (but the bug was originally reported to us on iOS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants