Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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: Filtering by ColumnTrait.eq(None) does not filter by NULL #267

Closed
Trivernis opened this issue Oct 22, 2021 · 1 comment
Closed

Bug: Filtering by ColumnTrait.eq(None) does not filter by NULL #267

Trivernis opened this issue Oct 22, 2021 · 1 comment

Comments

@Trivernis
Copy link
Contributor

Summary

When using the expression mytable::Column::MyColumn.eq(None) the resulting sql statement is ...column = ?. This expression filters by value and therefore does not filter for NULL since NULL is not a value in the sql syntax.

Expected Result

The resulting query should filter by IS NULL instead. This type of expression can currently only be constructed when using the sea_query expression builder.

System information

Database: Sqlite3
Crate Version: 0.2.4

@tyt2y3
Copy link
Member

tyt2y3 commented Oct 23, 2021

  • you should use is_null instead of eq None

Not sure why it was missing from ColumnTrait though, we will add it.

Meanwhile you can construct the expression yourself as in

use sea_query::Expr;

.filter(Expr::col(fruit::Column::CakeId).is_null())

@SeaQL SeaQL locked and limited conversation to collaborators Oct 23, 2021
@tyt2y3 tyt2y3 closed this as completed Oct 23, 2021
@SeaQL SeaQL unlocked this conversation Oct 23, 2021
billy1624 pushed a commit that referenced this issue Oct 27, 2021
arpancodes pushed a commit to arpancodes/sea-orm that referenced this issue Apr 8, 2022
* with-time

* fmt

* fix CI

* Revert CI changes

* Add `chrono` & `time` version of datetime `Value`

* cargo fmt

* Fixup

* Examples with `time` crate

* Fixup

Co-authored-by: Bastian Schubert <[email protected]>

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants