QuerySet.defer() and only() don't work

XMLWordPrintableJSON

    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      SQL examples from Django's "defer" test app (since it lacks MQL tests, this bug went undetected):

      >>> Primary.objects.defer("name")
      
      SELECT "defer_primary"."id", "defer_primary"."value", "defer_primary"."related_id" FROM "defer_primary
      
      >>> Primary.objects.only("only")
      
      SELECT "defer_primary"."id", "defer_primary"."name" FROM "defer_primary
      

      On MongoDB, the queries don't include the necessary $project to limit the keys returned: db.defer_primary.aggregate([\{'$limit': 1}])

      Probably logic in SQLCompiler.columns is at fault. Query.get_select_mask() is where the deferred columns are computed.

            Assignee:
            Emanuel Lupi
            Reporter:
            Tim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: