[Bast-commits] r4292 - in DBIx-Class-Fixtures/1.001/trunk: .
lib/DBIx/Class t t/var t/var/configs t/var/fixtures
captainL at dev.catalyst.perl.org
captainL at dev.catalyst.perl.org
Fri Apr 25 17:15:51 BST 2008
Author: captainL
Date: 2008-04-25 17:15:50 +0100 (Fri, 25 Apr 2008)
New Revision: 4292
Added:
DBIx-Class-Fixtures/1.001/trunk/t/09-dump-scalar-ref.t
DBIx-Class-Fixtures/1.001/trunk/t/var/configs/scalar_ref.json
Removed:
DBIx-Class-Fixtures/1.001/trunk/META.yml
DBIx-Class-Fixtures/1.001/trunk/t/var/fixtures/_dumper_version
DBIx-Class-Fixtures/1.001/trunk/t/var/fixtures/artist/
Modified:
DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm
DBIx-Class-Fixtures/1.001/trunk/t/var/DBIxClass.db
Log:
scalar refs now handled on set conds as well as related conds
Deleted: DBIx-Class-Fixtures/1.001/trunk/META.yml
===================================================================
--- DBIx-Class-Fixtures/1.001/trunk/META.yml 2008-04-25 15:03:12 UTC (rev 4291)
+++ DBIx-Class-Fixtures/1.001/trunk/META.yml 2008-04-25 16:15:50 UTC (rev 4292)
@@ -1,45 +0,0 @@
----
-abstract: ~
-author:
- - Luke Saunders <luke at shadowcatsystems.co.uk>
-build_requires:
- Test::More: 0.7
-distribution_type: module
-generated_by: Module::Install version 0.68
-license: perl
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
-name: DBIx-Class-Fixtures
-no_index:
- directory:
- - inc
- - t
-provides:
- DBIx::Class::Fixtures:
- file: lib/DBIx/Class/Fixtures.pm
- version: 1.000001
- DBIx::Class::Fixtures::Schema:
- file: lib/DBIx/Class/Fixtures/Schema.pm
- DBIx::Class::Fixtures::SchemaVersioned:
- file: lib/DBIx/Class/Fixtures/SchemaVersioned.pm
- version: 0
- DBIx::Class::Fixtures::Versioned:
- file: lib/DBIx/Class/Fixtures/Versioned.pm
-requires:
- Class::Accessor::Grouped: 0.06
- Config::Any: 0.08
- DBIx::Class: 0.08
- DBIx::Class::Schema::Loader: 0.04004
- Data::Dump::Streamer: 2.05
- Data::Visitor: 0.15
- DateTime: 0.41
- DateTime::Format::MySQL: 0.04
- File::Copy::Recursive: 0.35
- File::Slurp: 999.13
- Hash::Merge: 0.1
- JSON::Syck: 0.26
- Path::Class: 0.16
- perl: 5.6.1
-tests: t/*.t
-version: 1.000001
Modified: DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm
===================================================================
--- DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm 2008-04-25 15:03:12 UTC (rev 4291)
+++ DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm 2008-04-25 16:15:50 UTC (rev 4292)
@@ -191,7 +191,7 @@
Specifies whether to automatically dump might_have relationships. Should be a hash with one attribute - fetch. Set fetch to 1 or 0.
{
- might_have: [{
+ might_have: {
fetch: 1
},
sets: [{
@@ -501,6 +501,13 @@
# fetch objects
my $rs = $schema->resultset($source->{class});
+
+ if ($source->{cond} and ref $source->{cond} eq 'HASH') {
+ # if value starts with / assume it's meant to be passed as a scalar ref to dbic
+ # ideally this would substitute deeply
+ $source->{cond} = { map { $_ => ($source->{cond}->{$_} =~ s/^\\//) ? \$source->{cond}->{$_} : $source->{cond}->{$_} } keys %{$source->{cond}} };
+ }
+
$rs = $rs->search($source->{cond}, { join => $source->{join} }) if ($source->{cond});
$self->msg("- dumping $source->{class}");
my @objects;
Added: DBIx-Class-Fixtures/1.001/trunk/t/09-dump-scalar-ref.t
===================================================================
--- DBIx-Class-Fixtures/1.001/trunk/t/09-dump-scalar-ref.t (rev 0)
+++ DBIx-Class-Fixtures/1.001/trunk/t/09-dump-scalar-ref.t 2008-04-25 16:15:50 UTC (rev 4292)
@@ -0,0 +1,44 @@
+#!perl
+
+use DBIx::Class::Fixtures;
+use Test::More tests => 7;
+use lib qw(t/lib);
+use DBICTest;
+use Path::Class;
+use Data::Dumper;
+
+# set up and populate schema
+ok(my $schema = DBICTest->init_schema(), 'got schema');
+
+my $config_dir = 't/var/configs';
+
+# do dump
+ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir, debug => 0 }), 'object created with correct config dir');
+
+ok($fixtures->dump({ config => 'scalar_ref.json', schema => $schema, directory => 't/var/fixtures' }), 'simple dump executed okay');
+
+{
+ # check dump is okay
+ my $dir = dir('t/var/fixtures/artist');
+ my @children = $dir->children;
+ is(scalar(@children), 1, 'right number of fixtures created');
+
+ my $fix_file = $children[0];
+ my $HASH1; eval($fix_file->slurp());
+
+ is($HASH1->{name}, 'We Are Goth', 'correct artist dumped');
+}
+
+{
+ # check dump is okay
+ my $dir = dir('t/var/fixtures/cd');
+ my @children = $dir->children;
+ is(scalar(@children), 1, 'right number of fixtures created');
+
+ my $fix_file = $children[0];
+ my $HASH1; eval($fix_file->slurp());
+
+ is($HASH1->{title}, 'Come Be Depressed With Us', 'correct cd dumped');
+}
+
+
Modified: DBIx-Class-Fixtures/1.001/trunk/t/var/DBIxClass.db
===================================================================
(Binary files differ)
Added: DBIx-Class-Fixtures/1.001/trunk/t/var/configs/scalar_ref.json
===================================================================
--- DBIx-Class-Fixtures/1.001/trunk/t/var/configs/scalar_ref.json (rev 0)
+++ DBIx-Class-Fixtures/1.001/trunk/t/var/configs/scalar_ref.json 2008-04-25 16:15:50 UTC (rev 4292)
@@ -0,0 +1,17 @@
+{
+ might_have: {
+ fetch: 0
+ },
+ has_many: {
+ fetch: 0
+ },
+ sets: [{
+ class: 'Artist',
+ cond: { me.name: '\= "We Are Goth"' },
+ quantity: all,
+ fetch: [{
+ rel: 'cds',
+ cond: { 'me.title': '\LIKE "%with us"' }
+ }]
+ }]
+}
\ No newline at end of file
Deleted: DBIx-Class-Fixtures/1.001/trunk/t/var/fixtures/_dumper_version
===================================================================
--- DBIx-Class-Fixtures/1.001/trunk/t/var/fixtures/_dumper_version 2008-04-25 15:03:12 UTC (rev 4291)
+++ DBIx-Class-Fixtures/1.001/trunk/t/var/fixtures/_dumper_version 2008-04-25 16:15:50 UTC (rev 4292)
@@ -1 +0,0 @@
-1.000001
\ No newline at end of file
More information about the Bast-commits
mailing list