-
Notifications
You must be signed in to change notification settings - Fork 55
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
Eager loading causes DataTypeCasting exception on sqlite #403
Comments
Hi, sorry for a delay. Does it mean that in all other cases everything is fine when you load your models separately? sqlite adapter master branch is behind current jennifer master branch. Recently we introduced a breaking change - automatic primary keys are of Int64 type. |
Loading the models separately works fine. Only eager loading causes problems. I would say that my problem is related to this breaking change. |
Will try to reproduce and fix on this weekend |
Also could you please share minified mapping for your |
class User < Jennifer::Model::Base
mapping(
id: Primary32,
email: String?,
)
has_many :memberships, TeamMember
end
class TeamMember < Jennifer::Model::Base
mapping(
id: Primary32,
user_id: Int32,
team_id: Int32,
role: Int32,
)
belongs_to :team, Team
belongs_to :user, User
end
class Team < Jennifer::Model::Base
mapping(
id: Primary32,
name: String,
)
has_many :members, TeamMember
end
|
Any updates on this issue? |
I couldn't reproduce it with postgres. Maybe it's an issue with sqlite adapter. Here's my test with postgres: cyangle@566fec0 |
Was on a vacation so it look longer to respond 🌴 Hm, I though I had done something with this but don't remember what and why I left this without a response. Will take a look in the evening today |
I was able to reproduce it. Sorry, I don't remember why I skipped this 😞 . Will find a way to fix this behavior |
The error still persists on latest releases
Models:
Error: |
Calling
eager_load
with sqlite always produces aDataTypeCasting
Column <Model>.id can't be casted from Int64 to it's type - (Int32 | Nil)
.I'm using a simple model with
User
,Team
andMember
and the following code is causing the exceptionThis can be fixed by adding the following code in
mapping.cr
at line 438I'm not sure if this would be the right place for this kind of fix.
I'm using
The text was updated successfully, but these errors were encountered: