Recent

Author Topic: Enforcing constraints  (Read 1853 times)

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Enforcing constraints
« on: April 21, 2015, 06:55:27 pm »
The fact that TField's CustomConstraint and ConstraintErrorMessage are not yet implemented, makes dealing with missing values that much more cumbersome.

The default message that is generated, while technically correct, is designed to scare the crap out of people running the program with its additional warning: 'Press OK to ignore and risk data corruption. Press Cancel to kill the program.".

My question is: How do you guys handle NOT NULL constraints in your programs?

I am currently using the CaptureExceptions property and the OnException handler from TApplicationProperties to centrally handle these, but am wondering if there are better ways...

PS: Using the SqlDB framework
« Last Edit: April 21, 2015, 07:12:32 pm by kpeters58 »
Lazarus 2.0.4/FPC 3.0.4/Win 64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Enforcing constraints
« Reply #1 on: April 21, 2015, 07:17:30 pm »
have you seen the events of the query? especially the onupdateerror, onediterror, and onPostError?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Re: Enforcing constraints
« Reply #2 on: April 21, 2015, 07:57:43 pm »
Probably the first method I tried out - I am a big believer in simple, clear & techo-speak free error messages for the users of my programs.

Thus I'd have to parse the component names out because they should not be visible as they provide no value at all to end users - they are confusing at best.

The moment I do that, I make my programs vulnerable to framework changes because my parsing might fail should someone alter the format of the database exceptions - I'd much rather have working CustomConstraints or something else....
Lazarus 2.0.4/FPC 3.0.4/Win 64

 

TinyPortal © 2005-2018