Hello Andreas
On Thu, Jul 11, 2013 at 8:29 PM, Andreas Tille <[email protected]> wrote: > On Thu, Jul 11, 2013 at 06:30:20PM +0300, Emmanouil Kiagias wrote: > > > Any idea? > > > > > > Oups I did not think of this case (like the "freeb" example). Instead > of > > regex(to be honest I did not find anything new on this) I think this fits > > us: > > > > query=""" > > SELECT DISTINCT provides, p.distribution, component, > > r.sort FROM packages p > > JOIN releases r ON p.release = r.release > > WHERE provides SIMILAR TO '{0}|{0},%|% {0} %|% {0}, %' > > ORDER BY r.sort DESC > > LIMIT 1 > > """.format('djvu-viewer') > > > > A "similar to" with multiple OR statements inside to cover our cases: > > single OR virtual, % OR % virtual % OR % virtual. > > At first it looks fine, I need to make more tests. This example does not > > catch "freeb" and catches correctly the "djvu-viewer" > > Let me know what you think. > > Uhm, need to cope with the {0} syntax. Meanwhile I've got a hint from a > (German) psql list: > > its :.. WHERE provides SIMILAR TO 'djvu-viewer|djvu-viewer,%|% djvu-viewer %|% djvu-viewer, %' so {0} just replaces the first(0 index) element of the format() function which in our case is the 'djvu-viewer' string. it can be similar in the EXECUTE as : ... WHERE provides SIMILAR TO '$1|$1,%|% $1 %|% $1, %' Anyway as you said everything that works is fine :-) .Are you going to commit the patch? Or we need to make more tests? Kind regards Emmanouil
