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

`#[belongs_to]` doesn't allow for nullable foreign keys #116

Closed
sgrif opened this Issue Jan 20, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@sgrif
Member

sgrif commented Jan 20, 2016

This is because we can't have an Eq<Integer, Nullable<Integer>>. We should absolutely allow nullable foreign keys though. Unsure how we want to go about this one.

@sgrif sgrif added this to the 0.5 milestone Jan 20, 2016

sgrif added a commit that referenced this issue Jan 20, 2016

Add `Expression#nullable` to allow comparing null and not null exprs
We currently don't allow a comparison like `Eq<Integer,
Nullable<Integer>>`. This is somewhat by design, but the goal was to
force you to explicitly declare that you want to do this, not to make it
impossible to do entirely. The `nullable` method will take a potentially
nullable expression, and ensure it is of a `nullable` type. Calling it
on an already `nullable` expression will not change the `SqlType`
(though it will end up wrapping it in our `Nullable` expression struct).
The resulting expression will have the same SQL as the original.

Our private API associations have also been updated to use this new
method, to allow for cases where there are optional foreign keys.

Fixes #116

sgrif added a commit that referenced this issue Jan 20, 2016

Add `Expression#nullable` to allow comparing null and not null exprs
We currently don't allow a comparison like `Eq<Integer,
Nullable<Integer>>`. This is somewhat by design, but the goal was to
force you to explicitly declare that you want to do this, not to make it
impossible to do entirely. The `nullable` method will take a potentially
nullable expression, and ensure it is of a `nullable` type. Calling it
on an already `nullable` expression will not change the `SqlType`
(though it will end up wrapping it in our `Nullable` expression struct).
The resulting expression will have the same SQL as the original.

Our private API associations have also been updated to use this new
method, to allow for cases where there are optional foreign keys.

Fixes #116

@sgrif sgrif closed this in #117 Jan 20, 2016

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