NAME

SQL::Abstract::Limit::Test - Helper package for testing generated SQL and bind values

SYNOPSIS

use Test::More;
use SQL::Abstract::Limit::Test;

my ($sql, @bind) = $schema->storage->sql_maker->select(%args);
is_same_sql_bind(
  $sql, \@bind, 
  $expected_sql, \@expected_bind,
  'foo bar works'
);

DESCRIPTION

Exports functions that can be used to compare generated SQL and bind values.

If SQL::Abstract::Test (packaged in SQL::Abstract versions 1.50 and above) is available, then it is used to perform the comparisons (all functions are delegated to id). Otherwise uses simple string comparison for the SQL statements and simple Data::Dumper-like recursive stringification for comparison of bind values.

FUNCTIONS

is_same_sql_bind

is_same_sql_bind(
  $given_sql, \@given_bind, 
  $expected_sql, \@expected_bind,
  $test_msg
);

Compares given and expected pairs of ($sql, \@bind), and calls "ok" in Test::Builder on the result, with $test_msg as message.

eq_sql

my $is_same = eq_sql($given_sql, $expected_sql);

Compares the two SQL statements. Returns true IFF they are equivalent.

eq_bind

my $is_same = eq_sql(\@given_bind, \@expected_bind);

Compares two lists of bind values. Returns true IFF their values are the same.

SEE ALSO

SQL::Abstract::Test, Test::More, Test::Builder.

AUTHOR

Norbert Buchmuller, <norbi@nix.hu>

COPYRIGHT AND LICENSE

Copyright 2008 by Norbert Buchmuller.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.