3

I have a postgresql table with a bunch of columns, it's around 20-30 columns. Posgresql Simple supports only up 10 variables in a tuple https://hackage.haskell.org/package/postgresql-simple-0.5.0.0/candidate/docs/Database-PostgreSQL-Simple-ToRow.html#v:toRow

It's not enough for me. How can I fix that? I can't use the original "data" I have. If I use it for insertion then the "id" and other fields generated by Postgresql will be passed from a client and it'll cause an exception.

Creating a new "data" and then implementing FromJson and possibly other intances might be overkill. Then is there any other solution?

Judi
  • 147
  • 2
  • 7
  • 1
    You should be able to make your own instance of FromRow that can compose either a tuple of the size you need, or some other data type that you can use. – dvaergiller Apr 07 '16 at 12:30
  • 1
    and as a 30-tuple would be horrible (the constraints for the instance alone would be insane) I would suggest writing a simple `data` structure and to make it into `FromRow` - just copy&past/adapt from [here](https://hackage.haskell.org/package/postgresql-simple-0.5.0.0/candidate/docs/src/Database-PostgreSQL-Simple-ToRow.html#toRow) – Random Dev Apr 07 '16 at 13:46

1 Answers1

2

Just use (:.) operator to combine several tuples into one row. There are instances defined for both FromRow and ToRow

Ed'ka
  • 6,595
  • 29
  • 30