NAME
DBIO::PopulateMore - Enhanced populate with cross-source references
VERSION
version 0.900004
SYNOPSIS
package MyApp::Schema;
use DBIO 'Schema', -pg;
# Can be loaded as a component or used standalone
__PACKAGE__->load_components(qw/PopulateMore/);
# Or use directly on any schema instance, without loading the component
# (note the function-call form -- the schema is the invocant):
# DBIO::PopulateMore::populate_more($schema, [...]);
Then:
$schema->populate_more([
{ Gender => {
fields => 'label',
data => {
male => 'male',
female => 'female',
}}},
{ Person => {
fields => ['name', 'age', 'gender'],
data => {
john => ['john', 38, '!Index:Gender.male'],
jane => ['jane', 40, '!Index:Gender.female'],
}}},
]);
See t/populate_more.t for a runnable example of the !Index: cross-reference.
DESCRIPTION
This module provides an enhanced version of the builtin "populate" in DBIO::Schema method. It allows inserting rows across multiple result sources in one call, with cross-referencing between them via the !Index:Source.key syntax.
Based on DBIx::Class::Schema::PopulateMore by John Napiorkowski.
Unlike other DBIO::Schema components, this module is not a schema plugin that inherits from DBIO::Schema. It is a standalone utility class that operates on any schema instance. It can be loaded as a component via "load_components" in DBIO::Schema, or used directly.
Inflators
Values starting with ! are processed by inflator plugins:
!Index:Source.key- Reference a previously inserted row!Env:VAR_NAME- Substitute from%ENV!Find:Source.[key=val]- Look up an existing row; thekey=valpairs (or a single primary key value) give every column of one unique constraint, as for "find" in DBIO::ResultSet
METHODS
populate_more
Populate multiple sources with optional cross-source references and inflators.
Each row is written with "update_or_create" in DBIO::ResultSet: the fields of a row give every column of exactly one unique constraint of its source, that constraint finds an existing row, and the other fields are the data the row is updated or created with.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.