- Fix corner case of forked children disconnecting the parents DBI
handle
- Fix leakage of $schema on in-memory new_related() calls
+ - Fix more cases of $schema leakage in SQLT::Parser::DBIC
- Remove useless vestigial pessimization in Ordered.pm for cases
when the position column is part of a unique constraint
# We're working with DBIx::Class Schemas, not data streams.
# -------------------------------------------------------------------
sub parse {
- # this is a hack to prevent schema leaks due to a retarded SQLT implementation
- # DO NOT REMOVE (until SQLT2 is out, the all of this will be rewritten anyway)
- weaken $_[1] if ref ($_[1]);
-
my ($tr, $data) = @_;
my $args = $tr->parser_args;
my $dbicschema = $args->{'DBIx::Class::Schema'} || $args->{"DBIx::Schema"} ||$data;
$dbicschema ||= $args->{'package'};
my $limit_sources = $args->{'sources'};
+ # this is a hack to prevent schema leaks due to a retarded SQLT implementation
+ # DO NOT REMOVE (until SQLT2 is out, the all of this will be rewritten anyway)
+ ref $_ and weaken $_
+ for $_[1], $dbicschema, @{$args}{qw/DBIx::Schema DBIx::Class::Schema package/};
+
DBIx::Class::Exception->throw('No DBIx::Class::Schema') unless ($dbicschema);
if (!ref $dbicschema) {
eval "require $dbicschema"
# Test for SQLT-related leaks
{
my $s = DBICTest::Schema->clone;
- my $sqlt_schema = create_schema ({ schema => $s });
+
+ my @schemas = (
+ create_schema ({ schema => $s }),
+ create_schema ({ args => { parser_args => { 'DBIx::Class::Schema' => $s } } }),
+ create_schema ({ args => { parser_args => { 'DBIx::Schema' => $s } } }),
+ create_schema ({ args => { parser_args => { package => $s } } }),
+ );
+
Scalar::Util::weaken ($s);
ok (!$s, 'Schema not leaked');
- isa_ok ($sqlt_schema, 'SQL::Translator::Schema', 'SQLT schema object produced');
+ isa_ok ($_, 'SQL::Translator::Schema', "SQLT schema object $_ produced")
+ for @schemas;
}
# make sure classname-style works