From: Dagfinn Ilmari Mannsåker Date: Wed, 8 Aug 2012 19:27:06 +0000 (+0100) Subject: Use weak refs for schema object attributes X-Git-Tag: v0.11013_01~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5bfeba834a779d591ed9e629594142f14afb73f;p=dbsrgits%2FSQL-Translator.git Use weak refs for schema object attributes This fixes the leaks that the destructors removed in the previous commit were ineffectually trying to fix. Bump the Moo prereq for fixed return value of weak_ref setters. --- diff --git a/Makefile.PL b/Makefile.PL index 6378634..3557edc 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -19,7 +19,7 @@ my $deps = { 'File::ShareDir' => '1.0', 'File::Spec' => '0', 'XML::Writer' => '0.500', - 'Moo' => '0.009007', + 'Moo' => '1.000003', 'Try::Tiny' => '0.04', }, recommends => { diff --git a/lib/SQL/Translator/Schema.pm b/lib/SQL/Translator/Schema.pm index 3e7884b..de48413 100644 --- a/lib/SQL/Translator/Schema.pm +++ b/lib/SQL/Translator/Schema.pm @@ -757,7 +757,7 @@ Get the SQL::Translator instance that instantiated the parser. =cut -has translator => ( is => 'rw' ); +has translator => ( is => 'rw', weak_ref => 1 ); 1; diff --git a/lib/SQL/Translator/Schema/Constraint.pm b/lib/SQL/Translator/Schema/Constraint.pm index 2be5bbd..be70221 100644 --- a/lib/SQL/Translator/Schema/Constraint.pm +++ b/lib/SQL/Translator/Schema/Constraint.pm @@ -390,7 +390,7 @@ Get or set the constraint's table object. =cut -has table => ( is => 'rw', isa => schema_obj('Table') ); +has table => ( is => 'rw', isa => schema_obj('Table'), weak_ref => 1 ); around table => \&ex2err; diff --git a/lib/SQL/Translator/Schema/Field.pm b/lib/SQL/Translator/Schema/Field.pm index c5bda76..48fac66 100644 --- a/lib/SQL/Translator/Schema/Field.pm +++ b/lib/SQL/Translator/Schema/Field.pm @@ -178,6 +178,7 @@ has foreign_key_reference => ( is => 'rw', predicate => '_has_foreign_key_reference', isa => schema_obj('Constraint'), + weak_ref => 1, ); around foreign_key_reference => sub { @@ -493,7 +494,7 @@ also be used to get the table name. =cut -has table => ( is => 'rw', isa => schema_obj('Table') ); +has table => ( is => 'rw', isa => schema_obj('Table'), weak_ref => 1 ); around table => \&ex2err; diff --git a/lib/SQL/Translator/Schema/Index.pm b/lib/SQL/Translator/Schema/Index.pm index 890c1b4..695f10f 100644 --- a/lib/SQL/Translator/Schema/Index.pm +++ b/lib/SQL/Translator/Schema/Index.pm @@ -153,7 +153,7 @@ Get or set the index's table object. =cut -has table => ( is => 'rw', isa => schema_obj('Table') ); +has table => ( is => 'rw', isa => schema_obj('Table'), weak_ref => 1 ); around table => \&ex2err; diff --git a/lib/SQL/Translator/Schema/Procedure.pm b/lib/SQL/Translator/Schema/Procedure.pm index e7d0cde..35cb738 100644 --- a/lib/SQL/Translator/Schema/Procedure.pm +++ b/lib/SQL/Translator/Schema/Procedure.pm @@ -161,7 +161,7 @@ Get or set the procedures's schema object. =cut -has schema => ( is => 'rw', isa => schema_obj('Schema') ); +has schema => ( is => 'rw', isa => schema_obj('Schema'), weak_ref => 1 ); around schema => \&ex2err; diff --git a/lib/SQL/Translator/Schema/Table.pm b/lib/SQL/Translator/Schema/Table.pm index 2c0a3da..71d7bd2 100644 --- a/lib/SQL/Translator/Schema/Table.pm +++ b/lib/SQL/Translator/Schema/Table.pm @@ -723,7 +723,7 @@ Get or set the table's schema object. =cut -has schema => ( is => 'rw', isa => schema_obj('Schema') ); +has schema => ( is => 'rw', isa => schema_obj('Schema'), weak_ref => 1 ); around schema => \&ex2err; diff --git a/lib/SQL/Translator/Schema/Trigger.pm b/lib/SQL/Translator/Schema/Trigger.pm index 429e7d8..ebd97c9 100644 --- a/lib/SQL/Translator/Schema/Trigger.pm +++ b/lib/SQL/Translator/Schema/Trigger.pm @@ -177,7 +177,7 @@ Gets or set the table on which the trigger works, as a L ( is => 'rw', isa => schema_obj('Table') ); +has table => ( is => 'rw', isa => schema_obj('Table'), weak_ref => 1 ); around table => \&ex2err; @@ -304,7 +304,7 @@ Get or set the trigger's schema object. =cut -has schema => (is => 'rw', isa => schema_obj('Schema') ); +has schema => (is => 'rw', isa => schema_obj('Schema'), weak_ref => 1 ); around schema => \&ex2err; diff --git a/lib/SQL/Translator/Schema/View.pm b/lib/SQL/Translator/Schema/View.pm index bee761e..b33c160 100644 --- a/lib/SQL/Translator/Schema/View.pm +++ b/lib/SQL/Translator/Schema/View.pm @@ -202,7 +202,7 @@ Get or set the view's schema object. =cut -has schema => ( is => 'rw', isa => schema_obj('Schema') ); +has schema => ( is => 'rw', isa => schema_obj('Schema'), weak_ref => 1 ); around schema => \&ex2err;