Re: DRY for ActiveRecord w/PostgreSQL : defaults and validations

Lugovoi Nikolai
Mon, 19 Sep 2005 09:39:00 -0000

Kev Jackson wrote:
>> In PostgreSQL practically full information about schema, intertable
>> relationships and constraints can be extracted and injected to Rails
app.
>
> What about other RDBMSs that rails supports?
>

Well, I don''t have much experience with other SQL DBMS, but SQL
standard
includes "information schema", so it can be possible with other DBMS
also, if the feature is properly supported.

>
> I agree with the DRY principle, but I''m thinking that if you do a
query
> to check the constraints for every insert, then you''ll be bogging
the
> database down with two calls for every insert instead of 1 call.  Just
> something to consider.  Although the fact that the schema does define
> the constraints should mean that the developer shouldn''t have to
repeat
> these in the model code.
>
> Kev

As for me it''s better to make one more constraint check query to
database than handling weird exception messages (or even exposing them
to end users).
Though, if one doesn''t care neither about data integrity(primary
reason)
nor friendly UI(keep users with this software), validations aren''t
necessary at all and can be avoided :)

WBR, Lugovoi Nikolai