[Bast-commits] r5114 - in
DBIx-Class/0.08/branches/sqla_1.50_compat: . lib/DBIx/Class
lib/DBIx/Class/Relationship lib/DBIx/Class/Storage/DBI t
t/lib t/lib/DBICTest/Schema
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Wed Nov 12 16:43:55 GMT 2008
Author: matthewt
Date: 2008-11-12 16:43:54 +0000 (Wed, 12 Nov 2008)
New Revision: 5114
Modified:
DBIx-Class/0.08/branches/sqla_1.50_compat/
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship/BelongsTo.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/SQLite.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/t/66relationship.t
DBIx-Class/0.08/branches/sqla_1.50_compat/t/73oracle.t
DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/Schema/ForceForeign.pm
DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/sqlite.sql
Log:
r25478 at agaton (orig r5092): ribasushi | 2008-11-10 22:46:45 +0000
Switch out one more reliance on connect_info
r25483 at agaton (orig r5097): ribasushi | 2008-11-10 23:09:23 +0000
belongs_to relationships are explicitly flagged by default, to aid the DBIC SQLT parser (by abraxxa)
r25484 at agaton (orig r5098): ribasushi | 2008-11-10 23:18:01 +0000
Clarify attributes argument of find()
r25499 at agaton (orig r5113): plu | 2008-11-12 16:42:44 +0000
fixed 73oracle.t, added charfield
Property changes on: DBIx-Class/0.08/branches/sqla_1.50_compat
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5096
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5096
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:5113
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship/BelongsTo.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship/BelongsTo.pm 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Relationship/BelongsTo.pm 2008-11-12 16:43:54 UTC (rev 5114)
@@ -9,6 +9,11 @@
sub belongs_to {
my ($class, $rel, $f_class, $cond, $attrs) = @_;
+
+ # assume a foreign key contraint unless defined otherwise
+ $attrs->{is_foreign_key_constraint} = 1
+ if not exists $attrs->{is_foreign_key_constraint};
+
# no join condition or just a column name
if (!ref $cond) {
$class->ensure_class_loaded($f_class);
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSet.pm 2008-11-12 16:43:54 UTC (rev 5114)
@@ -341,6 +341,9 @@
If your table does not have a primary key, you B<must> provide a value for the
C<key> attribute matching one of the unique constraints on the source.
+In addition to C<key>, L</find> recognizes and applies standard
+L<resultset attributes|/ATTRIBUTES> in the same way as L</search> does.
+
Note: If your query does not return only one row, a warning is generated:
Query returned more than one row
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/ResultSource.pm 2008-11-12 16:43:54 UTC (rev 5114)
@@ -843,7 +843,7 @@
#warn "$self $k $for $v";
unless ($for->has_column_loaded($v)) {
if ($for->in_storage) {
- $self->throw_exception("Column ${v} not loaded on ${for} trying to reolve relationship");
+ $self->throw_exception("Column ${v} not loaded on ${for} trying to resolve relationship");
}
return $UNRESOLVABLE_CONDITION;
}
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/SQLite.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/SQLite.pm 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI/SQLite.pm 2008-11-12 16:43:54 UTC (rev 5114)
@@ -19,7 +19,7 @@
$dir ||= './';
## Where is the db file?
- my $dsn = $self->connect_info()->[0];
+ my $dsn = $self->_dbi_connect_info()->[0];
my $dbname = $1 if($dsn =~ /dbname=([^;]+)/);
if(!$dbname)
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/66relationship.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/66relationship.t 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/66relationship.t 2008-11-12 16:43:54 UTC (rev 5114)
@@ -7,7 +7,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 67;
+plan tests => 69;
# has_a test
my $cd = $schema->resultset("CD")->find(4);
@@ -117,14 +117,11 @@
is( $cd->title, 'Greatest Hits 2: Louder Than Ever', 'find_or_new_related new record ok' );
ok( ! $cd->in_storage, 'find_or_new_related on a new record: not in_storage' );
-# print STDERR Data::Dumper::Dumper($cd->get_columns);
-# $cd->result_source->schema->storage->debug(1);
$cd->artist(undef);
my $newartist = $cd->find_or_new_related( 'artist', {
name => 'Random Boy Band Two',
artistid => 200,
} );
-# $cd->result_source->schema->storage->debug(0);
is($newartist->name, 'Random Boy Band Two', 'find_or_new_related new artist record with id');
is($newartist->id, 200, 'find_or_new_related new artist id set');
@@ -263,3 +260,12 @@
is ($@, '', 'Staged insertion successful');
ok($new_artist->in_storage, 'artist inserted');
ok($new_related_cd->in_storage, 'new_related_cd inserted');
+
+# check if is_foreign_key_constraint attr is set
+my $rs_normal = $schema->source('Track');
+my $relinfo = $rs_normal->relationship_info ('cd');
+cmp_ok($relinfo->{attrs}{is_foreign_key_constraint}, '==', 1, "is_foreign_key_constraint defined for belongs_to relationships.");
+
+my $rs_overridden = $schema->source('ForceForeign');
+my $relinfo_with_attr = $rs_overridden->relationship_info ('cd_3');
+cmp_ok($relinfo_with_attr->{attrs}{is_foreign_key_constraint}, '==', 0, "is_foreign_key_constraint defined for belongs_to relationships with attr.");
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/73oracle.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/73oracle.t 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/73oracle.t 2008-11-12 16:43:54 UTC (rev 5114)
@@ -32,7 +32,7 @@
$dbh->do("CREATE SEQUENCE pkid1_seq START WITH 1 MAXVALUE 999999 MINVALUE 0");
$dbh->do("CREATE SEQUENCE pkid2_seq START WITH 10 MAXVALUE 999999 MINVALUE 0");
$dbh->do("CREATE SEQUENCE nonpkid_seq START WITH 20 MAXVALUE 999999 MINVALUE 0");
-$dbh->do("CREATE TABLE artist (artistid NUMBER(12), name VARCHAR(255), rank NUMBER(38))");
+$dbh->do("CREATE TABLE artist (artistid NUMBER(12), name VARCHAR(255), rank NUMBER(38), charfield VARCHAR2(10))");
$dbh->do("CREATE TABLE sequence_test (pkid1 NUMBER(12), pkid2 NUMBER(12), nonpkid NUMBER(12), name VARCHAR(255))");
$dbh->do("CREATE TABLE cd (cdid NUMBER(12), artist NUMBER(12), title VARCHAR(255), year VARCHAR(4))");
$dbh->do("CREATE TABLE track (trackid NUMBER(12), cd NUMBER(12), position NUMBER(12), title VARCHAR(255), last_updated_on DATE)");
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/Schema/ForceForeign.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/Schema/ForceForeign.pm 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/Schema/ForceForeign.pm 2008-11-12 16:43:54 UTC (rev 5114)
@@ -29,4 +29,13 @@
},
);
+# Normally this would appear as a FK constraint
+__PACKAGE__->belongs_to(
+ 'cd_3', 'DBICTest::Schema::CD', {
+ 'foreign.cdid' => 'self.cd',
+ }, {
+ is_foreign_key_constraint => 0,
+ },
+);
+
1;
Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/sqlite.sql
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/sqlite.sql 2008-11-12 16:42:44 UTC (rev 5113)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/sqlite.sql 2008-11-12 16:43:54 UTC (rev 5114)
@@ -1,6 +1,6 @@
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Sun Nov 9 16:28:17 2008
+-- Created on Mon Nov 10 23:52:55 2008
--
BEGIN TRANSACTION;
@@ -190,6 +190,7 @@
notes varchar(100) NOT NULL
);
+CREATE INDEX liner_notes_idx_liner_id_liner ON liner_notes (liner_id);
--
-- Table: link
More information about the Bast-commits
mailing list