[Jifty-commit] jifty-dbi branch, master, updated. 0.74-5-gecdcb17

Jifty commits jifty-commit at lists.jifty.org
Sun Nov 4 01:55:12 EST 2012


The branch, master has been updated
       via  ecdcb17af5e4d8debd3b58f17e30cede29b309d5 (commit)
       via  ebf655c2f54023b2de564d401750a0af16f37af2 (commit)
      from  cfb2d769160fd102a30026dc6aba6ce3596ad367 (commit)

Summary of changes:
 lib/Jifty/DBI/Filter/DateTime.pm |   8 +++
 lib/Jifty/DBI/Record.pm          | 105 ++++++++++++++++++++-------------------
 2 files changed, 62 insertions(+), 51 deletions(-)

- Log -----------------------------------------------------------------
commit ebf655c2f54023b2de564d401750a0af16f37af2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sun Nov 4 00:53:15 2012 -0400

    Don't attempt to filter, eq-check, validate, or otherwise munge functions

diff --git a/lib/Jifty/DBI/Record.pm b/lib/Jifty/DBI/Record.pm
index 62b54fc..94cab9e 100755
--- a/lib/Jifty/DBI/Record.pm
+++ b/lib/Jifty/DBI/Record.pm
@@ -962,65 +962,68 @@ sub __set {
         return ( $ret->return_value );
     }
 
-    $self->_apply_input_filters(
-        column    => $column,
-        value_ref => \$args{'value'}
-    );
+    my $unmunged_value;
+    unless ($args{is_sql_function}) {
+        $self->_apply_input_filters(
+            column    => $column,
+            value_ref => \$args{'value'}
+        );
 
-    # if value is not fetched or it's already decoded
-    # then we don't check eqality
-    # we also don't call __value because it decodes value, but
-    # we need encoded value
-    if ( $self->{'fetched'}{ $column->name }
-        || !$self->{'decoded'}{ $column->name } )
-    {
-        if ((      !defined $args{'value'}
-                && !defined $self->{'values'}{ $column->name }
-            )
-            || (   defined $args{'value'}
-                && defined $self->{'values'}{ $column->name }
-
-                # XXX: This is a bloody hack to stringify DateTime
-                # and other objects for compares
-                && $args{value}
-                . "" eq ""
-                . $self->{'values'}{ $column->name }
-            )
-            )
+        # if value is not fetched or it's already decoded
+        # then we don't check eqality
+        # we also don't call __value because it decodes value, but
+        # we need encoded value
+        if ( $self->{'fetched'}{ $column->name }
+            || !$self->{'decoded'}{ $column->name } )
         {
-            $ret->as_array( 1, "That is already the current value" );
-            return ( $ret->return_value );
+            if ((      !defined $args{'value'}
+                    && !defined $self->{'values'}{ $column->name }
+                )
+                || (   defined $args{'value'}
+                    && defined $self->{'values'}{ $column->name }
+
+                    # XXX: This is a bloody hack to stringify DateTime
+                    # and other objects for compares
+                    && $args{value}
+                    . "" eq ""
+                    . $self->{'values'}{ $column->name }
+                )
+                )
+            {
+                $ret->as_array( 1, "That is already the current value" );
+                return ( $ret->return_value );
+            }
         }
-    }
 
-    if ( my $sub = $column->validator ) {
-        my ( $ok, $msg ) = $sub->( $self, $args{'value'} );
-        unless ($ok) {
-            $ret->as_array( 0, 'Illegal value for ' . $column->name );
-            $ret->as_error(
-                errno        => 3,
-                do_backtrace => 0,
-                message      => "Illegal value for " . $column->name
-            );
-            return ( $ret->return_value );
+        if ( my $sub = $column->validator ) {
+            my ( $ok, $msg ) = $sub->( $self, $args{'value'} );
+            unless ($ok) {
+                $ret->as_array( 0, 'Illegal value for ' . $column->name );
+                $ret->as_error(
+                    errno        => 3,
+                    do_backtrace => 0,
+                    message      => "Illegal value for " . $column->name
+                );
+                return ( $ret->return_value );
+            }
         }
-    }
 
-    # Implement 'is distinct' checking
-    if ( $column->distinct ) {
-        my $ret = $self->is_distinct( $column->name, $args{'value'} );
-        return ($ret) if not($ret);
-    }
+        # Implement 'is distinct' checking
+        if ( $column->distinct ) {
+            my $ret = $self->is_distinct( $column->name, $args{'value'} );
+            return ($ret) if not($ret);
+        }
 
-    # The blob handling will destroy $args{'value'}. But we assign
-    # that back to the object at the end. this works around that
-    my $unmunged_value = $args{'value'};
+        # The blob handling will destroy $args{'value'}. But we assign
+        # that back to the object at the end. this works around that
+        $unmunged_value = $args{'value'};
 
-    if ( $column->type =~ /^(text|longtext|clob|blob|lob|bytea)$/i ) {
-        my $bhash
-            = $self->_handle->blob_params( $column->name, $column->type );
-        $bhash->{'value'} = $args{'value'};
-        $args{'value'} = $bhash;
+        if ( $column->type =~ /^(text|longtext|clob|blob|lob|bytea)$/i ) {
+            my $bhash
+                = $self->_handle->blob_params( $column->name, $column->type );
+            $bhash->{'value'} = $args{'value'};
+            $args{'value'} = $bhash;
+        }
     }
 
     my $val = $self->_handle->update_record_value(

commit ecdcb17af5e4d8debd3b58f17e30cede29b309d5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sun Nov 4 01:54:26 2012 -0500

    Work around Pg's sub-second formatting and DateTime::Parser::ISO8601

diff --git a/lib/Jifty/DBI/Filter/DateTime.pm b/lib/Jifty/DBI/Filter/DateTime.pm
index 45bc466..732fc39 100644
--- a/lib/Jifty/DBI/Filter/DateTime.pm
+++ b/lib/Jifty/DBI/Filter/DateTime.pm
@@ -104,6 +104,14 @@ sub decode {
 # but we need Jifty::DBI::Handle here to get DB type
 
     my $str = join('T', split ' ', $$value_ref, 2);
+
+    # The ISO8601 parser accepts 2012-11-04T12:34:56+00
+    #                        and 2012-11-04T12:34:56.789+00:00
+    #                    but not 2012-11-04T12:34:56.789+00
+    # Postgres returns sub-second times as the last one; append ":00" to
+    # change it into the acceptable second option.
+    $str .= ":00" if $str =~ /\d\.\d+[+-]\d\d$/;
+
     my $dt;
     eval { $dt  = $self->_parser->parse_datetime($str) };
 

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


More information about the Jifty-commit mailing list