Changes between Version 1 and Version 2 of Ticket #32690, comment 3


Ignore:
Timestamp:
Apr 28, 2021, 7:25:53 PM (4 years ago)
Author:
allen-munsch

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32690, comment 3

    v1 v2  
    77edit: added the attachment
    88
     9edit2:
     10
     11Inside of the ticket32690.django.proj.tar.gz readme.md:
    912
    1013
     14{{{
     15
     16```bash
     17docker-compose up
     18
     19pyenv install 3.8.9
     20pyenv local 3.8.9
     21python -m venv .env
     22. .env/bin/activate
     23pip install -r requirements.txt
     24
     25# create the db
     26psql postgres://ticket32690user:password@127.0.0.1:5432/ -c "create database ticket32690db;"
     27./manage.py migrate
     28```
     29
     30
     31
     32From inside the django shell
     33
     34```example
     3507:11:24 (.env) jmunsch@pop-os ticket32690 → ./manage.py shell
     36Python 3.8.9 (default, Apr 14 2021, 18:54:59)
     37[GCC 9.3.0] on linux
     38Type "help", "copyright", "credits" or "license" for more information.
     39(InteractiveConsole)
     40>>> from things.models import Actor, RealmAccess, Thing
     41>>> actor1, _ = Actor.objects.get_or_create(**{})
     42>>> actor2, _ = Actor.objects.get_or_create(**{})
     43>>>
     44>>> r1 = RealmAccess.objects.create(name='ok')
     45>>> r2 = RealmAccess.objects.create(name='ok2')
     46>>>
     47>>> actor1.realm_access.add(r1)
     48>>>
     49>>> Thing.objects.filter_by_realm_access_broken(actor1)
     50SELECT "things_thing"."id",
     51       "things_thing"."created",
     52       "things_thing"."updated",
     53       "things_thing"."create_by",
     54       "things_thing"."update_by",
     55       "things_thing"."date",
     56       "things_thing"."average",
     57       "things_thing"."data_points",
     58       "things_thing"."actor_id",
     59       "things_thing"."realms",
     60       COUNT("things_actorrealmaccess"."property_group_id") AS "actor__realm_access__count"
     61FROM "things_thing"
     62INNER JOIN "things_actor" ON ("things_thing"."actor_id" = "things_actor"."id")
     63LEFT OUTER JOIN "things_actorrealmaccess" ON ("things_actor"."id" = "things_actorrealmaccess"."actor_id")
     64LEFT OUTER JOIN "things_actorrealmaccess" T5 ON ("things_actor"."id" = T5."actor_id")
     65GROUP BY "things_thing"."id",
     66         T5."property_group_id",
     67  (SELECT U0."id",
     68          U0."created",
     69          U0."updated",
     70          U0."create_by",
     71          U0."update_by",
     72          U0."name"
     73   FROM "things_realmaccess" U0
     74   INNER JOIN "things_actorrealmaccess" U1 ON (U0."id" = U1."property_group_id")
     75   WHERE U1."actor_id" = 2)
     76HAVING (T5."property_group_id" IN
     77          (SELECT U0."id"
     78           FROM "things_realmaccess" U0
     79           INNER JOIN "things_actorrealmaccess" U1 ON (U0."id" = U1."property_group_id")
     80           WHERE U1."actor_id" = 2)
     81        OR COUNT("things_actorrealmaccess"."property_group_id") = 0)
     82Traceback (most recent call last):
     83  File "/home/jmunsch/PycharmProjects/test-django/.env/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
     84    return self.cursor.execute(sql, params)
     85psycopg2.errors.SyntaxError: subquery must return only one column
     86LINE 1: ...P BY "things_thing"."id", T5."property_group_id", (SELECT U0...
     87                                                             ^
     88```
     89}}}
     90
Back to Top