But when you violate multiple constraints, PostgreSQL only tells you about them one at a time. This means that a user would have to fill out a form, submit, fix an error, resubmit, fix another error⦠etc. To avoid this, we have to check things like NOT NULL with validations in addition to the underlying database constraint.
If PostgreSQL could tell us all the violated constraints at once, that would simplify things, wouldnβt it?
itβs not clear to me if using PQresultErrorField with PG_DIAG_CONSTRAINT_NAME would return all violated constraints or just the first one, like I see in psql
I know beans about programming C, so I donβt know how to test this. I donβt really even know whether or where libpq figures into the Ecto stack.
My understanding is that we have something like this:
βββββββββββββββββββββ
β Ecto β
βββββββββββββββββββββ
β
β uses
βΌ
βββββββββββββββββββββ
β Postgrex β
βββββββββββββββββββββ
β connects on
β port 5432 (or other)
βΌ
βββββββββββββββββββββ
β PostgreSQL Server β
βββββββββββββββββββββ
Is libpq involved here somewhere? If so, is there any way to try to get it to query this information?
@ericmj Iβd love to help us make use of this, but I need to get a clue about the stack first.
libpq and postgrex follow the same constraints since they speak the same protocol, the only difference is that libpq uses text serialisition and postgrex uses the binary format, but that should not matter in this case.
Unfortunately I donβt think the issue you linked solves what you want. Ecto already uses the feature in the issue to link errors with changeset validations. The issue doesnβt seem to have a solution for multiple errors reported from Postgres.