haskell-beam / haskell-beam/beam

Maybe_ generate wrong (non intuitive) sql query

Open
#524 2 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
Haskell
Stars
635
Forks
193
PR merge metrics
No merged PRs in 30d

Description

I have left and right table, where right table contains nullable fields \
I join them with `leftJoin_` and try to create `filter_` which has such condition:
```haskell
maybe_ nothing_ nullableFieldFromRightTable rt /=. just_ (val_ 1)
```

So, if `rt` is null just return `nothing` and if `rt` is not null return `nullableFieldFromRightTable` which will return `nothing` or `just value` \
I am using it as beam doen't support to check nested maybes\
Then I just check if it is different from `just 1`\
This code compiles but I get invalid result, so, here is why:

```sql
CASE
WHEN ((((("t1"."someField1") IS NOT NULL) AND (("t1"."someField2") IS NOT NULL)) AND
(("t1"."nullableFieldFromRightTable") IS NOT NULL)) AND IS NOT NULL)
THEN "t1"."nullableFieldFromRightTable"
ELSE null END) IS DISTINCT FROM 1)
```
Beam generates strange query which doesn't the meaning of the beam query

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.