Skip Menu |

This queue is for tickets about the SQL-Interp CPAN distribution.

Report information
The Basics
Id: 30652
Status: resolved
Priority: 0/
Queue: SQL-Interp

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

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



Subject: Support for MySQL’s ON DUPLICATE KEY UPDATE clause
Hi Mark, it would be nice if SQL::Interp treated `ON DUPLICATE KEY UPDATE` (an optional clause on `INSERT` statements) as an alternative spelling of `SET`. Right now I hack around this by wrapping the sql_interp function and substituting a `SET` into my SQL in the right places in the input, then substituting it back out in the output. It would be cool if this Just Worked. -- Aristotle
Subject: Re: [rt.cpan.org #30652] Support for MySQL’s ON DUPLICATE KEY UPDATE clause
Date: Sun, 11 Nov 2007 19:57:03 -0500
To: bug-SQL-Interp [...] rt.cpan.org
From: Mark Stosberg <mark [...] summersault.com>
Show quoted text
> it would be nice if SQL::Interp treated `ON DUPLICATE KEY UPDATE` (an > optional clause on `INSERT` statements) as an alternative spelling of > `SET`. Right now I hack around this by wrapping the sql_interp function > and substituting a `SET` into my SQL in the right places in the input, > then substituting it back out in the output. It would be cool if this > Just Worked.
Aristotle, That sounds reasonable. I'll take a look at what's involved. Mark
On Sun Nov 11 19:57:37 2007, mark@summersault.com wrote: Show quoted text
> I'll take a look at what's involved.
I think you just need to change one pattern match; see attached patch. Seems to work fine for me anyway.
--- Interp.pm.orig 2007-11-12 12:07:33.000000000 +0100 +++ Interp.pm 2007-11-12 12:08:38.000000000 +0100 @@ -182,2 +182,2 @@ - elsif ($sql =~ /\bSET\s*$/si && ref $item eq 'HASH') { + elsif ($sql =~ /\b(?:ON\s+DUPLICATE\s+KEY\s+UPDATE|SET)\s*$/si && ref $item eq 'HASH') { _error('Hash has zero elements.') if keys %$item == 0;
Accepted and about to released. Mark