X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSource.pm;h=dfa4c7827b56a204242363968841ea0fc2fd6517;hb=2c74a93a46d0913a25ac6574ec9a65edb0466931;hp=45ac6acce6427c4b57892aad5acadd4d108e41ab;hpb=cbda91cb503efc22b57f3b5a37a6f4489ad5581c;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 45ac6ac..dfa4c78 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -40,8 +40,6 @@ DBIx::Class::ResultSource - Result source object # Create a query (view) based result source, in a result class package MyDB::Schema::Result::Year2000CDs; - use DBIx::Class::ResultSource::View; - __PACKAGE__->load_components('Core'); __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); @@ -245,9 +243,15 @@ automatically. =item auto_nextval -Set this to a true value for a column whose value is retrieved -automatically from an oracle sequence. If you do not use an Oracle -trigger to get the nextval, you have to set sequence as well. +Set this to a true value for a column whose value is retrieved automatically +from a sequence or function (if supported by your Storage driver.) For a +sequence, if you do not use a trigger to get the nextval, you have to set the +L value as well. + +Also set this for MSSQL columns with the 'uniqueidentifier' +L whose values you want to automatically +generate using C, unless they are a primary key in which case this will +be done anyway. =item extra @@ -581,7 +585,7 @@ sub name_unique_constraint { my ($self, $cols) = @_; my $name = $self->name; - $name = $$name if ref $name; + $name = $$name if (ref $name eq 'SCALAR'); return join '_', $name, @$cols; } @@ -1261,18 +1265,22 @@ sub pk_depends_on { # hashref of columns of the related object. sub _pk_depends_on { my ($self, $relname, $rel_data) = @_; - my $cond = $self->relationship_info($relname)->{cond}; + my $relinfo = $self->relationship_info($relname); + + # don't assume things if the relationship direction is specified + return $relinfo->{attrs}{is_foreign_key_constraint} + if exists ($relinfo->{attrs}{is_foreign_key_constraint}); + + my $cond = $relinfo->{cond}; return 0 unless ref($cond) eq 'HASH'; # map { foreign.foo => 'self.bar' } to { bar => 'foo' } - my $keyhash = { map { my $x = $_; $x =~ s/.*\.//; $x; } reverse %$cond }; # assume anything that references our PK probably is dependent on us # rather than vice versa, unless the far side is (a) defined or (b) # auto-increment - my $rel_source = $self->related_source($relname); foreach my $p ($self->primary_columns) {