[Dbix-class] t/92storage_on_connect_do.t

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Thu Oct 9 11:41:44 BST 2008


I'm having trouble with this test as well :(  I see this:


trunk$ perl  -Iblib/arch -Iblib/lib t/92storage_on_connect_do.t
1..9
ok 1 - connection()
Not an ARRAY reference at blib/lib/DBIx/Class/Storage/DBI.pm line 1076.
Attempt to free temp prematurely: SV 0x86fd5ec, Perl interpreter: 0x816c008.
Attempt to free unreferenced scalar: SV 0x86fd5ec, Perl interpreter:
0x816c008.
# Looks like you planned 9 tests but only ran 1.
# Looks like your test died just after 1.


There seem to be several oddities, not all necessarily connected with
the test failure. This is the first:

(1) There are two test 92, which doesn't seem ideal:
        t/92storage.t
        t/92storage_on_connect_do.t

The test failure seems to be provoked by this code in the test:

ok $schema->connection(
    DBICTest->_database,
    {
        on_connect_do       => [
            'CREATE TABLE TEST_empty (id INTEGER)',
            [ 'INSERT INTO TEST_empty VALUES (?)', {}, 2 ],
            \&insert_from_subref,
        ],
        on_disconnect_do    =>
            [\&check_exists, 'DROP TABLE TEST_empty', \&check_dropped],
    },
), 'connection()';

Trying to understand this, I hit the next oddity:

(2) The POD for on_connect_do in DBIx::Class::Storage::DBI says that
"Its value may contain ... an array reference ... This contains SQL
statements to execute in order.  Each element contains a string or a
code reference that returns a string." But the code that actually gets
called, in _do_query, also accepts elements that are arrays (call it
ETAA). So it seems the code has got ahead of the documentation.

And that brings us to the last oddity, which appears to be the cause of
my problem, but again my brain is struggling with why the test doesn't
fail for everybody?

(3) _do_query calls _query_start which calls _fix_bind_params. This
accepts ETAA (i.e. list of bind params) but only if each item in the
list is an array. In the t/92 code above, one of the elements is the
hashref {}.

So is the test wrong, or the module, or is my brain fried?

Thanks, Dave



More information about the DBIx-Class mailing list