Author: spadkins
Date: Wed Apr  9 05:53:20 2008
New Revision: 11061

Modified:
   p5ee/trunk/App-Repository/CHANGES
   p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm

Log:
consult the "table" config value for table to see the physical table (good for 
schema-qualified table names)

Modified: p5ee/trunk/App-Repository/CHANGES
==============================================================================
--- p5ee/trunk/App-Repository/CHANGES   (original)
+++ p5ee/trunk/App-Repository/CHANGES   Wed Apr  9 05:53:20 2008
@@ -2,6 +2,9 @@
 # CHANGE LOG
 #########################################
 
+0.967
+ x App::Repository::_mk_*(): consult the "table" config value for table to see 
the physical table (good for schema-qualified table names)
+
 0.966
  x App::Repository::mk_select_joined_sql(): enable param substitutions in 
dbexpr's
  x App::Repository::get_rows()/get_row(): use query caching if turned on for 
the table ({cache_name} => "name_of_shared_datastore")

Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm Wed Apr  9 05:53:20 2008
@@ -901,7 +901,9 @@
     $direction = $options->{direction} || $options->{directions};     # 
{directions} is deprecated
     my $modifier = $options->{distinct} ? " distinct" : "";
 
-    $sql = "select$modifier\n   " . join(",\n   ", @$cols) . "\nfrom $table\n";
+    my $table_def = $self->get_table_def($table);
+    my $realtable = $table_def->{table} || $table;
+    $sql = "select$modifier\n   " . join(",\n   ", @$cols) . "\nfrom 
$realtable\n";
     $sql .= $self->_mk_where_clause($table, $params);
 
     if (defined $order_by && $#$order_by > -1) {
@@ -1720,9 +1722,11 @@
         $self->{error} = "Database->_mk_insert_row_sql(): no columns 
specified";
         return();
     }
-    my $tabcols = $self->{table}{$table}{column};
+    my $table_def = $self->get_table_def($table);
+    my $tabcols = $table_def->{column};
 
-    $sql = "insert into $table\n";
+    my $realtable = $table_def->{table} || $table;
+    $sql = "insert into $realtable\n";
     $values = "values\n";
     for ($colnum = 0; $colnum <= $#$cols; $colnum++) {
         $col = $cols->[$colnum];
@@ -1800,7 +1804,9 @@
             }
         }
     }
-    my $sql = "insert into $table\n  (" . join(",\n   ",@$cols) . ")\nvalues\n 
 (" . join(@values) . ")\n";
+    my $table_def = $self->get_table_def($table);
+    my $realtable = $table_def->{table} || $table;
+    my $sql = "insert into $realtable\n  (" . join(",\n   ",@$cols) . 
")\nvalues\n  (" . join(@values) . ")\n";
     &App::sub_exit($sql) if ($App::trace);
     $sql;
 }
@@ -1936,7 +1942,9 @@
         }
     }
 
-    my $sql = "update $table set\n   " . join(",\n   ",@set) . "\n" . $where;
+    my $table_def = $self->get_table_def($table);
+    my $realtable = $table_def->{table} || $table;
+    my $sql = "update $realtable set\n   " . join(",\n   ",@set) . "\n" . 
$where;
     &App::sub_exit($sql) if ($App::trace);
     $sql;
 }
@@ -2038,7 +2046,9 @@
         die "_mk_delete_sql() unrecognized params type";
     }
 
-    my $sql = "delete from $table\n$where";
+    my $table_def = $self->get_table_def($table);
+    my $realtable = $table_def->{table} || $table;
+    my $sql = "delete from $realtable\n$where";
     &App::sub_exit($sql) if ($App::trace);
     $sql;
 }
@@ -2060,7 +2070,9 @@
 
     $colused[$#$cols] = 0;   # pre-extend the array
 
-    $sql = "delete from $table\n";
+    my $table_def = $self->get_table_def($table);
+    my $realtable = $table_def->{table} || $table;
+    $sql = "delete from $realtable\n";
 
     if (defined $keycolidx && $#$keycolidx > -1) {
         for ($i = 0; $i <= $#$keycolidx; $i++) {
@@ -2099,7 +2111,9 @@
     $self->_load_table_metadata($table) if (!defined 
$self->{table}{$table}{loaded});
     my ($sql);
 
-    $sql = "delete from $table\n";
+    my $table_def = $self->get_table_def($table);
+    my $realtable = $table_def->{table} || $table;
+    $sql = "delete from $realtable\n";
     $sql .= $self->_mk_where_clause($table, $params);
     &App::sub_exit($sql) if ($App::trace);
     $sql;

Reply via email to