Subject: | on_connect_do accepted syntax inconsistent with documentation - listref of subref returning string not actually supported |
https://metacpan.org/pod/DBIx::Class::Storage::DBI#DBIx::Class-specific-connection-attributes says that the argument to on_connect_do can be a listref that contains a subref -- which can return a string.
However, this usage does not work. This can be easily seen by altering an existing unit test:
diff --git a/t/storage/on_connect_do.t b/t/storage/on_connect_do.t
index 115fadb7..999b312b 100644
--- a/t/storage/on_connect_do.t
+++ b/t/storage/on_connect_do.t
@@ -101,8 +101,5 @@ sub check_dropped {
sub insert_from_subref {
my $storage = shift;
- return [
- [ 'INSERT INTO TEST_empty VALUES (?)', {}, 3 ],
- 'INSERT INTO TEST_empty VALUES (7)',
- ];
+ 'INSERT INTO TEST_empty VALUES (7)',
}
$ perl -Ilib t/storage/on_disconnect_do.t
...
DBIx::Class::Storage::DBI::catch {...} (): Can't use string ("INSERT INTO TEST_empty VALUES (7"...) as an ARRAY ref while "strict refs" in use at lib/DBIx/Class/Storage/DBI.pm line 1459. at t/storage/on_connect_do.t line 55
The documentation also does not mention the usage exercised in the unit test -- where the subref returns a listref of strings, nor the usage where a single query is itself a listref (query plus attributes and bind arguments).
(I'm not sure which way is right, but I'm guessing that all of these syntaxes ought to be valid.)