|
Posted by Joseph Brenner on April 4, 2005, 12:33 pm
Please log in for more thread options
I've written a module that I'm getting set to upload to CPAN,
but I'd like to write some decent tests for it first.
The module is probably going to be called "GraphViz::DBI::General" [1].
What the module does is let you automatically generate a graph of
table relationships given a DBI database handle. This poses a
few problems for testing, one of which is that the data to be
plotted is table relationships, not something simple like the
contents of a table. MockDBI and SQLite are probably out of the
question.
But what's the alternative? Check for the availability of a real
database (somehow), check that I've got the permissions to do
things like "CREATE DATABASE" (somehow), and do a full blown run?
Any suggestions?
[1] My "GraphViz::DBI::General" is a subclass of the existing
"GraphViz::DBI" which is intended to work with a wider range of
databases. In particular Postgresql, for which "GraphViz::DBI" is
pretty useless (it has no concept of schemas). Also the original
module relies on a naming convention to find foreign keys, and I
prefer the DBI method "foreign_key_info" (even if it is labeled
"experimental").
|
|
Posted by Ron Savage on April 5, 2005, 9:25 pm
Please log in for more thread options
On Tue, 5 Apr 2005 04:33:33 +1000, Joseph Brenner wrote:
Hi Joseph
> [1] My "GraphViz::DBI::General" is a subclass of the existing
> "GraphViz::DBI" which is intended to work with a wider range of
> databases. In particular Postgresql, for which "GraphViz::DBI" is
> pretty useless (it has no concept of schemas). Also the original
> module relies on a naming convention to find foreign keys, and I
> prefer the DBI method "foreign_key_info" (even if it is labeled
> "experimental").
Is this of any relevance:
http://savage.net.au/Ron/html/graphing-database-schema.html
|
|
Posted by Joseph Brenner on April 5, 2005, 6:23 pm
Please log in for more thread options
> Joseph Brenner wrote:
>> [1] My "GraphViz::DBI::General" is a subclass of the existing
>> "GraphViz::DBI" which is intended to work with a wider range of
>> databases. In particular Postgresql, for which "GraphViz::DBI" is
>> pretty useless (it has no concept of schemas). Also the original
>> module relies on a naming convention to find foreign keys, and I
>> prefer the DBI method "foreign_key_info" (even if it is labeled
>> "experimental").
>
> Is this of any relevance:
http://savage.net.au/Ron/html/graphing-database-schema.html
Well, it's not *irrelevant*, but I see that you're take on the
problem just uses a *different* naming convention for foreign
keys:
The default implementation of GraphViz::DBI assumes that for a
column called t_id, then it is a foreign key if t is the name
of a table. This does not match my convention, so I wrote a
replacement for the sub, which uses my own table and column
naming convention to determine if a column is in fact a
foreign key. That convention is documented elsewhere. See
below for the link.
My take is that now that there's a DBI method that you can use to
get info about foreign keys, it's better to use that so the code
will work with any naming convention. And won't break if you
decide to deviate from the naming convention...
For example, I like the convention of using the table name as
the foreign key name (so my WHERE clauses look like
"person = person.id"). But what if I decide to create a
"freinds" table, that links together records in my person
table in pairs?
CREATE TABLE friends (
id SERIAL PRIMARY KEY,
person_1 REFERENCES person(id),
person_2 REFERENCES person(id)
);
Then I can't rigorously stick to the naming convention. I think
that's probably the case for most such naming conventions.
|
| Similar Threads | Posted | | Testing stdout output modules | December 28, 2006, 11:26 am |
| ANNOUNCE: Code::Dumper - a ::Dumper for code. Available on CPAN | November 21, 2005, 11:03 am |
| Modules/code for comparing version numbers? | September 15, 2004, 1:55 pm |
| New module for testing | January 5, 2007, 1:17 pm |
| Testing RPC::XML goes awry -- Newbie alert | November 24, 2004, 8:39 am |
| download all CPAN modules ? | August 25, 2004, 10:35 pm |
| To publish on CPAN or not? And architectural q. on modules. | November 29, 2007, 12:56 pm |
| How to find all modules, required by a given CPAN module | September 4, 2005, 2:25 am |
| querying modules dependency tree on CPAN | November 19, 2004, 1:54 am |
| General question on CPAN perl modules | March 13, 2005, 6:34 pm |
|