Fix Verisoned.pm to not issue queries that break down with quoting
Peter Rabbitson [Sun, 8 Aug 2010 11:31:36 +0000 (13:31 +0200)]
enabled. Also simplify table-test SQL. (RT#59619)

Changes
lib/DBIx/Class/Schema/Versioned.pm

diff --git a/Changes b/Changes
index d33253b..ad96f1c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -18,6 +18,8 @@ Revision history for DBIx::Class
           column in the GROUP BY clause
         - Properly support column names with symbols (e.g. single quote)
           via custom accessors
+        - Fixed ::Schema::Versioned to work properly with quoting on
+          (RT#59619)
 
     * Misc
         - Refactored capability handling in Storage::DBI, allows for
index 052f8e7..5a861ba 100644 (file)
@@ -725,9 +725,12 @@ sub _source_exists
 {
     my ($self, $rs) = @_;
 
-    my $c = try { $rs->search({ 1, 0 })->count };
-
-    return (defined $c) ? 1 : 0;
+    return try {
+      $rs->search(\'1=0')->cursor->next;
+      1;
+    } catch {
+      0;
+    };
 }
 
 1;