[Dbix-class] DBIx::Class, another data validation approach

Alexander Hartmaier alexander.hartmaier at t-systems.at
Wed Jul 29 08:15:50 GMT 2009


Am Dienstag, den 28.07.2009, 16:20 +0200 schrieb Moritz Onken:
> Am 28.07.2009 um 10:59 schrieb Alexander Hartmaier:
>
> > Am Dienstag, den 28.07.2009, 00:29 +0200 schrieb Rob Kinyon:
> >> On Thu, Jul 23, 2009 at 08:28, Alexander
> >> Hartmaier<alexander.hartmaier at t-systems.at> wrote:
> >>> The DBMS validates data types, length, undef and foreign keys
> >>> anyway, so
> >>> maybe using it as validator (parse its error messages) is a
> >>> possibility?
> >>
> >> The problem is that many DBMSes do -NOT- validate things sanely -
> >> SQLite and MySQL being the biggest offenders, though every DBMS has
> >> its problems. Oracle, for example, in 9.2.0.3 had an issue where
> >> certain invalid datetime entries were accepted. Furthermore, part of
> >> the benefit of an ORM is that it is DBMS-independent - I want to know
> >> that the same value restrictions are going to be maintained
> >> regardless
> >> of backend.
> >>
> >> And, finally, the biggest win for validation is things that DBMSes
> >> cannot do. For example, a SMALLINT that, for business reasons, has to
> >> be within 20 of another column. How do you express that constraint in
> >> a DBMS-independent fashion?
> >>
> >> I, for one, cannot wait for our new Moose overlords!
> >>
> >> Rob
> > I didn't mean that we don't need business logic or extended
> > validation,
> > but use the basic validation the db does anyway instead of cloning it
> > which could lead to different checks and a performance penalty (i
> > had to
> > disable validation for an app that inserts lots of data because it
> > wasn't fast enough).
>
> I'm not sure whether the performance argument applies here because you
> need a roundtrip to the database. This takes time, especially if the
> database server is not located on the same machine as the app server.
>
> moritz
You'd do the sql query (insert or update) like now, but use the error
message (if any) as validation result.

--
BR Alex


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the DBIx-Class mailing list