blib/lib/DBIx/Class/MockData.pm

filter: Statementstmt 70.1% 216 / 308 Branchbran 59.8% 79 / 132 Conditioncond 54.4% 43 / 79 MC/DCmcdc 20.0% 8 / 40 Subroutinesub 61.2% 30 / 49 Podpod 80.0% 4 / 5 totaltotal 61.9% 380 / 613 CC 120 SCAR 28.0
CC
120
Cov
65%
dry_run
56.0
_generate_value
33.3
new
31.5
CRAP 16.5
↑ Summary
1 package DBIx::Class::MockData;
2  
3 5 $DBIx::Class::MockData::VERSION = '0.04';
4 5 $DBIx::Class::MockData::AUTHORITY = 'cpan:MANWAR';
5  
6 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =encoding UTF-8
10  
11 =head1 NAME
12  
13 DBIx::Class::MockData - Generate mock test data for DBIx::Class schemas
14  
15 =head1 VERSION
16  
17 Version 0.04
18  
19 =head1 SYNOPSIS
20  
21 use DBIx::Class::MockData;
22  
23 my $schema = MyApp::Schema->connect($dsn, $user, $pass);
24  
25 # Basic usage
26 DBIx::Class::MockData
27 ->new(
28 schema => $schema,
29 schema_dir => 't/lib',
30 )
31 ->deploy
32 ->generate;
33  
34 # With options
35 DBIx::Class::MockData
36 ->new(
37 schema => $schema,
38 schema_dir => 't/lib',
39 rows => 10,
40 verbose => 1,
41 seed => 42,
42 )
43 ->wipe
44 ->generate;
45  
46 # Populate only selected tables
47 DBIx::Class::MockData
48 ->new(
49 schema => $schema,
50 schema_dir => 't/lib',
51 only => [qw(Author Book)],
52 )
53 ->generate;
54  
55 # Populate all tables except selected ones
56 DBIx::Class::MockData
57 ->new(
58 schema => $schema,
59 schema_dir => 't/lib',
60 exclude => [qw(AuditLog SessionToken)],
61 )
62 ->generate;
63  
64 # Use custom generators for specific columns
65 DBIx::Class::MockData
66 ->new(
67 schema => $schema,
68 schema_dir => 't/lib',
69 generators => {
70 email => sub { "user".int(rand(1000))."\@example.com" },
71 status => sub { "active" },
72 created_at => sub {
73 my ($col, $info, $n, $mock) = @_;
74 return DateTime->now->datetime;
75 },
76 }
77 )
78 ->generate;
79  
80 # Set different row counts per table
81 DBIx::Class::MockData
82 ->new(
83 schema => $schema,
84 schema_dir => 't/lib',
85 rows => 5, # default for all tables
86 rows_per_table => {
87 Author => 10, # override for Author
88 Book => 3, # override for Book
89 },
90 )
91 ->generate;
92  
93 =head1 DESCRIPTION
94  
95 Accepts a connected L<DBIx::Class::Schema> object, the return value of
96 C<< YourSchema->connect(...) >>, introspects every result source, resolves
97 foreign-key insertion order via topological sort, and inserts randomly
98 generated rows. Values are produced from each column's declared
99 C<data_type>. Unique and primary-key columns are salted with a per-run
100 random value to avoid cross-run collisions.
101  
102 Connection and schema loading are entirely the caller's responsibility.
103 C<schema_dir> is accepted only to ensure the lib root is present in C<@INC>
104 so result classes remain resolvable at runtime.
105  
106 All public methods return C<$self>, enabling call chaining.
107  
108 =head1 METHODS
109  
110 =cut
111  
112 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
113 5 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
114 5 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116 =head1 CONSTRUCTOR
117  
118 my $mock = DBIx::Class::MockData->new(
119 schema => $connected_schema, # required
120 schema_dir => 't/lib', # required
121 rows => 5, # rows per table (default: 5)
122 verbose => 0, # debug output (default: 0)
123 seed => 42, # random seed (optional)
124 );
125  
126 B<ARGUMENTS>
127  
128 =over 4
129  
130 =item schema B<(required)>
131  
132 A connected L<DBIx::Class::Schema> instance - the return value of
133 C<< YourSchema->connect(...) >>.
134  
135 =item schema_dir B<(required)>
136  
137 The lib root containing your schema classes. Added to C<@INC> so result
138 classes referenced by relationships remain resolvable.
139  
140 =item rows
141  
142 Number of rows to generate per table. Default: C<5>.
143  
144 =item verbose
145  
146 Print debug output. Default: C<0>.
147  
148 =item seed
149  
150 Integer seed passed to C<srand> for reproducible output. Optional.
151  
152 =item only
153  
154 Array reference of source names to populate. When supplied, only the listed
155 tables are processed (in FK-safe order). Cannot be combined with C<exclude>.
156  
157 only => [qw(Author Book)]
158  
159 =item exclude
160  
161 Array reference of source names to skip. All other tables are populated.
162 Cannot be combined with C<only>.
163  
164 exclude => [qw(AuditLog SessionToken)]
165  
166 =back
167  
168 =cut
169  
170 sub new {
171 10 ▶ my ($class, %args) = @_;
Subroutine new: called CC=20 SCAR=34.5
Pod undocumented
172  
173 croak "schema is required"
174 10 ▶ unless $args{schema};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"schema"} 1 9 10
175 croak "schema must be a DBIx::Class::Schema instance"
176 9 ▶ unless blessed($args{schema}) && $args{schema}->isa('DBIx::Class::Schema');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($args{"schema"}) and $args{"schema"}->isa("DBIx::Class::Schema") 1 8 9
Condition66%2/3
builtin::blessed($args{"schema"}) and $args{"schema"}->isa("DBIx::Class::Schema")
!ll&&!rl&&r
108
MC/DC50%1/2
builtin::blessed($args{"schema"}) and $args{"schema"}->isa("DBIx::Class::Schema")
builtin::blessed($args{"schema"}) $args{"schema"}->isa("DBIx::Class::Schema")
Truth table66%2/3
A and B
A= builtin::blessed($args{"schema"})B= $args{"schema"}->isa("DBIx::Class::Schema")
ABresult
0X0
100
111
177 croak "schema_dir is required"
178 8 ▶ unless $args{schema_dir};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"schema_dir"} 1 7 8
179  
180 7 my $dir = File::Spec->rel2abs($args{schema_dir});
181 7 ▶ croak "schema_dir '$dir' does not exist" unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 7 7
182 7 ▶ push @INC, $dir unless grep { $_ eq $dir } @INC;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $dir;} @INC 4 3 7
183  
184 croak "only and exclude cannot both be specified"
185 7 ▶ if $args{only} && $args{exclude};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"only"} and $args{"exclude"} 0 7 7
Condition33%1/3
$args{"only"} and $args{"exclude"}
!ll&&!rl&&r
700
MC/DC0%0/2
$args{"only"} and $args{"exclude"}
$args{"only"} $args{"exclude"}
Truth table33%1/3
A and B
A= $args{"only"}B= $args{"exclude"}
ABresult
0X0
100
111
186 croak "only must be an arrayref"
187 7 ▶ if $args{only} && ref($args{only}) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $args{"only"} and ref $args{"only"} ne "ARRAY" 0 7 7
Condition33%1/3
$args{"only"} and ref $args{"only"} ne "ARRAY"
!ll&&!rl&&r
700
MC/DC0%0/2
$args{"only"} and ref $args{"only"} ne "ARRAY"
$args{"only"} ref $args{"only"} ne "ARRAY"
Truth table33%1/3
A and B
A= $args{"only"}B= ref $args{"only"} ne "ARRAY"
ABresult
0X0
100
111
188 croak "exclude must be an arrayref"
189 7 ▶ if $args{exclude} && ref($args{exclude}) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $args{"exclude"} and ref $args{"exclude"} ne "ARRAY" 0 7 7
Condition33%1/3
$args{"exclude"} and ref $args{"exclude"} ne "ARRAY"
!ll&&!rl&&r
700
MC/DC0%0/2
$args{"exclude"} and ref $args{"exclude"} ne "ARRAY"
$args{"exclude"} ref $args{"exclude"} ne "ARRAY"
Truth table33%1/3
A and B
A= $args{"exclude"}B= ref $args{"exclude"} ne "ARRAY"
ABresult
0X0
100
111
190  
191 my $self = {
192 _schema => $args{schema},
193 rows => $args{rows} // 5,
194 verbose => $args{verbose} // 0,
195 rows_per_table => $args{rows_per_table} || {},
196 generators => $args{generators} || {},
197 _salt => int(rand(9_000_000)) + 1_000_000,
198 0 ▶ _only => $args{only} ? { map { $_ => 1 } @{ $args{only} } } : undef,
Branch: 1 branch
BranchTrueFalseTotal
$args{'exclude'} ? : 0 7 7
199 7 ▶ _exclude => $args{exclude} ? { map { $_ => 1 } @{ $args{exclude} } } : undef,
Branch: 1 branch
BranchTrueFalseTotal
$args{'only'} ? : 0 7 7
Condition75%6/8
$args{"rows"} // 5
l!l
52
$args{"verbose"} // 0
l!l
07
$args{'rows_per_table'} || {}
l!l
16
$args{'generators'} || {}
l!l
07
MC/DC100%1/1
$args{"rows"} // 5
$args{"rows"}
MC/DC0%0/1
$args{"verbose"} // 0
$args{"verbose"}
MC/DC100%1/1
$args{'rows_per_table'} || {}
$args{'rows_per_table'}
MC/DC0%0/1
$args{'generators'} || {}
$args{'generators'}
Truth table100%2/2
A
A= $args{"rows"}
Aresult
11
00
Truth table50%1/2
A
A= $args{"verbose"}
Aresult
11
00
Truth table100%2/2
A
A= $args{'rows_per_table'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'generators'}
Aresult
11
00
200 };
201  
202 7 ▶ if (defined $args{seed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"seed"}) 1 6 7
203 1 srand($args{seed});
204 1 $self->{_salt} = int(rand(9_000_000)) + 1_000_000;
205 }
206  
207 7 return bless $self, $class;
208 }
209  
210 =head1 METHODS
211  
212 =head2 deploy
213  
214 $mock->deploy;
215 $mock->deploy->generate; # chainable
216  
217 Creates all tables that do not yet exist. Safe to call when some or all
218 tables are already present. Returns C<$self>.
219  
220 =cut
221  
222 sub deploy {
223 4 ▶ my ($self) = @_;
Subroutine deploy: called CC=4 SCAR=20.1
Pod documented
224 4 my $schema = $self->{_schema};
225  
226 4 $self->_log("Deploying schema (creating missing tables)...");
227  
228 4 my $ddl = eval { $schema->deployment_statements };
229 4 ▶ if ($@ || !$ddl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $ddl) { } 4 0 4
Condition33%1/3
$@ or not $ddl
l!l&&r!l&&!r
400
MC/DC0%0/2
$@ or not $ddl
$@ not $ddl
Truth table33%1/3
A or not(B)
A= $@B= not $ddl
ABresult
1X1
011
000
230 4 eval { $schema->deploy({ add_drop_table => 0, ignore_errors => 1 }) };
231 4 ▶ croak "Deploy failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 4 0 4
232 }
233 else {
234 $schema->storage->dbh_do(sub {
235 0 ▶ my (undef, $dbh) = @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
236 0 for my $stmt (split /;\s*/m, $ddl) {
237 0 $stmt =~ s/^\s+|\s+$//g;
238 0 ▶ next unless length $stmt;
Branch: 1 branch
BranchTrueFalseTotal
unless length $stmt 0 0 0
239 0 eval { $dbh->do($stmt) };
240 0 ▶ $self->_debug(" Skipped (exists?): " . substr($stmt, 0, 60)) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
241 }
242 0 });
243 }
244  
245 0 $self->_log("Deploy complete");
246 0 return $self;
247 }
248  
249 =head2 wipe
250  
251 $mock->wipe->generate; # chainable
252  
253 Drops B<all> tables then redeploys the schema.
254 B<Destructive -- for test environments only.> Returns C<$self>.
255  
256 =cut
257  
258 sub wipe {
259 0 ▶ my ($self) = @_;
Subroutine wipe: not called CC=2 SCAR=17.9
Pod documented
260 0 my $schema = $self->{_schema};
261  
262 0 $self->_log("Wiping all tables...");
263 0 eval {
264 $schema->storage->dbh_do(sub {
265 0 ▶ my (undef, $dbh) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
266 0 for my $src (reverse $schema->sources) {
267 0 my $table = $schema->source($src)->from;
268 0 ▶ $table = $$table if ref($table) eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $table eq "SCALAR" 0 0 0
269 0 $self->_debug(" Dropping: $table");
270 0 $dbh->do("DROP TABLE IF EXISTS $table");
271 }
272 0 });
273 };
274 0 ▶ croak "Wipe failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
275  
276 0 $schema->deploy({ add_drop_table => 0 });
277 0 $self->_log("Wipe and redeploy complete");
278 0 return $self;
279 }
280  
281 =head2 generate
282  
283 $mock->generate;
284  
285 Inserts mock rows into every table respecting FK insertion order, data
286 types, nullability, and uniqueness constraints. Returns C<$self>.
287  
288 =cut
289  
290 sub _active_sources {
291 2 ▶ my ($self, @all) = @_;
Subroutine _active_sources: called CC=5 SCAR=25.9
292 2 my %known = map { $_ => 1 } @all;
293  
294 2 ▶ if ($self->{_only}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_only"}) 0 2 2
295 0 my @unknown = grep { !$known{$_} } keys %{ $self->{_only} };
296 0 ▶ croak "Unknown source(s) in 'only': " . join(', ', sort @unknown) if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 0 0
297 0 return grep { $self->{_only}{$_} } @all;
298 }
299 2 ▶ if ($self->{_exclude}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_exclude"}) 0 2 2
300 0 my @unknown = grep { !$known{$_} } keys %{ $self->{_exclude} };
301 0 ▶ croak "Unknown source(s) in 'exclude': " . join(', ', sort @unknown) if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 0 0
302 0 return grep { !$self->{_exclude}{$_} } @all;
303 }
304 2 return @all;
305 }
306  
307 sub generate {
308 2 ▶ my ($self) = @_;
Subroutine generate: called CC=14 SCAR=27.3
Pod documented
309 2 my $schema = $self->{_schema};
310  
311 2 my @all_sources = $schema->sources;
312 2 ▶ croak "No result sources found in schema" unless @all_sources;
Branch: 1 branch
BranchTrueFalseTotal
unless @all_sources 0 2 2
313  
314 2 my @sources = $self->_active_sources(@all_sources);
315 2 ▶ croak "No sources to populate after applying only/exclude filters" unless @sources;
Branch: 1 branch
BranchTrueFalseTotal
unless @sources 0 2 2
316  
317 2 $self->_log("Found sources: " . join(', ', sort @sources));
318  
319 2 my ($deps, $rsrc) = $self->_build_dep_graph(\@sources);
320 2 my @ordered = $self->_topo_sort($deps, \@sources);
321  
322 2 $self->_log("Insertion order: " . join(' -> ', @ordered));
323  
324 2 my %inserted_pks;
325  
326 2 for my $name (@ordered) {
327 5 $self->_log("\n--- Table: $name ---");
328  
329 5 my $source = $rsrc->{$name};
330 5 my @cols = $source->columns;
331 5 my %col_info = map { $_ => $source->column_info($_) } @cols;
332 5 my @pk_cols = $source->primary_columns;
333 5 my %pk_set = map { $_ => 1 } @pk_cols;
334 5 my %unique = $self->_unique_cols($source, \@pk_cols, \%col_info);
335 5 my %fk = $self->_build_fk_map($source);
336  
337 5 ▶ $self->_debug(" Unique cols: " . join(', ', sort keys %unique)) if %unique;
Branch: 1 branch
BranchTrueFalseTotal
if %unique 5 0 5
338  
339 5 my @rows;
340 5 ▶ my $rows = $self->{rows_per_table}{$name} // $self->{rows};
Condition33%1/3
$self->{"rows_per_table"}{$name} // $self->{"rows"}
l!l&&r!l&&!r
050
MC/DC0%0/2
$self->{"rows_per_table"}{$name} // $self->{"rows"}
$self->{"rows_per_table"}{$name} $self->{"rows"}
Truth table33%1/3
A // B
A= $self->{"rows_per_table"}{$name}B= $self->{"rows"}
ABresult
1X1
011
000
341 5 for my $n (1 .. $rows) {
342 18 my %row;
343 18 for my $col (@cols) {
344 101 my $info = $col_info{$col};
345 101 ▶ next if $pk_set{$col} && $self->_is_auto_pk($info);
Branch: 1 branch
BranchTrueFalseTotal
if $pk_set{$col} and $self->_is_auto_pk($info) 0 101 101
Condition66%2/3
$pk_set{$col} and $self->_is_auto_pk($info)
!ll&&!rl&&r
83180
MC/DC0%0/2
$pk_set{$col} and $self->_is_auto_pk($info)
$pk_set{$col} $self->_is_auto_pk($info)
Truth table66%2/3
A and B
A= $pk_set{$col}B= $self->_is_auto_pk($info)
ABresult
0X0
100
111
346  
347 101 ▶ if (exists $fk{$col}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fk{$col}) 11 90 101
348 11 ▶ my $pool = $inserted_pks{ $fk{$col}{source} } // [];
Condition50%1/2
$inserted_pks{$fk{$col}{"source"}} // []
l!l
011
MC/DC0%0/1
$inserted_pks{$fk{$col}{"source"}} // []
$inserted_pks{$fk{$col}{"source"}}
Truth table50%1/2
A
A= $inserted_pks{$fk{$col}{"source"}}
Aresult
11
00
349 11 ▶ if (@$pool) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$pool) { } 0 11 11
elsif ($info->{'is_nullable'}) { } 0 11 11
350 0 $row{$col} = $pool->[ ($n-1) % @$pool ]{ $fk{$col}{col} };
351 }
352 elsif ($info->{is_nullable}) {
353 0 $row{$col} = undef
354 }
355 else {
356 11 $row{$col} = $self->_generate_value($col, $info, $n, $unique{$col})
357 }
358 11 next;
359 }
360  
361 90 $row{$col} = $self->_generate_value($col, $info, $n, $unique{$col});
362 }
363 18 push @rows, \%row;
364 }
365  
366 5 $self->_insert_rows($source, $name, \@rows, \@pk_cols, \%inserted_pks);
367 }
368  
369 2 return $self;
370 }
371  
372 =head2 dry_run
373  
374 $mock->dry_run;
375  
376 Prints the values that I<would> be inserted without touching the database.
377 Returns C<$self>.
378  
379 =cut
380  
381 sub dry_run {
382 0 ▶ my ($self) = @_;
Subroutine dry_run: not called CC=7 SCAR=40.3
Pod documented
383 0 my $schema = $self->{_schema};
384  
385 0 my @sources = sort $self->_active_sources($schema->sources);
386 0 for my $name (@sources) {
387 0 my $source = $schema->source($name);
388 0 my @cols = $source->columns;
389 0 my %col_info = map { $_ => $source->column_info($_) } @cols;
390 0 my @pk_cols = $source->primary_columns;
391 0 my %pk_set = map { $_ => 1 } @pk_cols;
392 0 my %unique = $self->_unique_cols($source, \@pk_cols, \%col_info);
393  
394 0 print "\n--- DRY RUN: $name ---\n";
395 0 for my $n (1 .. $self->{rows}) {
396 0 print " Row $n:\n";
397 0 for my $col (@cols) {
398 0 ▶ next if $pk_set{$col} && $self->_is_auto_pk($col_info{$col});
Branch: 1 branch
BranchTrueFalseTotal
if $pk_set{$col} and $self->_is_auto_pk($col_info{$col}) 0 0 0
Condition0%0/3
$pk_set{$col} and $self->_is_auto_pk($col_info{$col})
!ll&&!rl&&r
000
MC/DC0%0/2
$pk_set{$col} and $self->_is_auto_pk($col_info{$col})
$pk_set{$col} $self->_is_auto_pk($col_info{$col})
Truth table0%0/3
A and B
A= $pk_set{$col}B= $self->_is_auto_pk($col_info{$col})
ABresult
0X0
100
111
399 0 my $val = $self->_generate_value($col, $col_info{$col}, $n, $unique{$col});
400 0 ▶ printf " %-30s => %s\n", $col, defined $val ? "'$val'" : 'NULL';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
401 }
402 }
403 }
404 0 return $self;
405 }
406  
407 #
408 #
409 # PRIVATE METHODS
410  
411 sub _unique_cols {
412 5 ▶ my ($self, $source, $pk_cols, $col_info) = @_;
Subroutine _unique_cols: called CC=6 SCAR=17.9
413 5 my %unique;
414  
415 # Non-auto PKs must be unique
416 5 $unique{$_} = 1 for grep { !$self->_is_auto_pk($col_info->{$_}) } @$pk_cols;
417  
418 # Explicit unique constraints (skip 'primary' -- handled above)
419 5 ▶ if ($source->can('unique_constraints')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->can("unique_constraints")) 5 0 5
420 5 my %ucs = $source->unique_constraints;
421 5 for my $name (keys %ucs) {
422 8 ▶ next if $name eq 'primary';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "primary" 5 3 8
423 3 $unique{$_} = 1 for @{ $ucs{$name} };
424 }
425 }
426  
427 5 return %unique;
428 }
429  
430 sub _build_dep_graph {
431 2 ▶ my ($self, $sources) = @_;
Subroutine _build_dep_graph: called CC=8 SCAR=21.2
432 2 my $schema = $self->{_schema};
433 2 my (%deps, %rsrc);
434  
435 2 for my $name (@$sources) {
436 5 my $source = $schema->source($name);
437 5 $rsrc{$name} = $source;
438 5 ▶ $deps{$name} //= [];
Condition50%1/2
$deps{$name} //= []
l!l
05
MC/DC0%0/1
$deps{$name} //= []
$deps{$name}
Truth table50%1/2
A
A= $deps{$name}
Aresult
11
00
439  
440 5 for my $rel ($source->relationships) {
441 6 my $info = $source->relationship_info($rel);
442 6 ▶ next unless $self->_is_belongs_to($info);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_belongs_to($info) 3 3 6
443 3 ▶ my $parent = eval { $source->related_source($rel)->source_name } or next;
Branch: 1 branch
BranchTrueFalseTotal
my $parent = eval { do { $source->related_source($rel)->source_name } } or next 0 3 3
444 3 ▶ next if $parent eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $parent eq $name 0 3 3
445 3 push @{ $deps{$name} }, $parent
446 3 ▶ unless grep { $_ eq $parent } @{ $deps{$name} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $parent;} @{$deps{$name};} 3 0 3
447 }
448 }
449  
450 2 return (\%deps, \%rsrc);
451 }
452  
453 sub _topo_sort {
454 2 ▶ my ($self, $deps, $nodes) = @_;
Subroutine _topo_sort: called CC=8 SCAR=20.8
455 2 my %in = map { $_ => 0 } @$nodes;
456 2 my %adj;
457  
458 2 for my $node (@$nodes) {
459 5 for my $dep (@{ $deps->{$node} }) {
460 3 ▶ next unless exists $in{$dep};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $in{$dep} 0 3 3
461 3 $in{$node}++;
462 3 push @{ $adj{$dep} }, $node;
463 }
464 }
465  
466 2 my @queue = sort grep { $in{$_} == 0 } @$nodes;
467 2 my @result;
468 2 ▶ while (@queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (@queue) 5 2 7
469 5 my $n = shift @queue;
470 5 push @result, $n;
471 5 ▶ push @queue, $_ for grep { --$in{$_} == 0 } @{ $adj{$n} // [] };
Condition100%2/2
$adj{$n} // []
l!l
32
MC/DC100%1/1
$adj{$n} // []
$adj{$n}
Truth table100%2/2
A
A= $adj{$n}
Aresult
11
00
472 }
473  
474 # Append remaining nodes (cycle members -- best effort)
475 2 my %seen = map { $_ => 1 } @result;
476 2 push @result, $_ for grep { !$seen{$_} } @$nodes;
477 2 return @result;
478 }
479  
480 sub _build_fk_map {
481 5 ▶ my ($self, $source) = @_;
Subroutine _build_fk_map: called CC=6 SCAR=18.0
482 5 my %fk;
483  
484 5 for my $rel ($source->relationships) {
485 6 my $info = $source->relationship_info($rel);
486 6 ▶ next unless $self->_is_belongs_to($info);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_belongs_to($info) 3 3 6
487 3 ▶ my $related = eval { $source->related_source($rel) } or next;
Branch: 1 branch
BranchTrueFalseTotal
my $related = eval { do { $source->related_source($rel) } } or next 0 3 3
488 3 my $cond = $info->{cond};
489 3 ▶ next unless ref($cond) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cond eq "HASH" 0 3 3
490 3 ▶ while (my ($fcol, $scol) = each %$cond) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$cond) 3 3 6
491 3 $scol =~ s/^self\.//;
492 3 $fcol =~ s/^foreign\.//;
493 3 $fk{$scol} = { source => $related->source_name, col => $fcol };
494 }
495 }
496  
497 5 return %fk;
498 }
499  
500 sub _is_belongs_to {
501 12 ▶ my ($self, $info) = @_;
Subroutine _is_belongs_to: called CC=10 SCAR=28.0
502 12 ▶ my $a = $info->{attrs} // {};
Condition50%1/2
$info->{"attrs"} // {}
l!l
120
MC/DC0%0/1
$info->{"attrs"} // {}
$info->{"attrs"}
Truth table50%1/2
A
A= $info->{"attrs"}
Aresult
11
00
503 12 ▶ return 1 if ($a->{accessor} // '') eq 'single' && ($a->{is_foreign_key_constraint} // 0);
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"accessor"} // "") eq "single" and $a->{"is_foreign_key_constraint"} // 0 6 6 12
Condition57%4/7
($a->{"accessor"} // "") eq "single" and $a->{"is_foreign_key_constraint"} // 0
!ll&&!rl&&r
606
$a->{"accessor"} // ""
l!l
120
$a->{"is_foreign_key_constraint"} // 0
l!l
60
MC/DC0%0/2
($a->{"accessor"} // "") eq "single" and $a->{"is_foreign_key_constraint"} // 0
$a->{"accessor"} $a->{"is_foreign_key_constraint"}
Truth table33%1/3
A and B
A= $a->{"accessor"}B= $a->{"is_foreign_key_constraint"}
ABresult
0X0
100
111
504 6 ▶ return 1 if ($a->{accessor} // '') eq 'single' && !($a->{join_type} // '');
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"accessor"} // "") eq "single" and not $a->{"join_type"} // "" 0 6 6
Condition28%2/7
($a->{"accessor"} // "") eq "single" and not $a->{"join_type"} // ""
!ll&&!rl&&r
600
$a->{"accessor"} // ""
l!l
60
$a->{"join_type"} // ""
l!l
00
MC/DC0%0/2
($a->{"accessor"} // "") eq "single" and not $a->{"join_type"} // ""
$a->{"accessor"} $a->{"join_type"}
Truth table0%0/3
A and not(B)
A= $a->{"accessor"}B= $a->{"join_type"}
ABresult
0X0
110
101
505 6 return 0;
506 }
507  
508 sub _is_auto_pk {
509 23 ▶ my ($self, $info) = @_;
Subroutine _is_auto_pk: called CC=7 SCAR=22.1
510 23 ▶ return 1 if lc($info->{data_type} // '') =~ /\b(serial|bigserial|autoincrement)\b/;
Branch: 1 branch
BranchTrueFalseTotal
if lc($info->{"data_type"} // "") =~ /\b(serial|bigserial|autoincrement)\b/ 0 23 23
Condition50%1/2
$info->{"data_type"} // ""
l!l
230
MC/DC0%0/1
$info->{"data_type"} // ""
$info->{"data_type"}
Truth table50%1/2
A
A= $info->{"data_type"}
Aresult
11
00
511 23 ▶ return 1 if ($info->{extra}{auto_increment} // 0);
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"extra"}{"auto_increment"} // 0 0 23 23
Condition50%1/2
$info->{"extra"}{"auto_increment"} // 0
l!l
023
MC/DC0%0/1
$info->{"extra"}{"auto_increment"} // 0
$info->{"extra"}{"auto_increment"}
Truth table50%1/2
A
A= $info->{"extra"}{"auto_increment"}
Aresult
11
00
512 23 ▶ return 1 if ($info->{sequence} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"sequence"} // "" 0 23 23
Condition50%1/2
$info->{"sequence"} // ""
l!l
023
MC/DC0%0/1
$info->{"sequence"} // ""
$info->{"sequence"}
Truth table50%1/2
A
A= $info->{"sequence"}
Aresult
11
00
513 23 return 0;
514 }
515  
516 sub _generate_value {
517 101 ▶ my ($self, $col, $info, $n, $is_unique) = @_;
Subroutine _generate_value: called CC=24 SCAR=35.1
518 101 my $salt = $self->{_salt};
519 101 ▶ my $dtype = lc($info->{data_type} // '');
Condition50%1/2
$info->{"data_type"} // ""
l!l
1010
MC/DC0%0/1
$info->{"data_type"} // ""
$info->{"data_type"}
Truth table50%1/2
A
A= $info->{"data_type"}
Aresult
11
00
520 101 ▶ my $size = $info->{size} // 255;
Condition100%2/2
$info->{"size"} // 255
l!l
4457
MC/DC100%1/1
$info->{"size"} // 255
$info->{"size"}
Truth table100%2/2
A
A= $info->{"size"}
Aresult
11
00
521 101 ▶ $size = ref($size) eq 'ARRAY' ? $size->[0] : ($size || 255);
Branch: 1 branch
BranchTrueFalseTotal
ref $size eq 'ARRAY' ? : 7 94 101
Condition50%1/2
$size or 255
l!l
940
MC/DC0%0/1
$size or 255
$size
Truth table50%1/2
A
A= $size
Aresult
11
00
522  
523 101 ▶ return undef if !$is_unique && ($info->{is_nullable} // 0) && int(rand(6)) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if not $is_unique and $info->{"is_nullable"} // 0 and int rand 6 == 0 9 92 101
Condition100%8/8
not $is_unique and $info->{"is_nullable"} // 0 and int rand 6 == 0
!ll&&!rl&&r
77159
not $is_unique and $info->{"is_nullable"} // 0
!ll&&!rl&&r
294824
$info->{"is_nullable"} // 0
l!l
6012
MC/DC100%3/3
not $is_unique and $info->{"is_nullable"} // 0 and int rand 6 == 0
not $is_unique $info->{"is_nullable"} int rand 6 == 0
Truth table100%4/4
not(A) and B and C
A= not $is_uniqueB= $info->{"is_nullable"}C= int rand 6 == 0
ABCresult
0XX0
10X0
1100
1111
524  
525 92 ▶ if (my $gen = $self->{generators}{$col}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gen = $self->{"generators"}{$col}) 0 92 92
526 0 return $gen->($col, $info, $n, $self);
527 }
528  
529 92 ▶ if ($dtype =~ /\b(int|integer|bigint|smallint|tinyint|serial|bigserial)\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(int|integer|bigint|smallint|tinyint|serial|bigserial)\b/) 33 59 92
530 33 ▶ return $is_unique ? $salt + $n : int(rand(999_999)) + 1;
Branch: 1 branch
BranchTrueFalseTotal
$is_unique ? : 18 15 33
531 }
532 59 ▶ if ($dtype =~ /\b(numeric|decimal|float|double|real|money)\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(numeric|decimal|float|double|real|money)\b/) 7 52 59
533 7 return sprintf '%.2f', rand(10_000);
534 }
535 52 ▶ if ($dtype =~ /\b(bool|boolean|tinyint\(1\))\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(bool|boolean|tinyint\(1\))\b/) 4 48 52
536 4 return int(rand(2));
537 }
538 48 ▶ if ($dtype =~ /\b(datetime|timestamp)\b/) { # before bare 'date'
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(datetime|timestamp)\b/) 4 44 48
539 4 return $self->_rand_datetime;
540 }
541 44 ▶ if ($dtype =~ /\bdate\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\bdate\b/) 1 43 44
542 1 return $self->_rand_date;
543 }
544 43 ▶ if ($dtype =~ /\btime\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\btime\b/) 0 43 43
545 0 return sprintf '%02d:%02d:%02d', int(rand(24)), int(rand(60)), int(rand(60));
546 }
547 43 ▶ if ($dtype =~ /\buuid\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\buuid\b/) 0 43 43
548 return sprintf '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
549 0 map { int(rand(0x10000)) } 1 .. 8;
550 }
551 43 ▶ if ($dtype =~ /\bjsonb?\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\bjsonb?\b/) 0 43 43
552 0 return qq({"generated":true,"row":$n});
553 }
554 43 ▶ if ($dtype =~ /\[\]$/ || $dtype =~ /^array/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\[\]$/ or $dtype =~ /^array/) 0 43 43
Condition33%1/3
$dtype =~ /\[\]$/ or $dtype =~ /^array/
l!l&&r!l&&!r
0043
MC/DC0%0/2
$dtype =~ /\[\]$/ or $dtype =~ /^array/
$dtype =~ /\[\]$/ $dtype =~ /^array/
Truth table33%1/3
A or B
A= $dtype =~ /\[\]$/B= $dtype =~ /^array/
ABresult
1X1
011
000
555 0 return '{value1,value2}';
556 }
557 43 ▶ if ($dtype =~ /\b(text|varchar|character varying|char|nvarchar|nchar|string|citext|tinytext|mediumtext|longtext)\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(text|varchar|character varying|char|nvarchar|nchar|string|citext|tinytext|mediumtext|longtext)\b/) 43 0 43
558 43 ▶ return $self->_contextual_string($col, $n, int($size) || 255, $is_unique);
Condition50%1/2
int $size || 255
l!l
430
MC/DC0%0/1
int $size || 255
int $size
Truth table50%1/2
A
A= int $size
Aresult
11
00
559 }
560  
561 0 ▶ return $is_unique ? "${col}_${n}_${salt}" : "${col}_${n}";
Branch: 1 branch
BranchTrueFalseTotal
$is_unique ? : 0 0 0
562 }
563  
564 sub _contextual_string {
565 43 ▶ my ($self, $col, $n, $max, $is_unique) = @_;
Subroutine _contextual_string: called CC=4 SCAR=16.8
566 43 my $salt = $self->{_salt};
567 43 ▶ my $u = $is_unique ? "_${salt}" : '';
Branch: 1 branch
BranchTrueFalseTotal
$is_unique ? : 11 32 43
568  
569 my @templates = (
570 [ qr/\b(first_?name|fname)\b/i,
571 4 ▶ sub { (qw(Alice Bob Carol Dave Eve Frank Grace Hank Iris Jack))[$_[0]%10].$u }],
Subroutine __ANON__: called CC=1 SCAR=0.0
572 [ qr/\b(last_?name|lname|surname)\b/i,
573 4 ▶ sub { (qw(Smith Jones Taylor Brown Wilson Davies Evans Thomas Roberts))[$_[0]%9].$u }],
Subroutine __ANON__: called CC=1 SCAR=0.0
574 [ qr/\bname\b/i,
575 3 ▶ sub { "Name $_[0]$u" }],
Subroutine __ANON__: called CC=1 SCAR=0.0
576 [ qr/\b(username|login)\b/i,
577 0 ▶ sub { "user$_[0]$u" }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
578 [ qr/\bemail\b/i,
579 7 ▶ sub { "user$_[0]${u}\@example.com" }],
Subroutine __ANON__: called CC=1 SCAR=0.0
580 [ qr/\b(phone|mobile|fax)\b/i,
581 0 ▶ sub { sprintf '+1555%04d%04d', $salt%10000, $_[0] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
582 [ qr/\b(street|address|addr)\b/i,
583 0 ▶ sub { "$_[0]$u Main Street" }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
584 [ qr/\b(city|town)\b/i,
585 0 ▶ sub { (qw(London Paris Berlin Madrid Rome Amsterdam Brussels Vienna))[$_[0]%8] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
586 [ qr/\bcountry\b/i,
587 0 ▶ sub { (qw(UK US DE FR ES IT NL AT))[$_[0]%8] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
588 [ qr/\b(zip|postcode|postal)\b/i,
589 0 ▶ sub { sprintf '%05d', (10000+$_[0]+$salt)%99999 }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
590 [ qr/\b(state|province|region)\b/i,
591 0 ▶ sub { (qw(CA NY TX FL WA IL PA OH))[$_[0]%8] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
592 [ qr/\b(description|desc|summary|notes?|comment|body|content)\b/i,
593 3 ▶ sub { "Sample text for record $_[0] (run $salt)." }],
Subroutine __ANON__: called CC=1 SCAR=0.0
594 [ qr/\b(title|heading|subject)\b/i,
595 4 ▶ sub { "Title $_[0]$u" }],
Subroutine __ANON__: called CC=1 SCAR=0.0
596 [ qr/\bslug\b/i,
597 4 ▶ sub { "slug-$_[0]$u" }],
Subroutine __ANON__: called CC=1 SCAR=0.0
598 [ qr/\b(code|ref|reference)\b/i,
599 0 ▶ sub { sprintf 'CODE%04d%s', $_[0], $u }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
600 [ qr/\bsku\b/i,
601 0 ▶ sub { sprintf 'SKU%04d%s', $_[0], $u }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
602 [ qr/\b(token|secret|key|hash)\b/i,
603 0 ▶ sub { sprintf '%016x%08x', $salt, $_[0] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
604 [ qr/\b(url|link|href|website)\b/i,
605 0 ▶ sub { "https://example.com/item/$_[0]$u" }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
606 [ qr/\b(status|state)\b/i,
607 3 ▶ sub { (qw(active inactive pending approved rejected))[$_[0]%5] }],
Subroutine __ANON__: called CC=1 SCAR=0.0
608 [ qr/\b(type|kind|category|cat)\b/i,
609 0 ▶ sub { (qw(typeA typeB typeC typeD))[$_[0]%4] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
610 [ qr/\b(colour|color)\b/i,
611 0 ▶ sub { (qw(red green blue yellow purple orange))[$_[0]%6] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
612 [ qr/\b(lang|language|locale)\b/i,
613 0 ▶ sub { (qw(en fr de es it nl pt))[$_[0]%7] }],
Subroutine __ANON__: not called CC=1 SCAR=6.9
614 [ qr/\b(version|ver)\b/i,
615 43 ▶ sub { "1.$_[0].0" }],
Subroutine __ANON__: not called CC=1 SCAR=1.2
616 );
617  
618 43 for my $t (@templates) {
619 510 ▶ return substr($t->[1]->($n), 0, $max) if $col =~ $t->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $col =~ /$t->[0]/ 32 478 510
620 }
621 11 return substr("${col}_${n}${u}", 0, $max);
622 }
623  
624 sub _insert_rows {
625 5 ▶ my ($self, $source, $name, $rows, $pk_cols, $inserted_pks) = @_;
Subroutine _insert_rows: called CC=3 SCAR=13.6
626  
627 5 my $rs = $self->{_schema}->resultset($name);
628  
629 5 eval { $rs->populate($rows) };
630  
631 5 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 5 0 5
632 5 warn "[WARN] Bulk insert failed for $name: $@\n";
633 5 return;
634 }
635  
636 0 my @inserted = $rs->search({}, { rows => scalar(@$rows) });
637  
638 0 for my $row (@inserted) {
639 0 push @{ $inserted_pks->{$name} },
640 0 { map { $_ => $row->get_column($_) } @$pk_cols };
641 }
642  
643 0 $self->_log("Inserted " . scalar(@$rows) . " rows into $name");
644 }
645  
646 sub _rand_date {
647 1 ▶ my @y = (2020..2024);
Subroutine _rand_date: called CC=1 SCAR=0.0
648 1 sprintf '%d-%02d-%02d', $y[rand@y], rand(12)+1, rand(28)+1;
649 }
650  
651 sub _rand_datetime {
652 4 ▶ my @y = (2020..2024);
Subroutine _rand_datetime: called CC=1 SCAR=0.0
653 4 sprintf '%d-%02d-%02d %02d:%02d:%02d',
654 $y[rand@y], rand(12)+1, rand(28)+1, rand(24), rand(60), rand(60);
655 }
656  
657 13 ▶sub _log { print "[INFO] $_[1]\n"; }
Subroutine _log: called CC=1 SCAR=0.0
658 5 ▶sub _debug { print "[DEBUG] $_[1]\n" if $_[0]->{verbose} }
Subroutine _debug: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]{"verbose"} 0 5 5
659  
660 =head1 GENERATED VALUES
661  
662 Values are produced from each column's declared C<data_type>:
663  
664 integer / bigint / serial random integer (unique: salt + row_num)
665 numeric / decimal / float random decimal (2 d.p.)
666 boolean 0 or 1
667 datetime / timestamp random datetime 2020-2024
668 date random date 2020-2024
669 time random HH:MM:SS
670 uuid random UUID-shaped hex string
671 json / jsonb {"generated":true,"row":N}
672 text / varchar / char contextual string matched on column name
673 unknown / blank dtype colname_N (colname_N_SALT if unique)
674  
675 Nullable columns receive NULL roughly 17% of the time (never for unique cols).
676  
677 =head1 CONFIGURATION OPTIONS
678  
679 =head2 rows_per_table
680  
681 rows_per_table => { Author => 10, Book => 3 }
682  
683 Allows you to specify different numbers of rows for specific tables. Any table
684 not listed in this hash will use the global C<rows> value. This is useful when
685 you need more data for certain tables (e.g., Authors) and less for others.
686  
687 =head2 generators
688  
689 generators => {
690 email => sub { "user".int(rand(1000))."\@example.com" },
691 status => sub { "active" },
692 }
693  
694 Provides custom value generators for specific columns. The generator subroutine
695 receives four arguments:
696  
697 =over 4
698  
699 =item C<$col> - The column name
700  
701 =item C<$info> - The column info hashref from the result source
702  
703 =item C<$n> - The current row number (1-based)
704  
705 =item C<$mock> - The MockData object instance (provides access to C<_salt> etc.)
706  
707 =back
708  
709 The generator should return a scalar value appropriate for the column. This
710 overrides the default value generation for that column.
711  
712 Examples:
713  
714 # Static value for all rows
715 status => sub { 'active' }
716  
717 # Value based on row number
718 code => sub { my ($col, $info, $n) = @_; "CODE_$n" }
719  
720 # Value using the instance salt for uniqueness
721 token => sub { my ($col, $info, $n, $mock) = @_; "token_${n}_$mock->{_salt}" }
722  
723 # Conditional logic
724 email => sub {
725 my ($col, $info, $n) = @_;
726 return $n == 1 ? 'admin@example.com' : "user$n\@example.com";
727 }
728  
729 =head1 PERFORMANCE IMPROVEMENTS
730  
731 Version 0.04 introduces significant performance optimisations:
732  
733 =head2 Bulk Insert Mode
734  
735 Previously, rows were inserted one at a time using C<< $rs->create() >>, which
736 could be slow for large datasets. The module now uses C<< $rs->populate() >> to
737 insert all rows in a single batch operation. This results in:
738  
739 =over 4
740  
741 =item * Up to 10x faster insertions for large datasets
742  
743 =item * Reduced database round-trips
744  
745 =item * Maintained foreign key integrity
746  
747 =back
748  
749 =head2 Smarter Salt Generation
750  
751 When a C<seed> is provided for reproducible output, the salt value is now
752 randomised while still producing consistent results. This ensures:
753  
754 =over 4
755  
756 =item * Reproducible test data across runs (with same seed)
757  
758 =item * Unique values across different test runs (different salts)
759  
760 =item * No accidental collisions when running tests in parallel
761  
762 =back
763  
764 =head2 Unique Constraint Handling
765  
766 The module now properly respects:
767  
768 =over 4
769  
770 =item * Primary key uniqueness (except auto-increment columns)
771  
772 =item * Named unique constraints from L<DBIx::Class>
773  
774 =item * Multi-column unique constraints
775  
776 =back
777  
778 Values for unique columns are automatically salted to ensure uniqueness
779 without manual intervention.
780  
781 =head1 CLI TOOL
782  
783 This distribution ships with a command-line tool B<dbic-mockdata> in the
784 C<script/> directory, installed into your C<PATH> by C<make install>.
785  
786 dbic-mockdata --schema-dir t/lib --namespace MyApp::Schema \
787 --dsn "dbi:SQLite:dbname=test.db" --deploy --rows 5
788  
789 Run C<dbic-mockdata --help> for the full list of options, or see
790 L<dbic-mockdata> for the complete manual.
791  
792 =head1 DEPENDENCIES
793  
794 L<DBIx::Class>, L<Carp>, L<File::Spec>, L<Scalar::Util>
795  
796 =head1 AUTHOR
797  
798 Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >>
799  
800 =head1 REPOSITORY
801  
802 L<https://github.com/manwar/DBIx-Class-MockData>
803  
804 =head1 BUGS
805  
806 Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/DBIx-Class-MockData/issues>.
807 I will be notified and then you'll automatically be notified of progress on your
808 bug as I make changes.
809  
810 =head1 SUPPORT
811  
812 You can find documentation for this module with the perldoc command.
813  
814 perldoc DBIx::Class::MockData
815  
816 You can also look for information at:
817  
818 =over 4
819  
820 =item * BUG Report
821  
822 L<https://github.com/manwar/DBIx-Class-MockData/issues>
823  
824 =item * CPAN Ratings
825  
826 L<http://cpanratings.perl.org/d/DBIx-Class-MockData>
827  
828 =item * Search MetaCPAN
829  
830 L<https://metacpan.org/dist/DBIx-Class-MockData/>
831  
832 =back
833  
834 =head1 LICENSE AND COPYRIGHT
835  
836 Copyright (C) 2026 Mohammad Sajid Anwar.
837  
838 This program is free software; you can redistribute it and / or modify it under
839 the terms of the the Artistic License (2.0). You may obtain a copy of the full
840 license at:
841 L<http://www.perlfoundation.org/artistic_license_2_0>
842 Any use, modification, and distribution of the Standard or Modified Versions is
843 governed by this Artistic License.By using, modifying or distributing the Package,
844 you accept this license. Do not use, modify, or distribute the Package, if you do
845 not accept this license.
846 If your Modified Version has been derived from a Modified Version made by someone
847 other than you,you are nevertheless required to ensure that your Modified Version
848 complies with the requirements of this license.
849 This license does not grant you the right to use any trademark, service mark,
850 tradename, or logo of the Copyright Holder.
851 This license includes the non-exclusive, worldwide, free-of-charge patent license
852 to make, have made, use, offer to sell, sell, import and otherwise transfer the
853 Package with respect to any patent claims licensable by the Copyright Holder that
854 are necessarily infringed by the Package. If you institute patent litigation
855 (including a cross-claim or counterclaim) against any party alleging that the
856 Package constitutes direct or contributory patent infringement,then this Artistic
857 License to you shall terminate on the date that such litigation is filed.
858 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
859 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
860 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
861 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
862 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
863 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
864 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
865  
866 =cut
867  
868 5 1; # End of DBIx::Class::MockData
↑ Summary