[Dbix-class] DBIx::Class, another data validation approach
Rob Kinyon
rob.kinyon at gmail.com
Tue Jul 28 12:19:18 GMT 2009
On Tue, Jul 28, 2009 at 04:59, Alexander
Hartmaier<alexander.hartmaier at t-systems.at> wrote:
> 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.
>>
> 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).
>
> If a specific db (version) is buggy we can warn the user and suggest an
> upgrade.
You're not understanding me. SQLite doesn't have ANY validations at
all. MySQL's "validations" consist of "What's the closest legal value
that I can use?". For those DBMSes (which are both heavily used), what
should we do?
Different DBMSes already do different checks. If the ORM provides the
ability to do a set of checks, that becomes the common thread in my
validations across all DBMSes that I might point my app against.
Yes, there can be a performance penalty if this isn't done right.
Performance can be optimized after correctness is achieved.
And, no, suggesting an upgrade of a DBMS is never an answer. We might
detect a buggy version out of courtesy, but saying "Upgrade your DBMS
in order to get functionality I should be providing you anyways" is
ridiculous.
Rob
More information about the DBIx-Class
mailing list