Skip to content

Commit

Permalink
repair_table_model refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jonny64 committed Mar 24, 2016
1 parent c6e99ba commit 5e48bfb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Eludia/Content/Watchdog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ sub try_to_repair_error {

################################################################################

sub exists_sql_table {

my ($table) = @_;

$table && keys %{$DB_MODEL -> {tables} -> {$table}} or return 0;

return keys %{$DB_MODEL -> {tables} -> {$table} -> {columns}} > 0;
}

################################################################################

sub repair_table_model {

my ($tables) = @_;
Expand All @@ -125,7 +136,7 @@ sub repair_table_model {

ref $tables eq 'ARRAY' or $tables = [$tables];

@$tables = grep {0 < keys %{$DB_MODEL -> {tables} -> {$_}}} @$tables;
@$tables = grep {exists_sql_table ($_)} @$tables;

@$tables or return;

Expand Down

0 comments on commit 5e48bfb

Please sign in to comment.