-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
sqlite3 'row value misused' error when preloading a model with composite primary keys and foreign key relations #3585
Comments
This was 'just' a warning, but I recently updated my dependencies ( I narrowed it down to gorm v1.20.8; it remains a warning at v1.20.7, so it must have changed somewhere in these commits: v1.20.7...v1.20.8 |
It should not work before @fwielstra |
How is the progress on this issue? Will it be fixed or is it a no fix? |
I'm also seeing this with GORM versions // DELETE FROM `user_bios` WHERE (`user_bios`.`user_id`,`user_bios`.`mem_id`) IN (("[...]","[...]"))
type UserBio struct {
UserId string `gorm:"primarykey"`
MemId string `gorm:"primarykey"`
} For anyone looking for a workaround, check out db.Exec. |
I've encountered the same for SQLite. This actually breaks some of my test cases for structs having composite keys. |
Facing the same issue (using Preload) The generated SQL in my case is:
The problematic part is Quoting https://www.sqlite.org/rowvalue.html:
|
It seems like the only way to make it work for SQLite is to generate a SELECT subexpression using |
Can confirm. After updating gorm and the driver to latest, more tests are not running. |
Just in case anyone ends up here for the same reason I did, it seems that the use of |
Just wanted to bump this issue as the problem still seems to exist with the latest Gorm version |
I just wanted to use SQLite for unittest in CICD, but unfortunately, I encountered this error, so I had to continue to use MySQL 😢 |
Any updates on this problem? I still get the same problem with the latest Gorm version |
I've hit the same problem. Tried to find out if it could be easily remedied via the Dialector, but the code that builds this doesn't use it. I think it really deserves to be fixed, because I think the "IN with multiple columns" example on GORM's homepage cannot work in SQLite this way. |
GORM Playground Link
go-gorm/playground#168
Description
There is an issue when loading a model with composite primary keys from a sqlite3 database where the .Take() after a .Preload() will result in a sqlite3
row value misued
error.The following model (which is used in the playground link, too) can create the issue.
Basically when having a model composed of one root (ID=1) with two branches (b1 and b2) and a leaf on each branch the query to load the leaves in a preload is created as this:
From my understanding, the tuples in the IN clause cause the issue, as the used sqlite3 database does not seem to handle this.
The question is if the query could be build like the following, because this works with the used sqlite3 database, too.
or
I verified however, that the above query will work for a MariaDB, so I guess this issue is related to sqlite3 only.
The text was updated successfully, but these errors were encountered: