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:[email protected]] 
> Gesendet: Donnerstag, 2. Juli 2009 16:29
> An: [email protected]
> 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
> 

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to