[Bast-commits] r3133 - in branches/DBIx-Class-current: .
lib/DBIx/Class/Relationship lib/SQL/Translator/Parser/DBIx
ash at dev.catalyst.perl.org
ash at dev.catalyst.perl.org
Sun Mar 18 23:58:07 GMT 2007
Author: ash
Date: 2007-03-18 23:58:07 +0000 (Sun, 18 Mar 2007)
New Revision: 3133
Modified:
branches/DBIx-Class-current/Changes
branches/DBIx-Class-current/lib/DBIx/Class/Relationship/Base.pm
branches/DBIx-Class-current/lib/SQL/Translator/Parser/DBIx/Class.pm
Log:
sqlt parser now respected a relationship attribute of is_foreign_key_constraint
Modified: branches/DBIx-Class-current/Changes
===================================================================
--- branches/DBIx-Class-current/Changes 2007-03-18 17:22:13 UTC (rev 3132)
+++ branches/DBIx-Class-current/Changes 2007-03-18 23:58:07 UTC (rev 3133)
@@ -2,6 +2,9 @@
- select et al weren't properly detecing when the server connection
had timed out when not in a transaction
+ - The SQL::T parser class now respects a relationship attribute of
+ is_foreign_key_constrain to allow explicit control over wether or not
+ a foreign constraint is needed
0.07999_02 2007-01-25 20:11:00
- add support for binding BYTEA and similar parameters (w/Pg impl)
Modified: branches/DBIx-Class-current/lib/DBIx/Class/Relationship/Base.pm
===================================================================
--- branches/DBIx-Class-current/lib/DBIx/Class/Relationship/Base.pm 2007-03-18 17:22:13 UTC (rev 3132)
+++ branches/DBIx-Class-current/lib/DBIx/Class/Relationship/Base.pm 2007-03-18 23:58:07 UTC (rev 3133)
@@ -102,6 +102,13 @@
a column accessor). For C<multi> accessors, an add_to_* method is also
created, which calls C<create_related> for the relationship.
+=item is_foreign_key_constraint
+
+If you are using L<SQL::Translator> to create SQL for you and you find that it
+is creating constraints where it shouldn't, or not creating them where it
+should, set this attribute to a true or false value to override the detection
+of when to create constraints.
+
=back
=head2 register_relationship
Modified: branches/DBIx-Class-current/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- branches/DBIx-Class-current/lib/SQL/Translator/Parser/DBIx/Class.pm 2007-03-18 17:22:13 UTC (rev 3132)
+++ branches/DBIx-Class-current/lib/SQL/Translator/Parser/DBIx/Class.pm 2007-03-18 23:58:07 UTC (rev 3133)
@@ -145,16 +145,18 @@
#Decide if this is a foreign key based on whether the self
#items are our primary columns.
+ $DB::single = 1 if $moniker eq 'Tests::MBTI::Result';
# If the sets are different, then we assume it's a foreign key from
# us to another table.
- # OR: If is_foreign_key attr is explicity set on one the local columns
- if ( ! exists $created_FK_rels{$rel_table}->{$key_test}
- &&
- ( !$source->compare_relationship_keys(\@keys, \@primary) ||
- grep { $source->column_info($_)->{is_foreign_key} } @keys
- )
- ) {
+ # OR: If is_foreign_key_constraint attr is explicity set (or set to false) on the relation
+ if ( ! exists $created_FK_rels{$rel_table}->{$key_test} &&
+ ( exists $rel_info->{attrs}{is_foreign_key_constraint} &&
+ $rel_info->{attrs}{is_foreign_key_constraint} ||
+ !$source->compare_relationship_keys(\@keys, \@primary)
+ )
+ )
+ {
$created_FK_rels{$rel_table}->{$key_test} = 1;
$table->add_constraint(
type => 'foreign_key',
More information about the Bast-commits
mailing list