Skip to content
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

Crash when inductive tuple has non-nullable column after left join row #157

Open
alexmingoia opened this issue Nov 24, 2020 · 1 comment

Comments

@alexmingoia
Copy link
Contributor

alexmingoia commented Nov 24, 2020

If a query with a left join returns non-nullable columns after a left join row in the inductive tuple, a crash occurs.

This gist reproduces the crash.

This crashes with fromSql: text column with non-text value: SqlNull:

person <- select people
pet <- leftJoin (\p -> p ! #owner .== person ! #name) $ select pets
return (pet :*: person ! #name)

But this doesn't (inductive tuple order is flipped):

person <- select people
pet <- leftJoin (\p -> p ! #owner .== person ! #name) $ select pets
return (person ! #name :*: pet)
@kamoii
Copy link

kamoii commented Nov 24, 2020

I think I found the cause of this bug.

https://github.com/valderman/selda/blob/master/selda/src/Database/Selda/SqlRow.hs#L69

    then return Nothing

When the whole Row is null, it doesn't consume SqlValue's in the ResultReader state monad.
This code should be something like:

    then Nothing <$ R (put (drop (nestedCols (Proxy :: Proxy a)) xs))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants