On Fri, Jun 10, 2016 at 1:47 PM, Steve Atkins <steve@blighty.com> wrote:
You could name the check constraints, catch the errors and use a client-side mapping between constraint name and a friendly error message for display in the web interface.
This seems plausible, but not ideal. I could get over the aesthetics of sequence gaps, but don't like throwing lots of database errors on principle, and also for silting up my logs. Seems better to catch these before submitting.
I'm aiming as much as possible for this to "just work" with standard Postgres, and this approach gets away from that. Plus people would have to know SQL AND PHP in order to create tables.
You could look at one of the existing SQL parsers implemented in PHP, and use those to parse the constraint to a tree from which you could easily pull PHP.
This one sounds most promising! I took a quick Google, and it looks like there are lots of them, and a heavy Mysql focus. Anyone have experience or suggestions about which of these might be best, and particularly for Postgres?