django-delayed-union


Namedjango-delayed-union JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/roverdotcom/django-delayed-union
SummaryA library designed to workaround some drawbacks with Django's union, intersection, and difference operations.
upload_time2018-03-26 20:16:25
maintainer
docs_urlNone
authorMike Hansen
requires_python
licenseBSD 3-Clause License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            ========
Overview
========



``django-delayed-union`` is library designed to workaround some
drawbacks with Django's union, intersection, and difference
operations.  In particular, once one of these operations is performed,
certain methods on the queryset will silently not work::

  >>> qs = User.objects.filter(id=1)
  >>> unioned_qs = qs.union(qs)
  >>> should_be_empty_qs = unioned_qs.exclude(id=1)
  >>> user, = list(should_be_empty_qs); user.id
  1

In order to work around this, ``django-delayed-union`` provides
wrappers around a collection of querysets.  These wrappers implement a
similar interface to ``QuerySet``, and delay performing the union,
intersection, or difference operations until they are needed::

  >>> from django_delayed_union import DelayedUnionQuerySet
  >>> qs = User.objects.filter(id=1)
  >>> unioned_qs = DelayedUnionQuerySet(qs, qs)
  >>> empty_qs = unioned_qs.exclude(id=1)
  >>> list(empty_qs)
  []

Operations which would typically return a new ``QuerySet`` instead
return a new ``DelayedQuerySet`` with the operation applied to its
collection of querysets.

One example of where this code has been useful with is when the the
MySQL query planner has chosen an inefficient query plan for the
queryset of a `Django REST Framework <https://github.com/foo/>`_ view
which used an ``OR`` condition.  By using ``DelayedUnionQuerySet``,
subclasses could perform additional filters on the queryset while
still maintaining the efficient query plan.

* Free software: BSD 3-Clause License

Installation
============

::

    pip install django-delayed-union

Documentation
=============

https://django-delayed-union.readthedocs.io/

Development
===========

To run the all tests run::

    tox


Changelog
=========

0.1.0 (2018-03-14)
------------------

* First release on PyPI.



            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "cheesecake_code_kwalitee_id": null, 
    "keywords": "", 
    "upload_time": "2018-03-26 20:16:25", 
    "author": "Mike Hansen", 
    "home_page": "https://github.com/roverdotcom/django-delayed-union", 
    "github_user": "roverdotcom", 
    "download_url": "https://pypi.python.org/packages/44/bb/f915085280b8dadb11a3f8b8fb591ff58638fa522ce54925c6fdd30c529b/django-delayed-union-0.1.0.tar.gz", 
    "platform": "", 
    "version": "0.1.0", 
    "cheesecake_documentation_id": null, 
    "description": "========\nOverview\n========\n\n\n\n``django-delayed-union`` is library designed to workaround some\ndrawbacks with Django's union, intersection, and difference\noperations.  In particular, once one of these operations is performed,\ncertain methods on the queryset will silently not work::\n\n  >>> qs = User.objects.filter(id=1)\n  >>> unioned_qs = qs.union(qs)\n  >>> should_be_empty_qs = unioned_qs.exclude(id=1)\n  >>> user, = list(should_be_empty_qs); user.id\n  1\n\nIn order to work around this, ``django-delayed-union`` provides\nwrappers around a collection of querysets.  These wrappers implement a\nsimilar interface to ``QuerySet``, and delay performing the union,\nintersection, or difference operations until they are needed::\n\n  >>> from django_delayed_union import DelayedUnionQuerySet\n  >>> qs = User.objects.filter(id=1)\n  >>> unioned_qs = DelayedUnionQuerySet(qs, qs)\n  >>> empty_qs = unioned_qs.exclude(id=1)\n  >>> list(empty_qs)\n  []\n\nOperations which would typically return a new ``QuerySet`` instead\nreturn a new ``DelayedQuerySet`` with the operation applied to its\ncollection of querysets.\n\nOne example of where this code has been useful with is when the the\nMySQL query planner has chosen an inefficient query plan for the\nqueryset of a `Django REST Framework <https://github.com/foo/>`_ view\nwhich used an ``OR`` condition.  By using ``DelayedUnionQuerySet``,\nsubclasses could perform additional filters on the queryset while\nstill maintaining the efficient query plan.\n\n* Free software: BSD 3-Clause License\n\nInstallation\n============\n\n::\n\n    pip install django-delayed-union\n\nDocumentation\n=============\n\nhttps://django-delayed-union.readthedocs.io/\n\nDevelopment\n===========\n\nTo run the all tests run::\n\n    tox\n\n\nChangelog\n=========\n\n0.1.0 (2018-03-14)\n------------------\n\n* First release on PyPI.\n\n\n", 
    "tox": true, 
    "lcname": "django-delayed-union", 
    "bugtrack_url": null, 
    "github": true, 
    "coveralls": true, 
    "name": "django-delayed-union", 
    "license": "BSD 3-Clause License", 
    "travis_ci": true, 
    "github_project": "django-delayed-union", 
    "summary": "A library designed to workaround some drawbacks with Django's union, intersection, and difference operations.", 
    "split_keywords": [], 
    "author_email": "mike@rover.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2018-03-26T20:16:25", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://pypi.python.org/packages/44/bb/f915085280b8dadb11a3f8b8fb591ff58638fa522ce54925c6fdd30c529b/django-delayed-union-0.1.0.tar.gz", 
            "md5_digest": "17327b4fcff32d84cd760ed4065f2205", 
            "downloads": 0, 
            "filename": "django-delayed-union-0.1.0.tar.gz", 
            "packagetype": "sdist", 
            "path": "44/bb/f915085280b8dadb11a3f8b8fb591ff58638fa522ce54925c6fdd30c529b/django-delayed-union-0.1.0.tar.gz", 
            "digests": {
                "sha256": "f88cae25952e6330a9d48948f7b1c836c10e6e73cfc3263ee86b5d65a7fbfec5", 
                "md5": "17327b4fcff32d84cd760ed4065f2205"
            }, 
            "sha256_digest": "f88cae25952e6330a9d48948f7b1c836c10e6e73cfc3263ee86b5d65a7fbfec5", 
            "size": 20581
        }, 
        {
            "has_sig": false, 
            "upload_time": "2018-03-26T20:16:24", 
            "comment_text": "", 
            "python_version": "py2.py3", 
            "url": "https://pypi.python.org/packages/ef/7a/26e6852a4a2e7d1a5c68f787cf5ee25639592319503c0bed8c425bda5ee4/django_delayed_union-0.1.0-py2.py3-none-any.whl", 
            "md5_digest": "8ff9c67621ed164e0be34d403702897f", 
            "downloads": 0, 
            "filename": "django_delayed_union-0.1.0-py2.py3-none-any.whl", 
            "packagetype": "bdist_wheel", 
            "path": "ef/7a/26e6852a4a2e7d1a5c68f787cf5ee25639592319503c0bed8c425bda5ee4/django_delayed_union-0.1.0-py2.py3-none-any.whl", 
            "digests": {
                "sha256": "0053a4df639f869fe683fb284ef8286c324b6ec657535a1f422cad02fe4f800b", 
                "md5": "8ff9c67621ed164e0be34d403702897f"
            }, 
            "sha256_digest": "0053a4df639f869fe683fb284ef8286c324b6ec657535a1f422cad02fe4f800b", 
            "size": 10287
        }
    ], 
    "_id": null, 
    "cheesecake_installability_id": null
}