Browse Source

One more fix to the chado_query regular expressions to handle nested select statements where the FROM doesn't have a table but a nested statement

spficklin 12 years ago
parent
commit
7a8f7da935
1 changed files with 3 additions and 3 deletions
  1. 3 3
      tripal_core/api/tripal_core.api.inc

+ 3 - 3
tripal_core/api/tripal_core.api.inc

@@ -2238,9 +2238,9 @@ function chado_query($sql) {
     // we use the FROM keyword to look for tables, but FROM is also used in the 
     // 'substring' function of postgres. But since table names can't start with 
     // a number we exclude words numeric values. We also exclude tables that
-    // already have a schema prefix.
-    $sql = preg_replace('/FROM\s+([^0123456789][^\.]*?)\s/i', 'FROM chado.\1 ', $sql);
-    $sql = preg_replace('/INNER\s+JOIN\s+([^0123456789][^\.]*?)\s/i', 'INNER JOIN chado.\1 ', $sql);
+    // already have a schema prefix. 
+    $sql = preg_replace('/FROM\s+([^0123456789\(][^\.]*?)\s/i', 'FROM chado.\1 ', $sql);
+    $sql = preg_replace('/INNER\s+JOIN\s+([^\.]*?)\s/i', 'INNER JOIN chado.\1 ', $sql);
   }
   //print "$sql\n";