Hi all,
I generate webpages in which end-users can input data that is stored in a database via sqla.The datamodel is not pre-defined but created by (other) users/designers.
My question is how can i best let the end-user know which field contains the error if the end-user violates a unique constraint; e.g. if the user creates an account by filling in a username/password, the username must be unique so the user must get an error ("username already exists" oss) if he tries to fill in an existing username.
If i commit the data, the exception thrown is somewhat cryptic (is the message created by sqla or the database?).
Some related questions:
- are there arguments in the exception i could use?
- should i just query the table for the existence of the unique constrained value (i seem to remember that is impossible in the "validate" solution, so how else)?
I might be able to come up with some sort of solution, but i am looking for a good/the best (structurally sound, not too slow, not overly complex) solution, also useable for other constraints (e.g. non-null, maybe other query/multi-record based constraints).
Cheers, Lars