App-Sqitch

 view release on metacpan or  search on metacpan

lib/App/Sqitch/Engine/sqlite.pm  view on Meta::CPAN

    $self->_register_release;
}

sub _no_table_error  {
    return $DBI::errstr && $DBI::errstr =~ /^\Qno such table:/;
}

sub _no_column_error  {
    return $DBI::errstr && $DBI::errstr =~ /^\Qno such column:/;
}

sub _unique_error  {
    return $DBI::errstr && $DBI::errstr =~ /^\QUNIQUE constraint failed:/;
}

sub _regex_op { 'REGEXP' }

sub _limit_default { -1 }

sub _ts_default {
    q{strftime('%Y-%m-%d %H:%M:%f')};
}

sub _ts2char_format {
    return q{strftime('year:%%Y:month:%%m:day:%%d:hour:%%H:minute:%%M:second:%%S:time_zone:UTC', %s)};
}

sub _listagg_format {
    # The order of the concatenated elements is arbitrary.
    # https://www.sqlite.org/lang_aggfunc.html
    return q{group_concat(%s, ' ')};
}

sub _char2ts {
    my $dt = $_[1];
    $dt->set_time_zone('UTC');
    return join ' ', $dt->ymd('-'), $dt->hms(':');
}

sub _run {
    my $self   = shift;
    return $self->sqitch->run( $self->sqlite3, @_ );
}

sub _capture {
    my $self   = shift;
    return $self->sqitch->capture( $self->sqlite3, @_ );
}

sub _spool {
    my $self   = shift;
    my $fh     = shift;
    return $self->sqitch->spool( $fh, $self->sqlite3, @_ );
}

sub run_file {
    my ($self, $file) = @_;
    $self->_run( $self->_read($file) );
}

sub run_verify {
    my ($self, $file) = @_;
    # Suppress STDOUT unless we want extra verbosity.
    my $meth = $self->can($self->sqitch->verbosity > 1 ? '_run' : '_capture');
    $self->$meth( $self->_read($file) );
}

sub run_handle {
    my ($self, $fh) = @_;
    $self->_spool($fh);
}

sub run_upgrade {
    my ($self, $file) = @_;
    my @cmd = $self->sqlite3;
    $cmd[-1] = $self->registry_uri->dbname;
    return $self->sqitch->run( @cmd, $self->_read($file) );
}

sub _read {
    my $self = shift;
    return '.read ' . $self->dbh->quote(shift);
}

1;

__END__

=head1 Name

App::Sqitch::Engine::sqlite - Sqitch SQLite Engine

=head1 Synopsis

  my $sqlite = App::Sqitch::Engine->load( engine => 'sqlite' );

=head1 Description

App::Sqitch::Engine::sqlite provides the SQLite storage engine for Sqitch.

=head1 Interface

=head2 Accessors

=head3 C<client>

Returns the path to the SQLite client. If C<--client> was passed to C<sqitch>,
that's what will be returned. Otherwise, it uses the C<engine.sqlite.client>
configuration value, or else defaults to C<sqlite3> (or C<sqlite3.exe> on
Windows), which should work if it's in your path.

=head2 Instance Methods

=head3 C<sqlite3>

Returns a list containing the C<sqlite3> client and options to be passed to it.
Used internally when executing scripts.

=head1 Author

David E. Wheeler <david@justatheory.com>



( run in 0.466 second using v1.01-cache-2.11-cpan-5a3173703d6 )