Re: ports-mgmt/pkg: pkg query -e %#r condition doesn't match properly <PSAPR03MB5639FB7587281A570DE507F9FA9C9@PSAPR03MB5639.apcprd03

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Thu, 04 Aug 2022 07:17:49 UTC
Looking at "pkg shell .dump | grep \ deps\ " results, it seems that origin without @flavor is not unique.
However, ports that use FLAVORS are modified to make the PKGNAME unique.

So, the following patch is applied and it seems to be working properly.
The commands used in the tests are as follows.

pkg query -e "%#r > 2" "%n:%#r" | sort -t : -k 2nr -k 1

If someone has already repaired it, forget it :)

Regards.

--- src/query.c.orig	2022-08-03 07:37:06 UTC
+++ src/query.c
@@ -557,7 +557,7 @@ format_sql_condition(const char *str, xstring *sqlcond
 							fprintf(sqlcond->fp, "(SELECT %s FROM deps AS d WHERE d.package_id=p.id)", sqlop);
 							break;
 						case 'r':
-							fprintf(sqlcond->fp, "(SELECT %s FROM deps AS d WHERE d.origin=p.origin)", sqlop);
+							fprintf(sqlcond->fp, "(SELECT %s FROM deps AS d WHERE d.name=p.name)", sqlop);
 							break;
 						case 'C':
 							fprintf(sqlcond->fp, "(SELECT %s FROM pkg_categories AS d WHERE d.package_id=p.id)", sqlop);