Hi all,

I'm not proposing to write a Test::SQL module, but I am tired of having
the following two things not being equivalent:

    CREATE TABLE foo (
      id INTEGER NOT NULL PRIMARY KEY,
      name VARCHAR(32) NOT NULL,
      title
      age INTEGER
    );

And:

    create table foo (
      id INTEGER       NOT NULL PRIMARY KEY,
      name VARCHAR(32) NOT NULL,
      age integer
    );

Those are functionally equivalent but there are a few potential
problems with testing it. I can get a reasonably easy to debug test if
I do the following:

    * Collapse all unquoted whitespace to a single space.
    * Preserve newlines (so that Test::Differences will still be
meaningful)
    * Lower-case all unquoted characters.

I can use Data::Record to easily split the string on spaces without
affecting quoted characters:

    use Regexp::Common;
    use Data::Record;
    my $record = Data::Record->new({
        split  => qr/\s\t/,
        unless => $RE{quoted},
    });
    my $data = join ' ', map { lc $_ } $record->records($data);

That doesn't seem flexible enough, though. It would be useful to wrap
this in a test module whereby one can control whether or not one wants
to alter the case, ignore quoted data, preseve newlines, and so on. I
could make a plethora of test functions, but the number of possible
combinations would make them unweildy. I could have the user set the
parameters at the top of the test and change the parameters as needed.
This would make this far more flexible than simply an SQL tester.
Thoughts?

I'm thinking a name like Test::ControlWhitespace.

Also posted to http://use.perl.org/~Ovid/journal/28819

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send 
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

Reply via email to