Hello Andreas
On Thu, Jul 11, 2013 at 4:59 PM, Andreas Tille <[email protected]> wrote: > On Thu, Jul 11, 2013 at 03:01:21PM +0200, Andreas Tille wrote: > > On Thu, Jul 11, 2013 at 02:47:19PM +0200, Andreas Tille wrote: > > > query = """PREPARE blend_check_existing_package_provides AS > > > SELECT DISTINCT provides, p.distribution, component, > r.sort FROM packages p > > > JOIN releases r ON p.release = r.release > > > WHERE provides ~ ('[ ,]*'||$1||'[ ,]*') > > > ORDER BY r.sort DESC > > > LIMIT 1""" > > > > I think > > > > provides ~ ('\b'||'freeb'||'\b'); > > Damn: > > udd=# SELECT DISTINCT provides, p.distribution, component, r.sort FROM > packages p > JOIN releases r ON p.release = r.release > WHERE provides ~ ('\b'||'djvu-viewer'||'\b'); > provides | distribution | component | sort > ----------+--------------+-----------+------ > (0 Zeilen) > > > While we get no false positives like freeb we also do not get what we > really want to catch. :-( > > Keep on thinking what regexp will fetch those *real* virtual packages. > > If all else fails we need to create a function that turns the string > into an array and then query the array ... > > 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. PS: I have a local UDD instance, the extra "," was a mistake, probably from a copy paste without testing :-( Kind regards Emmanouil
