Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tidy

Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information...
commit d7bc9691e40bd7f8889e37a6c9d26cf8ac7f486b 1 parent f3a4a5d
@melo authored
View
2  lib/Percy/Schema/Type.pm
@@ -64,7 +64,7 @@ for my $w (qw(before after)) {
has $attr => (is => 'ro');
no strict 'refs';
- *{__PACKAGE__ . '::' . $meth} = sub {
+ *{ __PACKAGE__ . '::' . $meth } = sub {
return ($_[0]{$attr} || sub { })->(@_);
};
}
View
13 lib/Percy/Storage/DBI.pm
@@ -56,8 +56,7 @@ sub create {
$spec->before_change($self, $r, 'create');
$spec->before_create($self, $r);
- my $oid = $r->{oid} =
- _dbi_create_obj($dbh, $r, $spec->encode_to_db($self, $r));
+ my $oid = $r->{oid} = _dbi_create_obj($dbh, $r, $spec->encode_to_db($self, $r));
$spec->after_create($self, $r);
$spec->after_change($self, $r, 'create');
@@ -310,8 +309,7 @@ sub _dbi_obj_where {
return ("$sql WHERE oid=?", $r->{oid}) if defined $r->{oid};
return ("$sql WHERE type=? AND pk=?", $r->{type}, $r->{pk})
if defined $r->{type} && defined $r->{pk};
- Carp::confess(
- "FATAL: insufficient conditions to identify a specific object,");
+ Carp::confess("FATAL: insufficient conditions to identify a specific object,");
}
sub _type_fetch {
@@ -405,8 +403,7 @@ sub deploy {
sub _generate_table_stmts {
my $class = ref($_[0]) || $_[0];
- Carp::confess(
- "FATAL: redefine the _generate_table_stmts() method in '$class',");
+ Carp::confess("FATAL: redefine the _generate_table_stmts() method in '$class',");
}
sub _collect_obj_storage_table_stmts {
@@ -430,7 +427,7 @@ sub _collect_obj_storage_table_stmts {
},
],
pk => ['pk'],
- unique => {pk_type => [qw(pk type)]},
+ unique => { pk_type => [qw(pk type)] },
};
return $self->_generate_table_stmts($table);
@@ -472,7 +469,7 @@ sub _collect_set_table_stmts {
$type = 'VARCHAR(100)' if $type eq 'String';
$type = uc($type);
- push @{$table->{fields}}, {name => $field, type => "$type NOT NULL"};
+ push @{ $table->{fields} }, { name => $field, type => "$type NOT NULL" };
$table->{indexes}{$sn} = ['m_oid', $field];
}
View
17 lib/Percy/Storage/DBI/SQLite.pm
@@ -18,7 +18,7 @@ sub _generate_table_stmts {
my $skip_pk;
my $tn = $table->{name};
my $tbl = "CREATE TABLE IF NOT EXISTS $tn (\n";
- for my $f (@{$table->{fields}}) {
+ for my $f (@{ $table->{fields} }) {
$tbl .= ",\n" if $skip_pk;
$tbl .= " $f->{name} $f->{type}";
if ($f->{is_auto_increment}) {
@@ -29,26 +29,21 @@ sub _generate_table_stmts {
}
if (!$skip_pk) {
- $tbl .= "\n CONSTRAINT ${tn}_pk PRIMARY KEY ("
- . join(', ', @{$table->{pk}}) . ")\n";
+ $tbl .= "\n CONSTRAINT ${tn}_pk PRIMARY KEY (" . join(', ', @{ $table->{pk} }) . ")\n";
}
$tbl .= ')';
push @sql_stmts, $tbl;
## Indexes
- while (my ($in, $if) = each %{$table->{indexes} || {}}) {
+ while (my ($in, $if) = each %{ $table->{indexes} || {} }) {
push @sql_stmts,
- "CREATE INDEX IF NOT EXISTS ${tn}_${in}_idx"
- . " ON $tn ("
- . join(', ', @$if) . ")";
+ "CREATE INDEX IF NOT EXISTS ${tn}_${in}_idx" . " ON $tn (" . join(', ', @$if) . ")";
}
## Unique keys
- while (my ($un, $uf) = each %{$table->{unique} || {}}) {
+ while (my ($un, $uf) = each %{ $table->{unique} || {} }) {
push @sql_stmts,
- "CREATE UNIQUE INDEX IF NOT EXISTS ${tn}_${un}_un"
- . " ON $tn ("
- . join(', ', @$uf) . ")";
+ "CREATE UNIQUE INDEX IF NOT EXISTS ${tn}_${un}_un" . " ON $tn (" . join(', ', @$uf) . ")";
}
return \@sql_stmts;
View
12 lib/Percy/Storage/DBI/mysql.pm
@@ -20,26 +20,24 @@ sub _generate_table_stmts {
my $tbl = "CREATE TABLE IF NOT EXISTS $tn (\n";
my @fields;
- for my $f (@{$table->{fields}}) {
+ for my $f (@{ $table->{fields} }) {
push @fields, " $f->{name} $f->{type}";
$fields[-1] .= " PRIMARY KEY AUTO_INCREMENT" if $f->{is_auto_increment};
}
$tbl .= join(",\n", @fields);
if (@$pks > 1) {
- $tbl .= ",\n\n CONSTRAINT ${tn}_pk PRIMARY KEY ("
- . join(', ', @{$table->{pk}}) . ")";
+ $tbl .= ",\n\n CONSTRAINT ${tn}_pk PRIMARY KEY (" . join(', ', @{ $table->{pk} }) . ")";
}
## Indexes
- while (my ($in, $if) = each %{$table->{indexes} || {}}) {
+ while (my ($in, $if) = each %{ $table->{indexes} || {} }) {
$tbl .= ",\n INDEX ${tn}_${in}_idx (" . join(', ', @$if) . ")";
}
## Unique keys
- while (my ($un, $uf) = each %{$table->{unique} || {}}) {
- $tbl
- .= ",\n CONSTRAINT ${tn}_${un}_un UNIQUE (" . join(', ', @$uf) . ")";
+ while (my ($un, $uf) = each %{ $table->{unique} || {} }) {
+ $tbl .= ",\n CONSTRAINT ${tn}_${un}_un UNIQUE (" . join(', ', @$uf) . ")";
}
$tbl .= "\n) ENGINE = InnoDB\n";
Please sign in to comment.
Something went wrong with that request. Please try again.