Skip to content

Porting code with Nullable<> to 2.0.0 #2766

Answered by weiznich
ensc asked this question in Q&A
Discussion options

You must be logged in to vote

We changed our type tracking to be more in line with what database actually do. NULL OR some_expr evaluates to NULL, therefore we made sure that boolean expressions propagate nullability based on the arguments.
In consequence that means as soon as at least on of your arguments may be nullable diesel requires that the output can be nullable. Due to type inference issues this can require a third type parameter to diesel::dsl::Or, as outlined in the documentation, to specify if that expression is Nullable or not.

use diesel::dsl::{Or, Eq, AsExprOf};
use diesel::sql_types::{ Bool, Text, Nullable };
use diesel::{IntoSql, ExpressionMethods};

type FiBound<ST> = AsExprOf<&'static str, ST>;
type B…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ensc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants