Skip to content

Nullable arguments in .drift file queries #2493

Answered by simolus3
frankvollebregt asked this question in Q&A
Discussion options

You must be logged in to vote

In cases where type inference fails, you can also declare the types of variables explicitly:

getPersons(:lastName AS TEXT OR NULL): SELECT * FROM persons
WHERE first_name = :firstName AND (:lastName IS NULL OR last_name = :lastName);

But I'm surprised that drift generates non-nullable parameters here since both columns are nullable to begin with. I couldn't reproduce this, are you on a recent drift version?

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@frankvollebregt
Comment options

@simolus3
Comment options

Answer selected by frankvollebregt
Comment options

You must be logged in to vote
2 replies
@simolus3
Comment options

@FantasyCheese
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants