valderman / selda

A type-safe, high-level SQL library for Haskell
https://selda.link
MIT License
478 stars 58 forks source link

Add distinction between int 64 and int 32. #150

Closed TomMD closed 3 years ago

TomMD commented 3 years ago

In mostly an answer to https://williamyaoh.com/posts/2019-12-14-typesafe-db-libraries.html and my own eventual needs, here is some firming up of Int32 and Int64 support.

TomMD commented 3 years ago

I took another pass, removing some of the cruft of the first version of this change.

Looking back at the critical blog post, things that are still unaddressed include:

it doesn’t even provide an instance for Integer

Yes, but I'm not clear on a good SQL type for integer. Even the decimal type has a limit of 16k decimal digits so the translation from Integer is going to be imperfect if we use that. I'm not sure what good options exist that won't break indexing.

Insertion/updates also feel like an afterthought, as Selda won’t even allow you to use SQL DEFAULT for columns other than autoincrementing primary keys.

Hurm, insert/update/lookup feels smooth for what is supported and like a library extension for what isn't. That' is unsurprising but won't be addressed by any one PR. Eventually perhaps we can get DELETE CASCADE and other sorts of behaviors, but perhaps I'm just startlingly uninterested in the example used in the blog.

TomMD commented 3 years ago

Ping @Valderman

valderman commented 3 years ago

Sorry for being slow on this; crunch time at work, so it's not been my top priority.

This seems like a good idea in general. I also agree that Integer support is very much a non-issue. I've yet to see a good case for supporting it, and portability concerns alone are enough for me to hold off on it indefinitely.