Database-BI
view release on metacpan or search on metacpan
lib/Database/BI/Model/DataSource.pm view on Meta::CPAN
SCALAR integer # Unix epoch seconds, e.g. 1728601234
undef # URL-backed tables, or file cannot be stat()-ed
=head3 MESSAGES
None.
=cut
sub updated {
my $self = shift;
# The file itself comes first. D::A only learns an mtime when it opens the file,
# which it does lazily, so before the first read it answers undef, and after it
# goes on answering the time of that read however the file has changed since.
return (stat($self->{_file_path}))[9] if defined $self->{_file_path} && -f $self->{_file_path};
return $self->{_db}->updated() if $self->{_db} && $self->{_db}->can('updated');
return undef;
}
=head2 schema
t/mariadb.t view on Meta::CPAN
{
package InlineDA;
sub new {
my ($class, %args) = @_;
return bless { _cols => $args{cols} // [], _rows => $args{rows} // [] }, $class;
}
sub columns { return $_[0]->{_cols} }
sub schema { return {} }
sub updated { return 1 }
sub set_logger { return $_[0] }
sub selectall_arrayref {
my ($self, $criteria) = @_;
my @rows = @{ $self->{_rows} };
for my $col (CORE::keys %{ $criteria // {} }) {
my $val = $criteria->{$col};
next if ref $val;
@rows = grep { defined $_->{$col} && $_->{$col} eq $val } @rows;
}
t/mariadb_live.t view on Meta::CPAN
{
package InlineDA;
sub new {
my ($class, %args) = @_;
return bless { _cols => $args{cols} // [], _rows => $args{rows} // [] }, $class;
}
sub columns { return $_[0]->{_cols} }
sub schema { return {} }
sub updated { return 1 }
sub set_logger { return $_[0] }
sub selectall_arrayref {
my ($self, $criteria) = @_;
my @rows = @{ $self->{_rows} };
for my $col (CORE::keys %{ $criteria // {} }) {
my $val = $criteria->{$col};
next if ref $val;
@rows = grep { defined $_->{$col} && $_->{$col} eq $val } @rows;
}
t/mutant_killers.t view on Meta::CPAN
}
sub selectall_hashref {
my ($self) = @_;
push @{ $self->{calls} }, [ 'selectall_hashref' ];
die $self->{die} if $self->{die};
return $self->{rows};
}
sub columns { return $_[0]{columns} }
sub count { return $_[0]{count} }
sub aggregate { my ($self, @args) = @_; return { aggregated => \@args } }
sub updated { return $_[0]{updated} }
sub schema {
my ($self) = @_;
die 'no schema' if $self->{schema_dies};
return $self->{schema};
}
sub dbi_source {
my ($self) = @_;
die 'no dbi' if $self->{dbi_dies};
return $self->{dbi};
}
sub new {
my ($class, %args) = @_;
return bless {
_cols => $args{cols} // [],
_rows => $args{rows} // [],
}, $class;
}
sub columns { return $_[0]->{_cols} }
sub schema { return {} }
sub updated { return 1 }
sub set_logger { return $_[0] }
sub selectall_arrayref {
my ($self, $criteria) = @_;
my @rows = @{ $self->{_rows} };
for my $col (CORE::keys %{ $criteria // {} }) {
my $val = $criteria->{$col};
next if ref $val;
@rows = grep { defined $_->{$col} && $_->{$col} eq $val } @rows;
}
t/redis_live.t view on Meta::CPAN
sub new {
my ($class, %args) = @_;
return bless {
_cols => $args{cols} // [],
_rows => $args{rows} // [],
}, $class;
}
sub columns { return $_[0]->{_cols} }
sub schema { return {} }
sub updated { return 1 }
sub set_logger { return $_[0] }
sub selectall_arrayref {
my ($self, $criteria) = @_;
my @rows = @{ $self->{_rows} };
for my $col (CORE::keys %{ $criteria // {} }) {
my $val = $criteria->{$col};
next if ref $val;
@rows = grep { defined $_->{$col} && $_->{$col} eq $val } @rows;
}
( run in 1.582 second using v1.01-cache-2.11-cpan-0e0213f3164 )