Thilosophy has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I started writing some tests using DBD::Mock, but have hit a problem right at the beginning. My module asks the DBI handle for the database product name using get_info(17) (see the excerpt from the DBI docs below) because it needs to dispatch among different SQL dialects. Unfortunately, DBD::Mock returns nothing.

Can DBD::Mock be made to say what I want for any of the driver info properties? Looking at the docs (and the source) I could not figure out how. And I think it should also say something like "DBD::Mock v0.xy" by default.

From the DBI docs: Because some DBI methods make use of get_info(), drivers are strongly encouraged to support at least the following very minimal set of information types to ensure the DBI itself works properly:

 Type  Name                        Example A     Example B
 ----  --------------------------  ------------  ----------------
   17  SQL_DBMS_NAME               'ACCESS'      'Oracle'
   18  SQL_DBMS_VER                '03.50.0000'  '08.01.0721 ...'
   29  SQL_IDENTIFIER_QUOTE_CHAR   '`'           '"'
   41  SQL_CATALOG_NAME_SEPARATOR  '.'           '@'
  114  SQL_CATALOG_LOCATION        1             2

Replies are listed 'Best First'.
Re: Can DBD::Mock mock get_info() ?
by dragonchild (Archbishop) on Apr 08, 2005 at 01:50 UTC
    You're looking at it wrong. In your tests, you should have DBD::Mock return whatever you want in order to test a given SQL dialect.

    That said, I'll give stvn a patch tonight to add set_info() and get_info() methods that will let you do that.

      I'll give stvn a patch tonight to add set_info() and get_info() methods

      ++. Thanks, that would be great. I also need bind_param_inout (not supported right now), but I will probably write that myself.

        Huh. Didn't think of that one. If you want, send either me or stvn the patch and we'll get it into the next release.

        What kind of interface are you thinking of for bind_param_inout()?