Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aakropotkin committed Aug 23, 2023
1 parent 2f39afb commit d128d9e
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions src/pkgdb/query-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ PkgQueryArgs::validate() const
return error_code::PDQEC_INVALID_STABILITY;
}
}
if ( ( this->subtrees.value().size() != 1 ) ||
( this->subtrees.value().front() != ST_CATALOG )
if ( ( this->subtrees.has_value() ) &&
( ( this->subtrees.value().size() != 1 ) ||
( this->subtrees.value().front() != ST_CATALOG )
)
)
{
return error_code::PDQEC_CONFLICTING_SUBTREE;
Expand Down Expand Up @@ -211,20 +213,6 @@ buildPkgQuery( const PkgQueryArgs & params )
{
q.where( column( "subtree" ) == "catalog" );
}
else if ( params.subtrees.has_value() && params.subtrees.value().size() == 1 )
{
std::string s;
switch ( params.subtrees.value().front() )
{
case ST_LEGACY: s = "legacyPackages"; break;
case ST_PACKAGES: s = "packages"; break;
case ST_CATALOG: s = "catalog"; break;
default:
throw PkgQueryArgs::PkgQueryInvalidArgException();
break;
}
q.where( column( "subtree" ) == s );
}
else if ( params.subtrees.has_value() )
{
std::vector<std::string> lst;
Expand All @@ -244,14 +232,7 @@ buildPkgQuery( const PkgQueryArgs & params )
}

/* Systems */
if ( params.systems.size() == 1 )
{
q.where( column( "system" ) == params.systems.front() );
}
else
{
q.where( column( "system" ).in( params.systems ) );
}
q.where( column( "system" ).in( params.systems ) );

/* Stabilities */
if ( params.stabilities.has_value() )
Expand Down

0 comments on commit d128d9e

Please sign in to comment.