[Jifty-commit] jifty branch, jifty_client, updated. d6e7088ba7640cab9113b0c0fc83671169e4f329

Jifty commits jifty-commit at lists.jifty.org
Mon May 17 03:07:28 EDT 2010


The branch, jifty_client has been updated
       via  d6e7088ba7640cab9113b0c0fc83671169e4f329 (commit)
      from  a7243571c8649fb866c8dd44cbacc417e6bddc3e (commit)

Summary of changes:
 lib/Jifty/Plugin/REST/Dispatcher.pm |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit d6e7088ba7640cab9113b0c0fc83671169e4f329
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon May 17 16:07:16 2010 +0900

    Don't use a type constraint if the column has filters
    
        Type constraints break such filters as Jifty::DBI::Filter::Duration
        which puts integers in the database, but exposes strings to the API.

diff --git a/lib/Jifty/Plugin/REST/Dispatcher.pm b/lib/Jifty/Plugin/REST/Dispatcher.pm
index e479e69..0b90476 100644
--- a/lib/Jifty/Plugin/REST/Dispatcher.pm
+++ b/lib/Jifty/Plugin/REST/Dispatcher.pm
@@ -982,18 +982,27 @@ sub show_joose_class {
             }
         }
 
-        if ($col->name eq 'id') {
-            $props->{isa} = 'Joose.Type.Int';
-        }
-        elsif ($col->is_string) {
-            $props->{isa} = 'Joose.Type.Str';
-        }
-        elsif ($col->is_numeric) {
-            $props->{isa} = 'Joose.Type.Num';
-        }
-        elsif ($col->is_boolean) {
+        # column types only affect what is stored in the database. using types
+        # with filters breaks attributes using, say,
+        # Jifty::DBI::Filter::Duration. though boolean is implemented as
+        # a filter so it is special-cased
+        my @filters = ($col->input_filters, $col->output_filters);
+
+        if ($col->is_boolean) {
             $props->{isa} = 'Joose.Type.Bool';
         }
+        elsif (@filters == 0) {
+            if ($col->name eq 'id') {
+                $props->{isa} = 'Joose.Type.Int';
+            }
+            elsif ($col->is_string) {
+                $props->{isa} = 'Joose.Type.Str';
+            }
+            elsif ($col->is_numeric) {
+                $props->{isa} = 'Joose.Type.Num';
+            }
+
+        }
 
         # always coerce because our REST API output is always strings even
         # for int and bool columns

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list