Skip Menu |

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

Report information
The Basics
Id: 125805
Status: new
Worked: 2 hours (120 min)
Priority: 0/
Queue: SQL-Abstract

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

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



Subject: propose new method sqlwhere
Show quoted text
> Just generate the WHERE clause > my($where, @bind) = $sql->where(\%where, $order);
I find myself doing the "$sqlpart $where" join all of the time. Can it be moved into this package with the correct error checking, joining, etc.? =head2 sqlwhere This is used to generate statement given the known SQL part (not including WHERE or ORDER BY clauses) and data structures to produce the WHERE and ORDER BY clauses. It returns the full SQL statement and list of bind values. my($stmt, @bind) = $sql->sqlwhere($sqlpart, \%where, $order); =cut sub sqlwhere { my $self = shift; my $sqlpart = shift; my ($where, @bind) = $self->where(@_); my $stmt = "$sqlpart $where"; #add error checking here. Is space join portable? return($stmt, @bind); } mrdvt92
On Tue Jul 10 09:44:47 2018, MRDVT wrote: Show quoted text
> I find myself doing the "$sqlpart $where" join all of the time. Can > it be moved into this package with the correct error checking, > joining, etc.?
I implemented this in DBIx::Array 0.61 (not yet released) as below. However, I have no idea if the implementation is portable across all DBD drivers. I use on MySQL, Oracle and ProgresSQL and the tests are written against SQLLite. sub sqlwhere { my $self = shift; my $sqlpart = shift; my ($where, @bind) = $self->abs->where(@_); $sqlpart .= " $/ $where" if length($where); return($sqlpart, @bind); }