r73242 - in /trunk/libdancer-plugin-database-perl: Changes META.yml README debian/changelog lib/Dancer/Plugin/Database.pm lib/Dancer/Plugin/Database/Handle.pm t/lib/TestApp.pm

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sat Apr 23 16:55:52 UTC 2011


Author: gregoa
Date: Sat Apr 23 16:55:42 2011
New Revision: 73242

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=73242
Log:
* New upstream release 1.23.

Modified:
    trunk/libdancer-plugin-database-perl/Changes
    trunk/libdancer-plugin-database-perl/META.yml
    trunk/libdancer-plugin-database-perl/README
    trunk/libdancer-plugin-database-perl/debian/changelog
    trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database.pm
    trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database/Handle.pm
    trunk/libdancer-plugin-database-perl/t/lib/TestApp.pm

Modified: trunk/libdancer-plugin-database-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/Changes?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/Changes (original)
+++ trunk/libdancer-plugin-database-perl/Changes Sat Apr 23 16:55:42 2011
@@ -1,4 +1,15 @@
 Revision history for Dancer-Plugin-Database
+
+1.23    2011-04-15
+        - Only log queries generated by quick_*() helpers in D::P::D::Handle if
+          the log_queries setting was enabled in the configuration.  This avoids
+          the potential for the user to be unwittingly logging sensitive
+          information, and would provide a (tiny) performance boost too.
+
+1.22    2011-04-11
+        - Bugfix: don't needlessly use to_json() in tests, as Dancer doesn't
+          depend on JSON.pm, so tests will fail if it's not available.
+          Reported in RT #66204 by Johnathan (JAWNSY) - thanks!
 
 1.21    2011-03-06
         - Bugfix: return undef if connection fails, rather than attempting to

Modified: trunk/libdancer-plugin-database-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/META.yml?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/META.yml (original)
+++ trunk/libdancer-plugin-database-perl/META.yml Sat Apr 23 16:55:42 2011
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Dancer-Plugin-Database
-version:            1.21
+version:            1.23
 abstract:           easy database connections for Dancer applications
 author:
     - David Precious <davidp at preshweb.co.uk>

Modified: trunk/libdancer-plugin-database-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/README?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/README (original)
+++ trunk/libdancer-plugin-database-perl/README Sat Apr 23 16:55:42 2011
@@ -67,6 +67,7 @@
                     RaiseError: 1
                     AutoCommit: 1
                 on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ]
+                log_queries: 1
 
     The `connection_check_threshold' setting is optional, if not provided,
     it will default to 30 seconds. If the database keyword was last called
@@ -82,6 +83,14 @@
     The optional `on_connect_do' setting is an array of queries which should
     be performed when a connection is established; if given, each query will
     be performed using `$dbh->do'.
+
+    The optional `log_queries' setting enables logging of queries generated
+    by the helper functions `quick_insert' et al in
+    Dancer::Plugin::Database::Handle. If you enable it, generated queries
+    will be logged at 'debug' level. Be aware that they will contain the
+    data you're passing to/from the database, so be careful not to enable
+    this option in production, where you could inadvertently log sensitive
+    information.
 
     If you prefer, you can also supply a pre-crafted DSN using the `dsn'
     setting; in that case, it will be used as-is, and the

Modified: trunk/libdancer-plugin-database-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/debian/changelog?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/debian/changelog (original)
+++ trunk/libdancer-plugin-database-perl/debian/changelog Sat Apr 23 16:55:42 2011
@@ -1,16 +1,16 @@
-libdancer-plugin-database-perl (1.21-1) UNRELEASED; urgency=low
+libdancer-plugin-database-perl (1.23-1) UNRELEASED; urgency=low
 
-  IGNORE-VERSION: 1.21-1
-  Contacted the author about build-depends issue, waiting for a new
-  release: https://rt.cpan.org/Ticket/Display.html?id=66204
-
-  * New upstream release
+  [ Jonathan Yu ]
+  * New upstream release 1.21
   * Add myself to Copyright
   * Rewrite control description
   * Add Build-Depends on libjson-perl, as it is needed for tests. It
     is not needed during runtime, as nothing in lib/ contains 'json'
 
- -- Jonathan Yu <jawnsy at cpan.org>  Mon, 07 Mar 2011 19:22:23 -0500
+  [ gregor herrmann ]
+  * New upstream release 1.23.
+
+ -- gregor herrmann <gregoa at debian.org>  Sat, 23 Apr 2011 18:54:41 +0200
 
 libdancer-plugin-database-perl (1.00-1) unstable; urgency=low
 

Modified: trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database.pm?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database.pm (original)
+++ trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database.pm Sat Apr 23 16:55:42 2011
@@ -12,7 +12,7 @@
 
 =cut
 
-our $VERSION = '1.21';
+our $VERSION = '1.23';
 
 my $settings = undef;
 
@@ -161,6 +161,12 @@
         }
     }
 
+    # Indicate whether queries generated by quick_query() etc in
+    # Dancer::Plugin::Database::Handle should be logged or not; this seemed a
+    # little dirty, but DBI's docs encourage it
+    # ("You can stash private data into DBI handles via $h->{private_..._*}..")
+    $dbh->{_private_log_queries} = $settings->{log_queries};
+
     # Re-bless it as a Dancer::Plugin::Database::Handle object, to provide nice
     # extra features:
     return bless $dbh, 'Dancer::Plugin::Database::Handle';
@@ -298,6 +304,7 @@
                 RaiseError: 1
                 AutoCommit: 1
             on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ]
+            log_queries: 1
 
 The C<connection_check_threshold> setting is optional, if not provided, it
 will default to 30 seconds.  If the database keyword was last called more than
@@ -313,6 +320,13 @@
 The optional C<on_connect_do> setting is an array of queries which should be
 performed when a connection is established; if given, each query will be
 performed using C<< $dbh->do >>.
+
+The optional C<log_queries> setting enables logging of queries generated by the
+helper functions C<quick_insert> et al in L<Dancer::Plugin::Database::Handle>.
+If you enable it, generated queries will be logged at 'debug' level.  Be aware
+that they will contain the data you're passing to/from the database, so be
+careful not to enable this option in production, where you could inadvertently
+log sensitive information.
 
 If you prefer, you can also supply a pre-crafted DSN using the C<dsn> setting;
 in that case, it will be used as-is, and the driver/database/host settings will 

Modified: trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database/Handle.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database/Handle.pm?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database/Handle.pm (original)
+++ trunk/libdancer-plugin-database-perl/lib/Dancer/Plugin/Database/Handle.pm Sat Apr 23 16:55:42 2011
@@ -157,9 +157,18 @@
         $sql .= ' LIMIT 1';
     }
 
-    Dancer::Logger::debug(
-        "Executing $type query $sql with params " . join ',', @bind_params
-    );
+    # Dancer::Plugin::Database will have looked at the log_queries setting and
+    # stashed it away for us to see:
+    if ($self->{_private_log_queries}) {
+        Dancer::Logger::debug(
+            "Executing $type query $sql with params " . join ',', 
+            map { 
+                $_ =~ /^[[:ascii:]]+$/ ? 
+                    length $_ > 50 ? substr($_, 0, 47) . '...' : $_
+                : "[non-ASCII data not logged]" 
+            } @bind_params
+        );
+    }
 
     # Select queries, in scalar context, return the first matching row; in list
     # context, they return a list of matching rows.

Modified: trunk/libdancer-plugin-database-perl/t/lib/TestApp.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-plugin-database-perl/t/lib/TestApp.pm?rev=73242&op=diff
==============================================================================
--- trunk/libdancer-plugin-database-perl/t/lib/TestApp.pm (original)
+++ trunk/libdancer-plugin-database-perl/t/lib/TestApp.pm Sat Apr 23 16:55:42 2011
@@ -60,7 +60,8 @@
 
 get '/quick_select/:id' => sub {
     my $row = database->quick_select('users', { id => params->{id} });
-    return to_json($row || { error => 'No matching user' });
+    return $row ? join(',', values %$row) 
+        : "No matching user"; 
 };
 
 get '/quick_select_many' => sub {




More information about the Pkg-perl-cvs-commits mailing list