Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Automated testing of database classes

by MrCromeDome (Deacon)
on Dec 27, 2004 at 21:56 UTC ( #417645=note: print w/replies, xml ) Need Help??


in reply to Re: Automated testing of database classes
in thread Automated testing of database classes

The tranasction savepoints sound interesting . While never having investigated them, I'm imagining that SQL Server (the DBMS I'm stuck with) must have some similar functionality. My original suite of tests was very brute force - add rows that I need for my tests, run the tests, manually delete those rows. On the plus side, I at least verified that the delete functionality in Class::DBI worked as intended ;)

Up to this point, I've always verified my database tests using Class::DBI, but I think I like using yet another tool to verify my test data. Looks like Test::DatabaseRow will fit that bill nicely. Thanks for the recommendation!

MrCromeDome
  • Comment on Re^2: Automated testing of database classes

Replies are listed 'Best First'.
Re^3: Automated testing of database classes
by jplindstrom (Monsignor) on Dec 27, 2004 at 23:07 UTC
    I can imagine that Sybase and MS SQL Server have identical transaction semantics.

    This only works if you can do it consistently, but here is how to nest transactions and limit the rollback scope so that it matches that of e.g. a procedure:

    begin tran save tran the_procedure_name --modify stuff if ... error ... begin rollback tran the_procedure_name commit tran return 1 end --success commit tran return 0

    You start with beginning a transaction and immediately saving the transaction to a named savepoint. I've asked around and this doesn't seem to incur very much overhead.

    If everything works okay, just commit once to end the outermost transaction.

    If anything goes wrong, first rollback to the named savepoint, then commit the transaction (to make sure it's nested properly).

    /J

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417645]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2021-03-04 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (108 votes). Check out past polls.

    Notices?