Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[Squerl] can return rows for arbitrary SQL

  • Loading branch information...
commit f2b110dd44e160ac843c314712aca214bd02a42f 1 parent 5cddf99
Carl Mäsak authored September 23, 2009
9  lib/Squerl.pm
@@ -114,7 +114,14 @@ class Squerl::Dataset does Positional {
114 114
         $name;
115 115
     }
116 116
 
  117
+    method static_sql($sql) {
  118
+        $sql
  119
+    }
  120
+
117 121
     method select_sql() {
  122
+        return self.static_sql(%!opts<sql>)
  123
+            if %!opts.exists('sql');
  124
+
118 125
         # RAKUDO: Real string interpolation
119 126
         "SELECT * FROM {%!opts<from>}"
120 127
         ~ (%!opts.exists('filter')
@@ -168,7 +175,7 @@ class Squerl::Dataset does Positional {
168 175
 
169 176
     method update_sql(*%nameds) {
170 177
         my $values = join $COMMA_SEPARATOR, map {
171  
-            "{.key} = {self.literal(.value)}" 
  178
+            "{.key} = {self.literal(.value)}"
172 179
         }, %nameds.pairs;
173 180
         "UPDATE {%!opts<from>} SET $values";
174 181
     }
5  t/squerl/02-dataset.t
@@ -251,4 +251,9 @@ role R2 { method values { {} } }
251 251
        'format an update statement';
252 252
 }
253 253
 
  254
+{
  255
+    is $dataset.clone(:sql('xxx yyy zzz')).select_sql(), 'xxx yyy zzz',
  256
+       'return rows for arbitrary SQL';
  257
+}
  258
+
254 259
 done_testing;

0 notes on commit f2b110d

Please sign in to comment.
Something went wrong with that request. Please try again.