Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabaseError: more than one row returned by a subquery used as an expression (Django)
    text
    copied!<p>Django through a <code>DatabaseError</code> when I try to use a merged query set. My code is</p> <pre><code>assetsNetwork = Asset.objects.filter(client=myClient, module__label__in=network_label_list) vulnsNetworkRaw = Vuln.objects.none() for asset in assetsNetwork: vulnsNetworkRaw = vulnsNetworkRaw | asset.latest_vulns logging.debug("+++%s+++"%vulnsNetworkRaw) </code></pre> <p>The error message is </p> <pre><code>DatabaseError: more than one row returned by a subquery used as an expression </code></pre> <p>The .latest_vulns method is</p> <pre><code>@property def latest_scan(self): from arachni.models import WebScan, Vulns as WebVuln my_module = self.module try: return Scan.objects.filter(assets__id=self.id, status='Audit Complete').latest('completed_Date') except: return Scan.objects.none() @property def latest_vulns(self): from arachni.models import WebScan, Vulns as WebVuln latest_scan = self.latest_scan return Vuln.objects.filter(scan=latest_scan, host=self.IP_Address) </code></pre> <p>Query:</p> <pre><code>2012-08-07 16:44:38 EDT STATEMENT: SELECT "pegasus_vuln"."id", "pegasus_vuln"."nvt_id", "pegasus_vuln"."scan_id", "pegasus_vuln"."host", "pegasus_vuln"."port", "pegasus_vuln"."risk_factor", "pegasus_vuln"."cvss_score", "pegasus_vuln"."status", "pegasus_vuln"."change", "pegasus_vuln"."comment", "pegasus_vuln"."description", "pegasus_vuln"."solution", "pegasus_vuln"."_order" FROM "pegasus_vuln" WHERE (("pegasus_vuln"."host" = '192.168.2.251' AND "pegasus_vuln"."scan_id" = 95 ) OR ("pegasus_vuln"."host" = '192.168.2.5' AND "pegasus_vuln"."scan_id" = (SELECT U0."id" FROM "pegasus_scan" U0)) OR ("pegasus_vuln"."host" = '10.1.10.244' AND "pegasus_vuln"."scan_id" = 109 ) OR ("pegasus_vuln"."host" = '192.168.2.5' AND "pegasus_vuln"."scan_id" = (SELECT U0."id" FROM "pegasus_scan" U0)) OR ("pegasus_vuln"."host" = '192.168.2.248' AND "pegasus_vuln"."scan_id" = (SELECT U0."id" FROM "pegasus_scan" U0))) ORDER BY "pegasus_vuln"."_order" ASC LIMIT 21 2012-08-07 16:44:38 EDT ERROR: more than one row returned by a subquery used as an expression </code></pre> <p>It successfully logs for several times, but gives an error also in the logging line. Could anybody help me? Thanks a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload