On Thu, Jun 26, 2008 at 4:08 PM, Ruslan Zakirov <<a href="mailto:ruz@bestpractical.com">ruz@bestpractical.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
subclauses is the way to deal with that and open_paren/close_paren.<br>
<br>
something like:<br>
$col->limit( column => 'parent', value => 12 );<br>
$col->limit( column => 'task_type', value => 'action' );<br>
$col->open_paren("my_clause");<br>
$col->limit( subclause => "my_clause", column => 'status', value => 'open' );<br>
$col->open_paren("my_clause");<br>
$col->limit( subclause => "my_clause", column => 'status', value =><br>
'done', entry_aggregator => 'OR' );<br>
$col->limit( subclause => "my_clause", column => 'completed_on',<br>
<div class="Ih2E3d">operator => '>=', value => '2008-06-26 11:39:22' );<br>
</div>$col->close_paren("my_clause");<br>
$col->close_paren("my_clause");</blockquote><div><br>Thank you. I've been trying to understand the use of subclauses and open_paren/close_paren, but was at loss. I'll put that into the docs. I do note, however, that open_paren/close_paren have a "don't do this, we'll change this as soon as we figure out how" note on it.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
May be it's not ideal, but pure SQL is not a good too.</blockquote><div><br>No, it is not ideal, at least not as long as we can't get anyone to agree on what SQL is. However, if you're writing a quick and dirty app, SQL is an excellent shortcut. I don't always need the ideal solution, but one that is simple and works.<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
With tisql you can do:<br>
<br>
$col->tisql( "parent = 12 AND task_type = 'action' AND (status =<br>
<div class="Ih2E3d">'open' OR (status = 'done' AND completed_on >= '2008-06-26<br>
</div>11:39:22'))" );<br>
<br>
But I found some design problems with tisql and have to rethink<br>
language to address issues with one-to-many relations.</blockquote><div><br>I would love to see this incorporated into the trunk. But until then...<br><br>Cheers,<br>Sterling<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Thu, Jun 26, 2008 at 9:23 PM, Sterling Hanenkamp<br>
<<a href="mailto:sterling@hanenkamp.com">sterling@hanenkamp.com</a>> wrote:<br>
> Every so often I want to defenestrate Jifty::DBI for the simple fact that I<br>
> cannot describe a basic WHERE clause with it. For example, the query:<br>
><br>
> SELECT *<br>
> FROM tasks<br>
> WHERE parent = 12 AND task_type = 'action' AND (status = 'open' OR (status =<br>
> 'done' AND completed_on >= '2008-06-26 11:39:22'))<br>
><br>
> Is there a way to do this? I haven't found a combination of limits and<br>
> subclauses that will let me do this that works. The code within limit() is<br>
> pretty complicated, so I haven't been able to unravel what it is doing, let<br>
> alone how this is supposed to work. I'll write up a complex query example in<br>
> the documentation if someone will give me a demonstration on how this is<br>
> supposed to be done. I have not found a good example of a complex query<br>
> either.<br>
><br>
> My other issue with limit is that the format used in limit() is pretty<br>
> verbose. Has there been any consideration for allowing arbitrary SQL to be<br>
> used. I.e., this is arguably more straitforward:<br>
><br>
> $tasks->limit(sql => "completed_on >= '2008-06-26 11:39:22'");<br>
><br>
> than:<br>
><br>
> $tasks->limit(column => 'completed_on', operator => '>=', value =><br>
> '2008-06-26 11:39:22');<br>
><br>
> Or the use of a more flexible and compact format for limits, such as is used<br>
> by SQL::Abstract:<br>
><br>
> $tasks->limit(abstract => [ completed_on => [ '>=', '2008-06-26 11:39:22' ]<br>
> ]);<br>
><br>
> Cheers,<br>
> Sterling<br>
><br>
</div></div>> _______________________________________________<br>
> jifty-devel mailing list<br>
> <a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br>
> <a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Best regards, Ruslan.<br>
_______________________________________________<br>
jifty-devel mailing list<br>
<a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br>
<a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br>
</font></blockquote></div><br>