Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: DBD::Mock and DBD-specific attributes

by dragonchild (Archbishop)
on Aug 16, 2004 at 20:04 UTC ( #383432=note: print w/replies, xml ) Need Help??


in reply to Re^3: DBD::Mock and DBD-specific attributes
in thread DBD::Mock and DBD-specific attributes

Other replies in this thread seem to indicate that lowercase attributes will not be handled unless they have the correct prefix. So, what about adding a check in the two STORE/FETCH subs in DBD::Mock to say "If I don't know about this attribute, but it is in lowercase, I'll store/fetch it for you."?

I went ahead and added this code to my copy and it passed my tests, though you'll probably want to design it a little better than my hackish solution. Specifically, doing a reset on the $dbh should probably delete all the added-on attributes. Plus, I would still like to see a way of mocking a given DBD.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re^4: DBD::Mock and DBD-specific attributes

Replies are listed 'Best First'.
Re^5: DBD::Mock and DBD-specific attributes
by stvn (Monsignor) on Aug 17, 2004 at 01:09 UTC
    Specifically, doing a reset on the $dbh should probably delete all the added-on attributes.

    What do you mean by a 'reset'? Are you refering to the 'mock_clear_history' attribute?

    Plus, I would still like to see a way of mocking a given DBD.

    Well one of the things I know lachoy was trying to do was to keep DBD::Mock in a single file, so that it would be easy for other authors to include in their modules (and not have as an external dependency). So I would be hesitatant to start going to crazy with DBD::Mock::MySQL, DBD::Mock::Oracle, etc. if I can avoid it. However, that said, my experience with anything other than DBD::mysql and DBD::Pg is limited so I am not aware of how different other DBD's can be. If you have any suggestions/insight into this I would love to hear it.

    -stvn
Re^5: DBD::Mock and DBD-specific attributes
by lachoy (Parson) on Aug 17, 2004 at 02:12 UTC

    What might be useful is if you passed information via connect() to tell DBD::Mock what type of database handle it should emulate, like:

    my $dbh = DBI->connect( 'DBI:Mock:mysql', ... ); my $dbh = DBI->connect( 'DBI:Mock:Pg', ... );

    It probably wouldn't be hard to collect a list of valid attributes for each driver and store/return only these, throwing an exception on all others. That's something anyone can do, not just the driver author...

    But it's all in stvn's hands now :-)

    Chris
    M-x auto-bs-mode

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-05-21 12:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?