blib/lib/DBIx/Class/MockData.pm

filter: Statementstmt 57.5% 266 / 462 Branchbran 42.9% 103 / 240 Conditioncond 49.5% 52 / 105 MC/DCmcdc 16.3% 9 / 55 Subroutinesub 58.1% 32 / 55 Podpod 83.3% 5 / 6 totaltotal 50.6% 467 / 923 CC 186 SCAR 39.4
CC
186
Cov
52%
new
196.6
__ANON__
72.0
dry_run
56.0
CRAP 51.3
↑ Summary
1 package DBIx::Class::MockData;
2  
3 6 $DBIx::Class::MockData::VERSION = '0.05';
4 6 $DBIx::Class::MockData::AUTHORITY = 'cpan:MANWAR';
5  
6 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶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.05
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 # Fast data refresh (recommended for most test scenarios)
35 DBIx::Class::MockData
36 ->new(
37 schema => $schema,
38 schema_dir => 't/lib',
39 rows => 10,
40 )
41 ->truncate # Empties tables quickly, preserves structure
42 ->generate;
43  
44 # Complete schema reset (use sparingly)
45 DBIx::Class::MockData
46 ->new(
47 schema => $schema,
48 schema_dir => 't/lib',
49 rows => 10,
50 verbose => 1,
51 seed => 42,
52 )
53 ->wipe # Destructive: drops and recreates tables
54 ->generate;
55  
56 # Populate only selected tables
57 DBIx::Class::MockData
58 ->new(
59 schema => $schema,
60 schema_dir => 't/lib',
61 only => [qw(Author Book)],
62 )
63 ->truncate
64 ->generate;
65  
66 # Populate all tables except selected ones
67 DBIx::Class::MockData
68 ->new(
69 schema => $schema,
70 schema_dir => 't/lib',
71 exclude => [qw(AuditLog SessionToken)],
72 )
73 ->truncate
74 ->generate;
75  
76 # Use custom generators for specific columns
77 DBIx::Class::MockData
78 ->new(
79 schema => $schema,
80 schema_dir => 't/lib',
81 generators => {
82 email => sub { "user".int(rand(1000))."\@example.com" },
83 status => sub { "active" },
84 created_at => sub {
85 my ($col, $info, $n, $mock) = @_;
86 return DateTime->now->datetime;
87 },
88 }
89 )
90 ->truncate
91 ->generate;
92  
93 # Set different row counts per table
94 DBIx::Class::MockData
95 ->new(
96 schema => $schema,
97 schema_dir => 't/lib',
98 rows => 5, # default for all tables
99 rows_per_table => {
100 Author => 10, # override for Author
101 Book => 3, # override for Book
102 },
103 )
104 ->truncate
105 ->generate;
106  
107 # Preview data without inserting
108 DBIx::Class::MockData
109 ->new(
110 schema => $schema,
111 schema_dir => 't/lib',
112 rows => 3,
113 )
114 ->dry_run; # Prints generated values, no database changes
115  
116 =head1 DESCRIPTION
117  
118 Accepts a connected L<DBIx::Class::Schema> object, the return value of
119 C<< YourSchema->connect(...) >>, introspects every result source, resolves
120 foreign-key insertion order via topological sort, and inserts randomly
121 generated rows. Values are produced from each column's declared
122 C<data_type>. Unique and primary-key columns are salted with a per-run
123 random value to avoid cross-run collisions.
124  
125 Connection and schema loading are entirely the caller's responsibility.
126 C<schema_dir> is accepted only to ensure the lib root is present in C<@INC>
127 so result classes remain resolvable at runtime.
128  
129 All public methods return C<$self>, enabling call chaining.
130  
131 =head1 METHODS
132  
133 =cut
134  
135 6 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
136 6 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
137 6 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
138 6 ▶use UUID::Tiny qw(:std);
Subroutine BEGIN: called CC=1 SCAR=0.0
139 6 ▶use feature qw(state);
Subroutine BEGIN: called CC=1 SCAR=0.0
140  
141 =head1 CONSTRUCTOR
142  
143 my $mock = DBIx::Class::MockData->new(
144 schema => $connected_schema, # required
145 schema_dir => 't/lib', # required
146 rows => 5, # rows per table (default: 5)
147 verbose => 0, # debug output (default: 0)
148 seed => 42, # random seed (optional)
149 );
150  
151 B<ARGUMENTS>
152  
153 =over 4
154  
155 =item schema B<(required)>
156  
157 A connected L<DBIx::Class::Schema> instance - the return value of
158 C<< YourSchema->connect(...) >>.
159  
160 =item schema_dir B<(required)>
161  
162 The lib root containing your schema classes. Added to C<@INC> so result
163 classes referenced by relationships remain resolvable.
164  
165 =item rows
166  
167 Number of rows to generate per table. Default: C<5>.
168  
169 =item verbose
170  
171 Print debug output. Default: C<0>.
172  
173 =item seed
174  
175 Integer seed passed to C<srand> for reproducible output. Optional.
176  
177 =item only
178  
179 Array reference of source names to populate. When supplied, only the listed
180 tables are processed (in FK-safe order). Cannot be combined with C<exclude>.
181  
182 only => [qw(Author Book)]
183  
184 =item exclude
185  
186 Array reference of source names to skip. All other tables are populated.
187 Cannot be combined with C<only>.
188  
189 exclude => [qw(AuditLog SessionToken)]
190  
191 =back
192  
193 =cut
194  
195 sub new {
196 11 ▶ my ($class, %args) = @_;
Subroutine new: called CC=45 SCAR=52.8
Pod undocumented
197  
198 croak "schema is required"
199 11 ▶ unless $args{schema};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"schema"} 1 10 11
200 croak "schema must be a DBIx::Class::Schema instance"
201 10 ▶ 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 9 10
Condition66%2/3
builtin::blessed($args{"schema"}) and $args{"schema"}->isa("DBIx::Class::Schema")
!ll&&!rl&&r
109
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
202 croak "schema_dir is required"
203 9 ▶ unless $args{schema_dir};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"schema_dir"} 1 8 9
204  
205 8 my $dir = File::Spec->rel2abs($args{schema_dir});
206 8 ▶ croak "schema_dir '$dir' does not exist" unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 8 8
207 8 ▶ push @INC, $dir unless grep { $_ eq $dir } @INC;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $dir;} @INC 5 3 8
208  
209 croak "only and exclude cannot both be specified"
210 8 ▶ if $args{only} && $args{exclude};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"only"} and $args{"exclude"} 0 8 8
Condition33%1/3
$args{"only"} and $args{"exclude"}
!ll&&!rl&&r
800
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
211 croak "only must be an arrayref"
212 8 ▶ if $args{only} && ref($args{only}) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $args{"only"} and ref $args{"only"} ne "ARRAY" 0 8 8
Condition33%1/3
$args{"only"} and ref $args{"only"} ne "ARRAY"
!ll&&!rl&&r
800
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
213 croak "exclude must be an arrayref"
214 8 ▶ if $args{exclude} && ref($args{exclude}) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $args{"exclude"} and ref $args{"exclude"} ne "ARRAY" 0 8 8
Condition33%1/3
$args{"exclude"} and ref $args{"exclude"} ne "ARRAY"
!ll&&!rl&&r
800
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
215  
216 # Validate numeric arguments
217 8 ▶ if (defined $args{rows}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"rows"}) 6 2 8
218 croak "rows must be a positive integer"
219 6 ▶ unless $args{rows} =~ /^\d+$/ && $args{rows} > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"rows"} =~ /^\d+$/ and $args{"rows"} > 0 0 6 6
Condition33%1/3
$args{"rows"} =~ /^\d+$/ and $args{"rows"} > 0
!ll&&!rl&&r
006
MC/DC0%0/2
$args{"rows"} =~ /^\d+$/ and $args{"rows"} > 0
$args{"rows"} =~ /^\d+$/ $args{"rows"} > 0
Truth table33%1/3
A and B
A= $args{"rows"} =~ /^\d+$/B= $args{"rows"} > 0
ABresult
0X0
100
111
220 }
221  
222 8 ▶ if (defined $args{seed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"seed"}) 2 6 8
223 croak "seed must be a positive integer"
224 2 ▶ unless $args{seed} =~ /^\d+$/ && $args{seed} > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"seed"} =~ /^\d+$/ and $args{"seed"} > 0 0 2 2
Condition33%1/3
$args{"seed"} =~ /^\d+$/ and $args{"seed"} > 0
!ll&&!rl&&r
002
MC/DC0%0/2
$args{"seed"} =~ /^\d+$/ and $args{"seed"} > 0
$args{"seed"} =~ /^\d+$/ $args{"seed"} > 0
Truth table33%1/3
A and B
A= $args{"seed"} =~ /^\d+$/B= $args{"seed"} > 0
ABresult
0X0
100
111
225 }
226  
227 8 ▶ if (defined $args{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"verbose"}) 0 8 8
228 croak "verbose must be 0 or 1"
229 0 ▶ unless $args{verbose} =~ /^[01]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"verbose"} =~ /^[01]$/ 0 0 0
230 }
231  
232 # Validate rows_per_table if provided
233 8 ▶ if (defined $args{rows_per_table}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"rows_per_table"}) 1 7 8
234 croak "rows_per_table must be a hashref"
235 1 ▶ unless ref($args{rows_per_table}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"rows_per_table"} eq "HASH" 0 1 1
236  
237 1 ▶ while (my ($table, $count) = each %{ $args{rows_per_table} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$args{"rows_per_table"};}) 1 1 2
238 1 ▶ croak "rows_per_table value for '$table' must be a positive integer"
Branch: 1 branch
BranchTrueFalseTotal
unless $count =~ /^\d+$/ and $count > 0 0 1 1
Condition33%1/3
$count =~ /^\d+$/ and $count > 0
!ll&&!rl&&r
001
MC/DC0%0/2
$count =~ /^\d+$/ and $count > 0
$count =~ /^\d+$/ $count > 0
Truth table33%1/3
A and B
A= $count =~ /^\d+$/B= $count > 0
ABresult
0X0
100
111
239 unless $count =~ /^\d+$/ && $count > 0;
240 }
241 }
242  
243 # Validate generators if provided
244 8 ▶ if (defined $args{generators}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"generators"}) 0 8 8
245 croak "generators must be a hashref"
246 0 ▶ unless ref($args{generators}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"generators"} eq "HASH" 0 0 0
247  
248 0 ▶ while (my ($col, $gen) = each %{ $args{generators} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$args{"generators"};}) 0 0 0
249 0 ▶ croak "generator for '$col' must be a code reference or scalar"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $gen eq "CODE" or not ref $gen 0 0 0
Condition0%0/3
ref $gen eq "CODE" or not ref $gen
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $gen eq "CODE" or not ref $gen
ref $gen eq "CODE" not ref $gen
Truth table0%0/3
A or not(B)
A= ref $gen eq "CODE"B= not ref $gen
ABresult
1X1
011
000
250 unless ref($gen) eq 'CODE' || !ref($gen);
251 }
252 }
253  
254 my $self = {
255 _schema => $args{schema},
256 rows => $args{rows} // 5,
257 verbose => $args{verbose} // 0,
258 quiet => $args{quiet} // 0,
259 rows_per_table => $args{rows_per_table} || {},
260 generators => $args{generators} || {},
261 _salt => int(rand(9_000_000)) + 1_000_000,
262 0 ▶ _only => $args{only} ? { map { $_ => 1 } @{ $args{only} } } : undef,
Branch: 1 branch
BranchTrueFalseTotal
$args{'exclude'} ? : 0 8 8
263 8 ▶ _exclude => $args{exclude} ? { map { $_ => 1 } @{ $args{exclude} } } : undef,
Branch: 1 branch
BranchTrueFalseTotal
$args{'only'} ? : 0 8 8
Condition80%8/10
$args{"rows"} // 5
l!l
62
$args{"verbose"} // 0
l!l
08
$args{"quiet"} // 0
l!l
44
$args{'rows_per_table'} || {}
l!l
17
$args{'generators'} || {}
l!l
08
MC/DC100%1/1
$args{"rows"} // 5
$args{"rows"}
MC/DC0%0/1
$args{"verbose"} // 0
$args{"verbose"}
MC/DC100%1/1
$args{"quiet"} // 0
$args{"quiet"}
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{"quiet"}
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
264 };
265  
266 8 ▶ if (defined $args{seed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"seed"}) 2 6 8
267 2 srand($args{seed});
268 2 $self->{_salt} = int(rand(9_000_000)) + 1_000_000;
269 }
270  
271 8 ▶ if (defined $args{start_year}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"start_year"}) 0 8 8
272 croak "start_year must be a 4-digit year"
273 0 ▶ unless $args{start_year} =~ /^\d{4}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"start_year"} =~ /^\d{4}$/ 0 0 0
274 0 $self->{start_year} = $args{start_year};
275 }
276 8 ▶ if (defined $args{end_year}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"end_year"}) 0 8 8
277 croak "end_year must be a 4-digit year"
278 0 ▶ unless $args{end_year} =~ /^\d{4}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"end_year"} =~ /^\d{4}$/ 0 0 0
279 0 $self->{end_year} = $args{end_year};
280 }
281 8 ▶ $self->{start_year} ||= 2010;
Condition50%1/2
$self->{"start_year"} ||= 2010
l!l
08
MC/DC0%0/1
$self->{"start_year"} ||= 2010
$self->{"start_year"}
Truth table50%1/2
A
A= $self->{"start_year"}
Aresult
11
00
282 8 ▶ $self->{end_year} ||= 2026;
Condition50%1/2
$self->{"end_year"} ||= 2026
l!l
08
MC/DC0%0/1
$self->{"end_year"} ||= 2026
$self->{"end_year"}
Truth table50%1/2
A
A= $self->{"end_year"}
Aresult
11
00
283  
284 8 return bless $self, $class;
285 }
286  
287 =head1 METHODS
288  
289 =head2 deploy
290  
291 $mock->deploy;
292 $mock->deploy->generate; # chainable
293  
294 Creates all tables that do not yet exist. Safe to call when some or all
295 tables are already present. Returns C<$self>.
296  
297 =cut
298  
299 sub deploy {
300 5 ▶ my ($self) = @_;
Subroutine deploy: called CC=4 SCAR=20.1
Pod documented
301 5 my $schema = $self->{_schema};
302  
303 5 $self->_log("Deploying schema (creating missing tables)...");
304  
305 5 my $ddl = eval { $schema->deployment_statements };
306 5 ▶ if ($@ || !$ddl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $ddl) { } 5 0 5
Condition33%1/3
$@ or not $ddl
l!l&&r!l&&!r
500
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
307 5 eval { $schema->deploy({ add_drop_table => 0, ignore_errors => 1 }) };
308 5 ▶ croak "Deploy failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 5 0 5
309 }
310 else {
311 $schema->storage->dbh_do(sub {
312 0 ▶ my (undef, $dbh) = @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
313 0 for my $stmt (split /;\s*/m, $ddl) {
314 0 $stmt =~ s/^\s+|\s+$//g;
315 0 ▶ next unless length $stmt;
Branch: 1 branch
BranchTrueFalseTotal
unless length $stmt 0 0 0
316 0 eval { $dbh->do($stmt) };
317 0 ▶ $self->_debug(" Skipped (exists?): " . substr($stmt, 0, 60)) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
318 }
319 0 });
320 }
321  
322 0 $self->_log("Deploy complete");
323 0 return $self;
324 }
325  
326 =head2 truncate
327  
328 $mock->truncate->generate; # chainable
329  
330 Truncates (empties) all tables while preserving table structure.
331 Safer than C<wipe> as it doesn't drop and recreate tables.
332 Returns C<$self>.
333  
334 =cut
335  
336 sub truncate {
337 0 ▶ my ($self) = @_;
Subroutine truncate: not called CC=2 SCAR=17.9
Pod documented
338 0 my $schema = $self->{_schema};
339  
340 0 $self->_log("Truncating all tables...");
341  
342 # Get tables in reverse dependency order to avoid FK issues
343 0 my @all_sources = $schema->sources;
344 0 my @sources = $self->_active_sources(@all_sources);
345 0 my ($deps, $rsrc) = $self->_build_dep_graph(\@sources);
346 0 my @ordered = reverse $self->_topo_sort($deps, \@sources);
347  
348 0 eval {
349 $schema->storage->dbh_do(sub {
350 0 ▶ my (undef, $dbh) = @_;
Subroutine __ANON__: not called CC=8 SCAR=42.8
351 0 for my $name (@ordered) {
352 0 my $source = $schema->source($name);
353 0 my $table = $source->from;
354 0 ▶ $table = $$table if ref($table) eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $table eq "SCALAR" 0 0 0
355  
356 0 $self->_debug(" Truncating: $table");
357  
358 # Different DBs have different truncate syntax
359 0 my $driver = $schema->storage->dbh->{Driver}->{Name};
360 0 ▶ if ($driver eq 'SQLite') {
Branch: 3 branches
BranchTrueFalseTotal
if ($driver eq 'SQLite') { } 0 0 0
elsif ($driver =~ /mysql|mariadb/i) { } 0 0 0
elsif ($driver =~ /postgres|pg/i) { } 0 0 0
361 0 $dbh->do("DELETE FROM $table");
362  
363 # Reset autoincrement sequences if they exist
364 # Check if sqlite_sequence table exists and has entry
365 # for this table
366 0 my $seq_exists = $dbh->selectrow_array(
367 "SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence'"
368 );
369  
370 0 ▶ if ($seq_exists) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seq_exists) 0 0 0
371 0 my $has_seq = $dbh->selectrow_array(
372 "SELECT name FROM sqlite_sequence WHERE name=?", {}, $table
373 );
374 0 ▶ if ($has_seq) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_seq) 0 0 0
375 0 $dbh->do("DELETE FROM sqlite_sequence WHERE name='$table'");
376 }
377 }
378 }
379 elsif ($driver =~ /mysql|mariadb/i) {
380 0 $dbh->do("TRUNCATE TABLE $table");
381 }
382 elsif ($driver =~ /postgres|pg/i) {
383 0 $dbh->do("TRUNCATE TABLE $table RESTART IDENTITY CASCADE");
384 }
385 else {
386 # Fallback
387 0 $dbh->do("DELETE FROM $table");
388 }
389 }
390 0 });
391 };
392 0 ▶ croak "Truncate failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
393  
394 0 $self->_log("Truncate complete");
395 0 return $self;
396 }
397  
398 =head2 wipe
399  
400 $mock->wipe->generate; # chainable
401  
402 Drops B<all> tables then redeploys the schema.
403 B<Destructive -- for test environments only.> Returns C<$self>.
404  
405 =cut
406  
407 sub wipe {
408 0 ▶ my ($self) = @_;
Subroutine wipe: not called CC=3 SCAR=24.8
Pod documented
409 0 my $schema = $self->{_schema};
410 warn "[WARN] wipe() is destructive and drops tables. Consider using truncate() instead.\n"
411 0 ▶ unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
412  
413 0 $self->_log("Wiping all tables...");
414 0 eval {
415 $schema->storage->dbh_do(sub {
416 0 ▶ my (undef, $dbh) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
417 0 for my $src (reverse $schema->sources) {
418 0 my $table = $schema->source($src)->from;
419 0 ▶ $table = $$table if ref($table) eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $table eq "SCALAR" 0 0 0
420 0 $self->_debug(" Dropping: $table");
421 0 $dbh->do("DROP TABLE IF EXISTS $table");
422 }
423 0 });
424 };
425 0 ▶ croak "Wipe failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
426  
427 0 $schema->deploy({ add_drop_table => 0 });
428 0 $self->_log("Wipe and redeploy complete");
429 0 return $self;
430 }
431  
432 =head2 generate
433  
434 $mock->generate;
435  
436 Inserts mock rows into every table respecting FK insertion order, data
437 types, nullability, and uniqueness constraints. Returns C<$self>.
438  
439 =cut
440  
441 sub _active_sources {
442 2 ▶ my ($self, @all) = @_;
Subroutine _active_sources: called CC=5 SCAR=25.9
443 2 my %known = map { $_ => 1 } @all;
444  
445 2 ▶ if ($self->{_only}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_only"}) 0 2 2
446 0 my @unknown = grep { !$known{$_} } keys %{ $self->{_only} };
447 0 ▶ croak "Unknown source(s) in 'only': " . join(', ', sort @unknown) if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 0 0
448 0 return grep { $self->{_only}{$_} } @all;
449 }
450 2 ▶ if ($self->{_exclude}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_exclude"}) 0 2 2
451 0 my @unknown = grep { !$known{$_} } keys %{ $self->{_exclude} };
452 0 ▶ croak "Unknown source(s) in 'exclude': " . join(', ', sort @unknown) if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 0 0
453 0 return grep { !$self->{_exclude}{$_} } @all;
454 }
455 2 return @all;
456 }
457  
458 sub generate {
459 2 ▶ my ($self) = @_;
Subroutine generate: called CC=14 SCAR=27.3
Pod documented
460 2 my $schema = $self->{_schema};
461  
462 2 my @all_sources = $schema->sources;
463 2 ▶ croak "No result sources found in schema" unless @all_sources;
Branch: 1 branch
BranchTrueFalseTotal
unless @all_sources 0 2 2
464  
465 2 my @sources = $self->_active_sources(@all_sources);
466 2 ▶ croak "No sources to populate after applying only/exclude filters" unless @sources;
Branch: 1 branch
BranchTrueFalseTotal
unless @sources 0 2 2
467  
468 2 $self->_log("Found sources: " . join(', ', sort @sources));
469  
470 2 my ($deps, $rsrc) = $self->_build_dep_graph(\@sources);
471 2 my @ordered = $self->_topo_sort($deps, \@sources);
472  
473 2 $self->_log("Insertion order: " . join(' -> ', @ordered));
474  
475 2 my %inserted_pks;
476  
477 2 for my $name (@ordered) {
478 5 $self->_log("\n--- Table: $name ---");
479  
480 5 my $source = $rsrc->{$name};
481 5 my @cols = $source->columns;
482 5 my %col_info = map { $_ => $source->column_info($_) } @cols;
483 5 my @pk_cols = $source->primary_columns;
484 5 my %pk_set = map { $_ => 1 } @pk_cols;
485 5 my %unique = $self->_unique_cols($source, \@pk_cols, \%col_info);
486 5 my %fk = $self->_build_fk_map($source);
487  
488 5 ▶ $self->_debug(" Unique cols: " . join(', ', sort keys %unique)) if %unique;
Branch: 1 branch
BranchTrueFalseTotal
if %unique 5 0 5
489  
490 5 my @rows;
491 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
492 5 for my $n (1 .. $rows) {
493 18 my %row;
494 18 for my $col (@cols) {
495 101 my $info = $col_info{$col};
496 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
497  
498 101 ▶ if (exists $fk{$col}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fk{$col}) 11 90 101
499 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
500 11 ▶ if (@$pool) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$pool) { } 0 11 11
elsif ($info->{'is_nullable'}) { } 0 11 11
501 0 $row{$col} = $pool->[ ($n-1) % @$pool ]{ $fk{$col}{col} };
502 }
503 elsif ($info->{is_nullable}) {
504 0 $row{$col} = undef
505 }
506 else {
507 11 $row{$col} = $self->_generate_value($col, $info, $n, $unique{$col})
508 }
509 11 next;
510 }
511  
512 90 $row{$col} = $self->_generate_value($col, $info, $n, $unique{$col});
513 }
514 18 push @rows, \%row;
515 }
516  
517 5 $self->_insert_rows($source, $name, \@rows, \@pk_cols, \%inserted_pks);
518 }
519  
520 2 return $self;
521 }
522  
523 =head2 dry_run
524  
525 $mock->dry_run;
526  
527 Prints the values that I<would> be inserted without touching the database.
528 Returns C<$self>.
529  
530 =cut
531  
532 sub dry_run {
533 0 ▶ my ($self) = @_;
Subroutine dry_run: not called CC=7 SCAR=40.3
Pod documented
534 0 my $schema = $self->{_schema};
535  
536 0 my @sources = sort $self->_active_sources($schema->sources);
537 0 for my $name (@sources) {
538 0 my $source = $schema->source($name);
539 0 my @cols = $source->columns;
540 0 my %col_info = map { $_ => $source->column_info($_) } @cols;
541 0 my @pk_cols = $source->primary_columns;
542 0 my %pk_set = map { $_ => 1 } @pk_cols;
543 0 my %unique = $self->_unique_cols($source, \@pk_cols, \%col_info);
544  
545 0 print "\n--- DRY RUN: $name ---\n";
546 0 for my $n (1 .. $self->{rows}) {
547 0 print " Row $n:\n";
548 0 for my $col (@cols) {
549 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
550 0 my $val = $self->_generate_value($col, $col_info{$col}, $n, $unique{$col});
551 0 ▶ printf " %-30s => %s\n", $col, defined $val ? "'$val'" : 'NULL';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
552 }
553 }
554 }
555 0 return $self;
556 }
557  
558 #
559 #
560 # PRIVATE METHODS
561  
562 sub _unique_cols {
563 5 ▶ my ($self, $source, $pk_cols, $col_info) = @_;
Subroutine _unique_cols: called CC=6 SCAR=17.9
564 5 my %unique;
565  
566 # Non-auto PKs must be unique
567 5 $unique{$_} = 1 for grep { !$self->_is_auto_pk($col_info->{$_}) } @$pk_cols;
568  
569 # Explicit unique constraints (skip 'primary' -- handled above)
570 5 ▶ if ($source->can('unique_constraints')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->can("unique_constraints")) 5 0 5
571 5 my %ucs = $source->unique_constraints;
572 5 for my $name (keys %ucs) {
573 8 ▶ next if $name eq 'primary';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "primary" 5 3 8
574 3 $unique{$_} = 1 for @{ $ucs{$name} };
575 }
576 }
577  
578 5 return %unique;
579 }
580  
581 sub _build_dep_graph {
582 2 ▶ my ($self, $sources) = @_;
Subroutine _build_dep_graph: called CC=14 SCAR=32.6
583 2 my $schema = $self->{_schema};
584 2 my (%deps, %rsrc);
585  
586 2 for my $name (@$sources) {
587 5 my $source = $schema->source($name);
588 5 $rsrc{$name} = $source;
589 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
590  
591 5 for my $rel ($source->relationships) {
592 6 my $info = $source->relationship_info($rel);
593 6 ▶ my $attrs = $info->{attrs} || {};
Condition50%1/2
$info->{'attrs'} || {}
l!l
60
MC/DC0%0/1
$info->{'attrs'} || {}
$info->{'attrs'}
Truth table50%1/2
A
A= $info->{'attrs'}
Aresult
11
00
594  
595 # Check if this is a foreign key constraint relationship
596 6 ▶ next unless $attrs->{is_foreign_key_constraint};
Branch: 1 branch
BranchTrueFalseTotal
unless $attrs->{"is_foreign_key_constraint"} 3 3 6
597  
598 # belongs_to, has_one, might_have all create FK dependencies
599 # but in different directions
600 3 ▶ my $accessor = $attrs->{accessor} || '';
Condition50%1/2
$attrs->{'accessor'} || ''
l!l
30
MC/DC0%0/1
$attrs->{'accessor'} || ''
$attrs->{'accessor'}
Truth table50%1/2
A
A= $attrs->{'accessor'}
Aresult
11
00
601  
602 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
603 3 ▶ next if $parent eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $parent eq $name 0 3 3
604  
605 3 ▶ if ($accessor eq 'single') {
Branch: 2 branches
BranchTrueFalseTotal
if ($accessor eq 'single') { } 3 0 3
elsif ($accessor eq 'multi') { } 0 0 0
606 # belongs_to - current table depends on parent
607 3 push @{ $deps{$name} }, $parent
608 3 ▶ unless grep { $_ eq $parent } @{ $deps{$name} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $parent;} @{$deps{$name};} 3 0 3
609 }
610 elsif ($accessor eq 'multi') {
611 # has_many - parent depends on current table?
612 # Actually has_many doesn't create FK constraint in current table
613 # So no dependency
614 }
615 else {
616 # might_have, has_one - parent depends on current table?
617 # These create FK in current table pointing to parent
618 # So current table depends on parent
619 0 ▶ if ($attrs->{is_foreign_key_constraint}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attrs->{"is_foreign_key_constraint"}) 0 0 0
620 0 push @{ $deps{$name} }, $parent
621 0 ▶ unless grep { $_ eq $parent } @{ $deps{$name} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $parent;} @{$deps{$name};} 0 0 0
622 }
623 }
624 }
625 }
626  
627 2 return (\%deps, \%rsrc);
628 }
629  
630 sub _topo_sort {
631 2 ▶ my ($self, $deps, $nodes) = @_;
Subroutine _topo_sort: called CC=9 SCAR=22.8
632 2 my %in = map { $_ => 0 } @$nodes;
633 2 my %adj;
634  
635 2 for my $node (@$nodes) {
636 5 for my $dep (@{ $deps->{$node} }) {
637 3 ▶ next unless exists $in{$dep};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $in{$dep} 0 3 3
638 3 $in{$node}++;
639 3 push @{ $adj{$dep} }, $node;
640 }
641 }
642  
643 2 my @queue = sort grep { $in{$_} == 0 } @$nodes;
644 2 my @result;
645 2 ▶ while (@queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (@queue) 5 2 7
646 5 my $n = shift @queue;
647 5 push @result, $n;
648 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
649 }
650  
651 # Check for cycles
652 2 my @remaining = grep { $in{$_} > 0 } @$nodes;
653 2 ▶ if (@remaining) {
Branch: 1 branch
BranchTrueFalseTotal
if (@remaining) 0 2 2
654 0 ▶ if ($self->{ignore_cycles}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ignore_cycles'}) { } 0 0 0
655 # Best effort - append remaining nodes
656 0 push @result, @remaining;
657 }
658 else {
659 0 my $cycle = $self->_find_cycle(\%adj, $remaining[0]);
660 0 croak "Cyclic dependency detected in relationships: " . join(' -> ', @$cycle);
661 }
662 }
663  
664 2 return @result;
665 }
666  
667 sub _find_cycle {
668 0 ▶ my ($self, $adj, $start) = @_;
Subroutine _find_cycle: not called CC=2 SCAR=17.9
669 0 my %seen;
670 my @path;
671  
672 0 my $dfs;
673 $dfs = sub {
674 0 ▶ my $node = shift;
Subroutine __ANON__: not called CC=6 SCAR=37.4
675 0 ▶ return if $seen{$node};
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$node} 0 0 0
676  
677 0 push @path, $node;
678 0 $seen{$node} = scalar @path;
679  
680 0 ▶ for my $next (@{ $adj->{$node} // [] }) {
Condition0%0/2
$adj->{$node} // []
l!l
00
MC/DC0%0/1
$adj->{$node} // []
$adj->{$node}
Truth table0%0/2
A
A= $adj->{$node}
Aresult
11
00
681 0 ▶ if (my $pos = $seen{$next}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pos = $seen{$next}) 0 0 0
682 # Found a cycle
683 0 return [ @path[$pos-1 .. $#path], $next ];
684 }
685 0 my $cycle = $dfs->($next);
686 0 ▶ return $cycle if $cycle;
Branch: 1 branch
BranchTrueFalseTotal
if $cycle 0 0 0
687 }
688  
689 0 pop @path;
690 0 $seen{$node} = 0;
691 0 return undef;
692 0 };
693  
694 0 ▶ return $dfs->($start) || [$start];
Condition0%0/2
&$dfs($start) || [$start]
l!l
00
MC/DC0%0/1
&$dfs($start) || [$start]
&$dfs($start)
Truth table0%0/2
A
A= &$dfs($start)
Aresult
11
00
695 }
696  
697 sub _build_fk_map {
698 5 ▶ my ($self, $source) = @_;
Subroutine _build_fk_map: called CC=6 SCAR=18.0
699 5 my %fk;
700  
701 5 for my $rel ($source->relationships) {
702 6 my $info = $source->relationship_info($rel);
703 6 ▶ next unless $self->_is_belongs_to($info);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_belongs_to($info) 3 3 6
704 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
705 3 my $cond = $info->{cond};
706 3 ▶ next unless ref($cond) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cond eq "HASH" 0 3 3
707 3 ▶ while (my ($fcol, $scol) = each %$cond) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$cond) 3 3 6
708 3 $scol =~ s/^self\.//;
709 3 $fcol =~ s/^foreign\.//;
710 3 $fk{$scol} = { source => $related->source_name, col => $fcol };
711 }
712 }
713  
714 5 return %fk;
715 }
716  
717 sub _is_belongs_to {
718 6 ▶ my ($self, $info) = @_;
Subroutine _is_belongs_to: called CC=10 SCAR=28.0
719 6 ▶ my $a = $info->{attrs} // {};
Condition50%1/2
$info->{"attrs"} // {}
l!l
60
MC/DC0%0/1
$info->{"attrs"} // {}
$info->{"attrs"}
Truth table50%1/2
A
A= $info->{"attrs"}
Aresult
11
00
720 6 ▶ 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 3 3 6
Condition57%4/7
($a->{"accessor"} // "") eq "single" and $a->{"is_foreign_key_constraint"} // 0
!ll&&!rl&&r
303
$a->{"accessor"} // ""
l!l
60
$a->{"is_foreign_key_constraint"} // 0
l!l
30
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
721 3 ▶ 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 3 3
Condition28%2/7
($a->{"accessor"} // "") eq "single" and not $a->{"join_type"} // ""
!ll&&!rl&&r
300
$a->{"accessor"} // ""
l!l
30
$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
722 3 return 0;
723 }
724  
725 sub _is_auto_pk {
726 23 ▶ my ($self, $info) = @_;
Subroutine _is_auto_pk: called CC=7 SCAR=22.1
727 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
728 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
729 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
730 23 return 0;
731 }
732  
733 sub _generate_value {
734 101 ▶ my ($self, $col, $info, $n, $is_unique) = @_;
Subroutine _generate_value: called CC=24 SCAR=34.8
735 101 my $salt = $self->{_salt};
736 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
737 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
738 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
739  
740 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 4 97 101
Condition100%8/8
not $is_unique and $info->{"is_nullable"} // 0 and int rand 6 == 0
!ll&&!rl&&r
77204
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
741  
742 97 ▶ if (my $gen = $self->{generators}{$col}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gen = $self->{"generators"}{$col}) 0 97 97
743 0 return $gen->($col, $info, $n, $self);
744 }
745  
746 97 ▶ 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 64 97
747 33 ▶ return $is_unique ? $salt + $n : int(rand(999_999)) + 1;
Branch: 1 branch
BranchTrueFalseTotal
$is_unique ? : 18 15 33
748 }
749 64 ▶ 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 57 64
750 7 return sprintf '%.2f', rand(10_000);
751 }
752 57 ▶ if ($dtype =~ /\b(bool|boolean|tinyint\(1\))\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(bool|boolean|tinyint\(1\))\b/) 4 53 57
753 4 return int(rand(2));
754 }
755 53 ▶ if ($dtype =~ /\b(datetime|timestamp)\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\b(datetime|timestamp)\b/) 7 46 53
756 7 return $self->_rand_datetime;
757 }
758 46 ▶ if ($dtype =~ /\bdate\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\bdate\b/) 2 44 46
759 2 return $self->_rand_date;
760 }
761 44 ▶ if ($dtype =~ /\btime\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\btime\b/) 0 44 44
762 0 return sprintf '%02d:%02d:%02d', int(rand(24)), int(rand(60)), int(rand(60));
763 }
764 44 ▶ if ($dtype =~ /\buuid\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\buuid\b/) 0 44 44
765 0 return create_uuid_as_string(UUID_V4);
766 }
767 44 ▶ if ($dtype =~ /\bjsonb?\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\bjsonb?\b/) 0 44 44
768 0 return qq({"generated":true,"row":$n});
769 }
770 44 ▶ if ($dtype =~ /\[\]$/ || $dtype =~ /^array/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtype =~ /\[\]$/ or $dtype =~ /^array/) 0 44 44
Condition33%1/3
$dtype =~ /\[\]$/ or $dtype =~ /^array/
l!l&&r!l&&!r
0044
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
771 0 return '{value1,value2}';
772 }
773 44 ▶ 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/) 44 0 44
774 44 ▶ return $self->_contextual_string($col, $n, int($size) || 255, $is_unique);
Condition50%1/2
int $size || 255
l!l
440
MC/DC0%0/1
int $size || 255
int $size
Truth table50%1/2
A
A= int $size
Aresult
11
00
775 }
776  
777 0 ▶ return $is_unique ? "${col}_${n}_${salt}" : "${col}_${n}";
Branch: 1 branch
BranchTrueFalseTotal
$is_unique ? : 0 0 0
778 }
779  
780 sub _contextual_string {
781 44 ▶ my ($self, $col, $n, $max, $is_unique) = @_;
Subroutine _contextual_string: called CC=4 SCAR=20.9
782 44 my $salt = $self->{_salt};
783  
784 state $templates = [
785 [ qr/\b(first_?name|fname)\b/i,
786 sub {
787 4 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
788 4 my $value = (qw(Alice Bob Carol Dave Eve Frank Grace Hank Iris Jack))[$n%10];
789 4 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 4 4
790 4 return $value;
791 } ],
792 [ qr/\b(last_?name|lname|surname)\b/i,
793 sub {
794 4 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
795 4 my $value = (qw(Smith Jones Taylor Brown Wilson Davies Evans Thomas Roberts))[$n%9];
796 4 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 4 4
797 4 return $value;
798 } ],
799 [ qr/\bname\b/i,
800 sub {
801 3 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
802 3 my $value = "Name $n";
803 3 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 3 3
804 3 return $value;
805 } ],
806 [ qr/\b(username|login)\b/i,
807 sub {
808 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
809 0 my $value = "user$n";
810 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
811 0 return $value;
812 } ],
813 [ qr/\bemail\b/i,
814 sub {
815 7 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
816 7 my $local = "user$n";
817 7 ▶ $local .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 7 0 7
818 7 return "${local}\@example.com";
819 } ],
820 [ qr/\b(phone|mobile|fax)\b/i,
821 sub {
822 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
823 0 return sprintf '+1555%04d%04d', $salt % 10000, $n;
824 } ],
825 [ qr/\b(street|address|addr)\b/i,
826 sub {
827 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
828 0 my $value = "$n Main Street";
829 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
830 0 return $value;
831 } ],
832 [ qr/\b(city|town)\b/i,
833 sub {
834 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
835 0 my $value = (qw(London Paris Berlin Madrid Rome Amsterdam Brussels Vienna))[$n%8];
836 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
837 0 return $value;
838 } ],
839 [ qr/\bcountry\b/i,
840 sub {
841 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
842 0 my $value = (qw(UK US DE FR ES IT NL AT))[$n%8];
843 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
844 0 return $value;
845 } ],
846 [ qr/\b(zip|postcode|postal)\b/i,
847 sub {
848 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
849 0 return sprintf '%05d', (10000 + $n + $salt) % 99999;
850 } ],
851 [ qr/\b(state|province|region)\b/i,
852 sub {
853 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
854 0 my $value = (qw(CA NY TX FL WA IL PA OH))[$n%8];
855 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
856 0 return $value;
857 } ],
858 [ qr/\b(description|desc|summary|notes?|comment|body|content)\b/i,
859 sub {
860 4 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
861 4 return "Sample text for record $n (run $salt).";
862 } ],
863 [ qr/\b(title|heading|subject)\b/i,
864 sub {
865 4 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
866 4 my $value = "Title $n";
867 4 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 4 4
868 4 return $value;
869 } ],
870 [ qr/\bslug\b/i,
871 sub {
872 4 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
873 4 my $value = "slug-$n";
874 4 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 4 0 4
875 4 return $value;
876 } ],
877 [ qr/\b(code|ref|reference)\b/i,
878 sub {
879 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
880 0 my $value = sprintf 'CODE%04d', $n;
881 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
882 0 return $value;
883 } ],
884 [ qr/\bsku\b/i,
885 sub {
886 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
887 0 my $value = sprintf 'SKU%04d', $n;
888 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
889 0 return $value;
890 } ],
891 [ qr/\b(token|secret|key|hash)\b/i,
892 sub {
893 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
894 0 return sprintf '%016x%08x', $salt, $n;
895 } ],
896 [ qr/\b(url|link|href|website)\b/i,
897 sub {
898 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
899 0 my $value = "https://example.com/item/$n";
900 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
901 0 return $value;
902 } ],
903 [ qr/\b(status|state)\b/i,
904 sub {
905 3 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
906 3 my $value = (qw(active inactive pending approved rejected))[$n%5];
907 3 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 3 3
908 3 return $value;
909 } ],
910 [ qr/\b(type|kind|category|cat)\b/i,
911 sub {
912 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
913 0 my $value = (qw(typeA typeB typeC typeD))[$n%4];
914 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
915 0 return $value;
916 } ],
917 [ qr/\b(colour|color)\b/i,
918 sub {
919 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
920 0 my $value = (qw(red green blue yellow purple orange))[$n%6];
921 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
922 0 return $value;
923 } ],
924 [ qr/\b(lang|language|locale)\b/i,
925 sub {
926 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
927 0 my $value = (qw(en fr de es it nl pt))[$n%7];
928 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
929 0 return $value;
930 } ],
931 [ qr/\b(version|ver)\b/i,
932 sub {
933 0 ▶ my ($n, $is_unique, $salt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
934 0 my $value = "1.$n.0";
935 0 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 0 0
936 0 return $value;
937 44 } ],
938 ];
939  
940 44 for my $t (@$templates) {
941 522 ▶ if ($col =~ $t->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($col =~ /$t->[0]/) 33 489 522
942 33 my $value = $t->[1]->($n, $is_unique, $salt);
943 33 return substr($value, 0, $max);
944 }
945 }
946  
947 # Default case
948 11 my $value = "${col}_${n}";
949 11 ▶ $value .= "_${salt}" if $is_unique;
Branch: 1 branch
BranchTrueFalseTotal
if $is_unique 0 11 11
950 11 return substr($value, 0, $max);
951 }
952  
953 sub _insert_rows {
954 5 ▶ my ($self, $source, $name, $rows, $pk_cols, $inserted_pks) = @_;
Subroutine _insert_rows: called CC=3 SCAR=13.6
955  
956 5 my $rs = $self->{_schema}->resultset($name);
957  
958 5 eval { $rs->populate($rows) };
959  
960 5 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 5 0 5
961 5 warn "[WARN] Bulk insert failed for $name: $@\n";
962 5 return;
963 }
964  
965 0 my @inserted = $rs->search({}, { rows => scalar(@$rows) });
966  
967 0 for my $row (@inserted) {
968 0 push @{ $inserted_pks->{$name} },
969 0 { map { $_ => $row->get_column($_) } @$pk_cols };
970 }
971  
972 0 $self->_log("Inserted " . scalar(@$rows) . " rows into $name");
973 }
974  
975 sub _rand_date {
976 2 ▶ my ($self) = @_;
Subroutine _rand_date: called CC=1 SCAR=0.0
977 2 my $year = $self->{start_year} + int(rand($self->{end_year} - $self->{start_year} + 1));
978 2 sprintf '%d-%02d-%02d', $year, rand(12)+1, rand(28)+1;
979 }
980  
981 sub _rand_datetime {
982 7 ▶ my ($self) = @_;
Subroutine _rand_datetime: called CC=1 SCAR=0.0
983 7 my $year = $self->{start_year} + int(rand($self->{end_year} - $self->{start_year} + 1));
984 7 sprintf '%d-%02d-%02d %02d:%02d:%02d',
985 $year, rand(12)+1, rand(28)+1, rand(24), rand(60), rand(60);
986 }
987  
988 14 ▶sub _log { print "[INFO] $_[1]\n"; }
Subroutine _log: called CC=1 SCAR=0.0
989 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
990  
991 =head1 GENERATED VALUES
992  
993 Values are produced from each column's declared C<data_type>:
994  
995 integer / bigint / serial random integer (unique: salt + row_num)
996 numeric / decimal / float random decimal (2 d.p.)
997 boolean 0 or 1
998 datetime / timestamp random datetime 2020-2024
999 date random date 2020-2024
1000 time random HH:MM:SS
1001 uuid random UUID-shaped hex string
1002 json / jsonb {"generated":true,"row":N}
1003 text / varchar / char contextual string matched on column name
1004 unknown / blank dtype colname_N (colname_N_SALT if unique)
1005  
1006 Nullable columns receive NULL roughly 17% of the time (never for unique cols).
1007  
1008 =head1 CONFIGURATION OPTIONS
1009  
1010 =head2 rows_per_table
1011  
1012 rows_per_table => { Author => 10, Book => 3 }
1013  
1014 Allows you to specify different numbers of rows for specific tables. Any table
1015 not listed in this hash will use the global C<rows> value. This is useful when
1016 you need more data for certain tables (e.g., Authors) and less for others.
1017  
1018 =head2 generators
1019  
1020 generators => {
1021 email => sub { "user".int(rand(1000))."\@example.com" },
1022 status => sub { "active" },
1023 }
1024  
1025 Provides custom value generators for specific columns. The generator subroutine
1026 receives four arguments:
1027  
1028 =over 4
1029  
1030 =item C<$col> - The column name
1031  
1032 =item C<$info> - The column info hashref from the result source
1033  
1034 =item C<$n> - The current row number (1-based)
1035  
1036 =item C<$mock> - The MockData object instance (provides access to C<_salt> etc.)
1037  
1038 =back
1039  
1040 The generator should return a scalar value appropriate for the column. This
1041 overrides the default value generation for that column.
1042  
1043 Examples:
1044  
1045 # Static value for all rows
1046 status => sub { 'active' }
1047  
1048 # Value based on row number
1049 code => sub { my ($col, $info, $n) = @_; "CODE_$n" }
1050  
1051 # Value using the instance salt for uniqueness
1052 token => sub { my ($col, $info, $n, $mock) = @_; "token_${n}_$mock->{_salt}" }
1053  
1054 # Conditional logic
1055 email => sub {
1056 my ($col, $info, $n) = @_;
1057 return $n == 1 ? 'admin@example.com' : "user$n\@example.com";
1058 }
1059  
1060 =head1 PERFORMANCE IMPROVEMENTS
1061  
1062 Version 0.04 introduces significant performance optimisations:
1063  
1064 =head2 Bulk Insert Mode
1065  
1066 Previously, rows were inserted one at a time using C<< $rs->create() >>, which
1067 could be slow for large datasets. The module now uses C<< $rs->populate() >> to
1068 insert all rows in a single batch operation. This results in:
1069  
1070 =over 4
1071  
1072 =item * Up to 10x faster insertions for large datasets
1073  
1074 =item * Reduced database round-trips
1075  
1076 =item * Maintained foreign key integrity
1077  
1078 =back
1079  
1080 =head2 Smarter Salt Generation
1081  
1082 When a C<seed> is provided for reproducible output, the salt value is now
1083 randomised while still producing consistent results. This ensures:
1084  
1085 =over 4
1086  
1087 =item * Reproducible test data across runs (with same seed)
1088  
1089 =item * Unique values across different test runs (different salts)
1090  
1091 =item * No accidental collisions when running tests in parallel
1092  
1093 =back
1094  
1095 =head2 Unique Constraint Handling
1096  
1097 The module now properly respects:
1098  
1099 =over 4
1100  
1101 =item * Primary key uniqueness (except auto-increment columns)
1102  
1103 =item * Named unique constraints from L<DBIx::Class>
1104  
1105 =item * Multi-column unique constraints
1106  
1107 =back
1108  
1109 Values for unique columns are automatically salted to ensure uniqueness
1110 without manual intervention.
1111  
1112 =head1 CLI TOOL
1113  
1114 This distribution ships with a command-line tool B<dbic-mockdata> in the
1115 C<script/> directory, installed into your C<PATH> by C<make install>.
1116  
1117 dbic-mockdata --schema-dir t/lib --namespace MyApp::Schema \
1118 --dsn "dbi:SQLite:dbname=test.db" --deploy --rows 5
1119  
1120 Run C<dbic-mockdata --help> for the full list of options, or see
1121 L<dbic-mockdata> for the complete manual.
1122  
1123 =head1 DEPENDENCIES
1124  
1125 L<DBIx::Class>, L<Carp>, L<File::Spec>, L<Scalar::Util>
1126  
1127 =head1 AUTHOR
1128  
1129 Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >>
1130  
1131 =head1 REPOSITORY
1132  
1133 L<https://github.com/manwar/DBIx-Class-MockData>
1134  
1135 =head1 BUGS
1136  
1137 Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/DBIx-Class-MockData/issues>.
1138 I will be notified and then you'll automatically be notified of progress on your
1139 bug as I make changes.
1140  
1141 =head1 SUPPORT
1142  
1143 You can find documentation for this module with the perldoc command.
1144  
1145 perldoc DBIx::Class::MockData
1146  
1147 You can also look for information at:
1148  
1149 =over 4
1150  
1151 =item * BUG Report
1152  
1153 L<https://github.com/manwar/DBIx-Class-MockData/issues>
1154  
1155 =item * CPAN Ratings
1156  
1157 L<http://cpanratings.perl.org/d/DBIx-Class-MockData>
1158  
1159 =item * Search MetaCPAN
1160  
1161 L<https://metacpan.org/dist/DBIx-Class-MockData/>
1162  
1163 =back
1164  
1165 =head1 LICENSE AND COPYRIGHT
1166  
1167 Copyright (C) 2026 Mohammad Sajid Anwar.
1168  
1169 This program is free software; you can redistribute it and / or modify it under
1170 the terms of the the Artistic License (2.0). You may obtain a copy of the full
1171 license at:
1172 L<http://www.perlfoundation.org/artistic_license_2_0>
1173 Any use, modification, and distribution of the Standard or Modified Versions is
1174 governed by this Artistic License.By using, modifying or distributing the Package,
1175 you accept this license. Do not use, modify, or distribute the Package, if you do
1176 not accept this license.
1177 If your Modified Version has been derived from a Modified Version made by someone
1178 other than you,you are nevertheless required to ensure that your Modified Version
1179 complies with the requirements of this license.
1180 This license does not grant you the right to use any trademark, service mark,
1181 tradename, or logo of the Copyright Holder.
1182 This license includes the non-exclusive, worldwide, free-of-charge patent license
1183 to make, have made, use, offer to sell, sell, import and otherwise transfer the
1184 Package with respect to any patent claims licensable by the Copyright Holder that
1185 are necessarily infringed by the Package. If you institute patent litigation
1186 (including a cross-claim or counterclaim) against any party alleging that the
1187 Package constitutes direct or contributory patent infringement,then this Artistic
1188 License to you shall terminate on the date that such litigation is filed.
1189 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
1190 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
1191 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
1192 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
1193 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
1194 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
1195 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1196  
1197 =cut
1198  
1199 6 1; # End of DBIx::Class::MockData
↑ Summary