<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>> I've been looking for a way to do SELECT FOR UPDATE
via DBIx::Class</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>Hi all,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>A couple of months ago I had to implement a similar
requirement for DBIx::DataModel, and came to some conclusions that are probably
worth sharing with the DBIC community : </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>1) The SELECT ... FOR ... syntax may have other variants
than 'SHARE' or 'UPDATE'. For example I'm working with a database that
understands statements like "SELECT ... FOR READ ONLY" (for the curious : that
database is "Livelink Collection Server", formerly "Basis+"). So what you put
after the "FOR" should not be hardcoded, it should be programmable by the client
code.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>2) This example shows a general problem with
SQL::Abstract::select : positional arguments are too limitative, because you can
only express select($columns, $table, $where). The solution in DBIx::DataModel
was to add an intermediate layer that can understand named arguments
like</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2> select(-columns => ..., -where => ...., -for
=> "read only", etc)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007></SPAN><FONT
face=Arial><FONT size=2><FONT color=#0000ff>T<SPAN class=434151609-04072007>hen
these are parsed</SPAN><SPAN class=434151609-04072007> and translated into
arguments suitable for SQL::Abstract. But it would be much better if
SQL::Abstract itself could evolve into a new API with named arguments. I heard
in Matt Trout's podcast that in a near future SQL::Abstract is going to be
maintained by the DBIC community : when that happens, adding a richer
API could be a nice evolution project.</SPAN></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>3) Even positional arguments may not be sufficient :
sometimes you need to tweak the generated SQL. With Livelink Collection Server,
I sometimes need a "SELECT ... WHERE NATIVE ('some db-specific syntax')". To do
this, DBIx::DataModel has a "-postSQL" callback that can manipulate the
result of SQL::Abstract. I haven't seen such a feature in DBIC; but I'm sure
some clients would need it (sorry if it's already there and I missed it).
Overriding the "select" method in subclasses is not enough, because those
details may vary from statement to statement.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2>Regards, L. Dami</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=434151609-04072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV></BODY></HTML>