[Dbix-class] Patch for SQL::Translator::Parser::DBIx::Class

Sebastian Willert willert at gmail.com
Sun Jun 25 22:05:11 CEST 2006


On Sun, 2006-06-25 at 20:39 +0100, Matt S Trout wrote:
> Sebastian Willert wrote:
> > Hi all,
> > 
> > after some late-night discussion with castaway about
> > DBIC::Schema->deploy() we noticed that
> > SQL::Translator::Parser::DBIx::Class tries to query the connected
> > database. This shouldn't be done IMO because this might change the info
> > provided in the schema and might not be stable between different
> > underlying RDBMs. 
> > 
> > This are the reasons why I've produced the patch below, the changes
> > should be self-explainatory. The patch has been tested on the
> > command-line, using the programmatic interface of SQLT and using
> > DBIC::Schema->deploy() but could need some additional testing with more
> > complex schema then I have readily available.
> 
> The changes are clearly harmful. A schema class simply acts as a prototype for 
>   objects of that class, it is not guaranteed to contain all the requisite data.

That depends on the intention of SQLT::Parser::DBIC, i think. If the
intention is to dump a running schema instance, then you are perfectly
correct. But if the intention is to build databases according to the
hard-coded info (i.e. the prototype) in the schema then relying on
run-time info gathered from a database is harmful IMO.

I was basically interested in automatic test database creation for RDBMs
agnostic apps and in this setting it is sensible to not rely on any info
gathered from a specific DB, so I naively assumed the second intention.

If I was wrong, I'll happily retract my patch, though.

Cheers,
  Sebastian




More information about the Dbix-class mailing list