Skip Menu |

This queue is for tickets about the DBIx-Simple CPAN distribution.

Report information
The Basics
Id: 22828
Status: rejected
Priority: 0/
Queue: DBIx-Simple

People
Owner: Nobody in particular
Requestors: BORISZ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: allow ( ?? ) and (?? ) and more instead of just (??) in a query
Hi, I really like to write $db->query(q{ INSERT INTO xx ( name, street ) VALUES ( ?? ) }, $name, $street ); It just looks better to me. please apply the attached patch -- Boris
Subject: allow_q_with_spaces.patch
- Add: ( ?? ) instead of only (??) --- commit df2d95344e3f3c462600cb56ee8f6e15a20329ac tree c89e2d6957189649d3f2f766d12d6fe617a2998c parent bcb0aafe074e673d5f45104f8261dfd0cad759e1 author Boris Zentner <borisz@lisa.local> Sun, 05 Nov 2006 16:57:16 +0100 committer Boris Zentner <borisz@lisa.local> Sun, 05 Nov 2006 16:57:16 +0100 lib/DBIx/Simple.pm | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/DBIx/Simple.pm b/lib/DBIx/Simple.pm index 443c796..73851c7 100644 --- a/lib/DBIx/Simple.pm +++ b/lib/DBIx/Simple.pm @@ -8,6 +8,9 @@ $DBIx::Simple::VERSION = '1.26'; $Carp::Internal{$_} = 1 for qw(DBIx::Simple DBIx::Simple::Result DBIx::Simple::DeadObject); +# omniholder regex +my $oh = qr/\([ \t]*\?\?[ \t]*\)/; + my $quoted = qr/'(?:\\.|[^\\']+)*'|"(?:\\.|[^\\"]+)*"/s; my %statements; # "$db" => { "$st" => $st, ... } @@ -79,10 +82,10 @@ sub _gimme_regex { no strict 'refs'; *{ # Replace (??) with (?, ?, ?, ...) sub _replace_omniholder { my ($self, $query, $binds) = @_; - return if $$query !~ /\(\?\?\)/; + return if $$query !~ /$oh/; my $omniholders = 0; - $$query =~ s[(\(\?\?\)|$quoted+|(?:(?!\(\?\?\)).)+)] { - $1 eq '(??)' + $$query =~ s[($oh|$quoted+|(?:(?!$oh).)+)] { + $1 =~ /^$oh$/ ? do { Carp::croak('There can be only one omniholder') if $omniholders++;
Although I reserve the right to change my mind, I see (??) as a 4 character single token. Any deviation might suggest that it is okay to use other characters in the omniholder, and that not (??), but only ?? is special. -- Juerd