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

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Thu, 04 Aug 2022 11:58:27 UTC
On Thu, Aug 04, 2022 at 04:17:49PM +0900, Tatsuki Makino wrote:
> 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);
> 
> 

Good catch, thanks, pushed in the repo:
https://github.com/freebsd/pkg/commit/a1f6f620b4671d924f5fad3f24c2d7abc3b229cb

Will be in the next release of pkg!!

Best regards,
Bapt