AW: [Dbix-class] Re: "Dry-run" for SQL ?
Robert Heinzmann
Robert.Heinzmann at 1und1.de
Thu Jul 2 14:35:00 GMT 2009
Hello Adam,
thanks for the Tip !
This works great. I get "Real World Testing" and all application logic works.
With DBD::Mock I have to make "syntetic tests" for all parts of the code that depends on previous inserts or on select results.
DBIC_TRACE is great :)
Regards,
Robert
> -----Ursprüngliche Nachricht-----
> Von: Adam Sjøgren [mailto:adsj at novozymes.com]
> Gesendet: Donnerstag, 2. Juli 2009 16:29
> An: dbix-class at lists.scsys.co.uk
> Betreff: [Dbix-class] Re: "Dry-run" for SQL ?
>
> On Tue, 30 Jun 2009 18:35:29 +0200, Robert wrote:
>
> > Is it possible to have a "dry run" mode in DBIx-Class ?
>
> > I just want to see the SQL Statements DBIx would execute,
> but not want
> > DBIx to execute them.
>
> > This way I can verify the statements before executing.
>
> I simply wrap the statements in a transaction and then roll
> it back at the end.
>
> Running the code with DBIC_TRACE=1 allows me to see the SQL
> executed, and the database isn't changed.
>
> I usually do something like this:
>
> my $transaction=sub {
> # Manipulate database...
> die "dry run";
> };
> $schema->txn_do($transaction);
>
> Remembering to put the die in there is of course important :-)
>
>
> Best regards,
>
> Adam
>
More information about the DBIx-Class
mailing list