nikita-volkov / hasql

The fastest PostgreSQL libpq-based driver for Haskell
http://hackage.haskell.org/package/hasql
MIT License
517 stars 54 forks source link

Does Row have to read every column? (documentation issue) #153

Closed chris-martin closed 4 months ago

chris-martin commented 1 year ago

When defining a Hasql.Decoders.Row, is it mandatory for the row decoder to read every column in every row, or is row decoding allowed to halt early? For example, suppose the first column in the selected table is a Bool which, if False, means that we don't care about the rest of the row.

column (nonNullable bool) >>= \case
    False -> pure Nothing
    True -> _ -- Decode additional columns

Is this sort of row decoder okay, or is there some potential problem that may arise?

nikita-volkov commented 1 year ago

I don't think there should be issues. Have you tried this?

chris-martin commented 1 year ago

I haven't tried it, no. I don't have any particular reason to believe that it would be a problem, I just don't know how the underlying mechanism works, so it seemed vaguely reasonable that consumption of the entire row might have been an assumption the library has. About to yolo some stuff into production so I thought I'd just try asking for some reassurance :upside_down_face: