App-Sqitch
view release on metacpan or search on metacpan
lib/App/Sqitch/Engine/clickhouse.pm view on Meta::CPAN
} . join( ",\n ", ($row) x @tags ),
undef,
map { (
$_->id,
$_->format_name,
$proj,
$id,
$_->note,
$user,
$email,
$self->_char2ts($_->timestamp),
$_->planner_name,
$_->planner_email,
) } @tags
);
return $self;
}
# Wrap _select_state to parse the tags into an array. Remove if and when
# clickhouse-odbc properly supports arrays. Remove if
# https://github.com/clickHouse/clickhouse-odbc/issues/525 fixed.
around _select_state => sub {
my ($orig, $self) = (shift, shift);
my $state = $self->$orig(@_);
$state->{tags} = $self->_parse_array($state->{tags})
if $state && $state->{tags};
return $state;
};
sub _run {
my $self = shift;
my $sqitch = $self->sqitch;
my $pass = $self->password or return $sqitch->run( $self->cli, @_ );
local $ENV{CLICKHOUSE_PASSWORD} = $pass;
return $sqitch->run( $self->cli, @_ );
}
sub _capture {
my $self = shift;
my $sqitch = $self->sqitch;
my $pass = $self->password or return $sqitch->capture( $self->cli, @_ );
local $ENV{CLICKHOUSE_PASSWORD} = $pass;
return $sqitch->capture( $self->cli, @_ );
}
sub _spool {
my $self = shift;
my @fh = (shift);
my $sqitch = $self->sqitch;
my $pass = $self->password or return $sqitch->spool( \@fh, $self->cli, @_ );
local $ENV{CLICKHOUSE_PASSWORD} = $pass;
return $sqitch->spool( \@fh, $self->cli, @_ );
}
sub run_file {
my ($self, $file) = @_;
$self->_run('--queries-file' => $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('--queries-file' => $file);
}
sub run_upgrade {
my ($self, $file) = @_;
my @cmd = $self->cli;
if ((my $idx = firstidx { $_ eq '--database' } @cmd) > 0) {
# Replace the database name with the registry database.
$cmd[$idx + 1] = $self->registry;
} else {
# Append the registry database name.
push @cmd => '--database', $self->registry;
}
return $self->sqitch->run(@cmd, '--queries-file' => $file);
}
sub run_handle {
my ($self, $fh) = @_;
$self->_spool($fh);
}
1;
__END__
=head1 Name
App::Sqitch::Engine::clickhouse - Sqitch ClickHouse Engine
=head1 Synopsis
my $clickhouse = App::Sqitch::Engine->load( engine => 'clickhouse' );
=head1 Description
App::Sqitch::Engine::clickhouse provides the ClickHouse storage engine for Sqitch. It
supports ClickHouse v25.8 and higher.
=head1 Interface
=head2 Instance Methods
=head3 C<cli>
Returns a list containing the C<clickhouse> client and options to be passed to it.
Used internally when executing scripts.
L<Query parameters|https://github.com/clickHouse/clickhouse-odbc> in the URI
that map to C<clickhouse> client options will be passed to the client, as
follows:
=over
=item * C<SSLMode>: C<--secure>
Assume that TLS is required in the client if SSLMode is set.
( run in 0.834 second using v1.01-cache-2.11-cpan-5a3173703d6 )