Commit graph

92 commits

Author SHA1 Message Date
Andrew-Chen-Wang
1d0a06a9ab Remove Python 2 and Django 2.2 code 2023-04-04 15:28:15 -04:00
David Haas
866b662273
Update utils.py (#225)
* Update utils.py

verify get_meta isn't none before requesting db_table

* Add passenv to tox.ini

* Fix test_explain in sqlite

---------

Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
2023-03-12 16:39:04 -04:00
Dominik Bartenstein
434a5759de
Add final SQL check when looking up involved tables (#199) 2021-12-27 12:30:44 -05:00
Lars Kruse
42af2e0126
Handle queryset implementations without lhs/rhs attribute (#204)
The `ExtraJoinRestriction` class used by django-taggit lacks the
attributes "rhs" and "lhs".
Thus projects cannot use django-taggit together with cachalot.

Closes: #121
2021-10-26 16:34:45 -04:00
Dominik Bartenstein
76d4ab4c8d
Simplify annotation handling by using the flatten method: (#197)
* Simplify annotation handling by using the flatten method:
f42ccdd835/django/db/models/expressions.py (L370)

Handle annotated cases when Subquery is part of the When.

* Before Django 3.2 flatten did not check for existence of flatten in the processed nodes.

* Add type BaseExpression to function "flatten".

* Add test case with annotated Coalesce.

* Add support for annotated raw SQL.

* Remove unnecessary code.

* Use as_sql instead of repr.

* Reorganize code

* Fix var name

* Improve naming: element -> expression

Co-authored-by: Dominik Bartenstein <db@zemtu.com>
Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
2021-08-21 20:55:01 -04:00
Andrew Chen Wang
b15027a627
Check for annotated case (#196) 2021-08-19 15:01:56 -04:00
Andrew Chen Wang
4fb23ab029
Check for Uncachables (i.e. Now) in annotations (#195)
* Check for Uncachables for annotations

* Add test case

* Update CHANGELOG.rst
2021-08-19 15:00:47 -04:00
Andrew Chen Wang
9d528656d5
Remove duplicate code _find_rhs_lhs_subquery (#190) 2021-06-06 14:17:49 -04:00
Andrew Chen Wang
5eaffb4958
Add CACHALOT_ADDITIONAL_TABLES for unmanaged models (#183)
* Add CACHALOT_ADDITIONAL_TABLES for unmanaged models
- Fixes #182
- For doc purposes, we do not want to use table_names and want to continue using django_table_names from connection.introspection to avoid a query to the db every request.
2021-05-13 00:44:41 -04:00
Andrew Chen Wang
165cdb6a00
Add Django 3.2 Support and drop error dependency check (#181)
* Remove system check for Django version
* Closes #175
* Bump version and amend CHANGELOG
* Update with GitHub action CI
* Update README with Python and Django versions
* Limit Django version to 3.2, inclusively.
* Add note on Django constraints to README
* Bump minor version
* Justified by dropping support for dependency versions
* Drop support for Django 2.0-2.1, Python 3.5
* Change CI badge in README to GitHub actions
* Add support for Pymemcache for Django 3.2+
* Add Django 3.2 to test matrix
* Fix MySQL test_explain
* Allow filebased delta leniency in tests
* Allow Subquery in finding more Subqueries (Fixes #156)
* Reverts #157 with proper fix. The initial problem was due to `django.db.models.expressions.Subquery` allowing both QuerySet and sql.Query to be used.
* Fixes Django 3.2 test_subquery and test_invalidate_subquery testing by also checking the lhs
* Fix Django 2.2 Subquery having no query attr
* Fix filebased test time delta
* Fix test_invalidate_having due to new inner_query
* The new inner_query replaces subquery for Django 3.2 where subquery is now a boolean. That's why I initially used that TypeError in _get_tables_from_sql. inner_query looks to be a sql.Query
* Add PyMemcacheCache to supported cache backends

Co-authored-by: Dominik George <nik@naturalnet.de>
2021-05-13 00:27:14 -04:00
Andrew-Chen-Wang
d699c5b8c3 Squashed commit of the following:
commit 4a33e7b68196bf6e0ee0b7f942a992532495b616
Author: Andrew-Chen-Wang <acwangpython@gmail.com>
Date:   Mon Aug 10 16:04:26 2020 -0400

    Replace f-strings with join for Python 3.5

commit dcb33232d605c01025469e776c4ed8eb6ae0a326
Author: Andrew-Chen-Wang <acwangpython@gmail.com>
Date:   Mon Aug 10 15:55:09 2020 -0400

    Fix sql_flush for dj versions below 3.1
    * Removed any other instances of JSONField for Django 3.1 removed many things like JsonAdapter in favor of regular json module

commit 74195e9ff5a52dba2449a55e543a27ebd99e4fc9
Author: Andrew-Chen-Wang <acwangpython@gmail.com>
Date:   Mon Aug 10 09:17:03 2020 -0400

    Add Django 3.1 to Travis
    * Specify Django version when checking if JSONField exists

commit da5c1fa4c8b2f2efba0b12d7b27460c544e2473a
Author: Andrew-Chen-Wang <acwangpython@gmail.com>
Date:   Wed Aug 5 17:39:58 2020 -0400

    Added support for Django 3.1
    * Some fields were removed, others were deprecated. They are now in a list of deprecation to follow. Some new fields were added like PositiveBigIntegerField that won't be tested
    * monkey_patch.py has a try/except import for EmptyResultSet that was from archaic Django. Removed apparently due to compatibility issues
2020-08-10 16:49:46 -04:00
John-Paul Stanford
71dcf73dd7
Attempt to fix issue #156 by handling subquieries (#157)
* Combine child_class passing to minimize if's

Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>
2020-07-29 14:57:16 -04:00
Andrew-Chen-Wang
6e22dc7f58 Drop Python 2.7 and Dj 1.11 2020-06-18 09:28:00 -04:00
benjfield
182154a286
Fix for queryset no longer existing (#151) 2020-04-28 16:33:22 -04:00
Andrew-Chen-Wang
602cdcee1d
Version 2.2.0 (#146)
This PR upgrades cachalot to version 2.2.0 allowing for anyone to install cachalot at any Django package above 1.11. All tests currently function now.

* Added mysql as a service to fix Travis CI

* Removed tox dependency

* Removed upper limit on Django and support 2.2-3.0 CI Test
* Cachalot will only say "officially supports" while removing upper limit to not hinder anyone's progress.
* Added Python 3.8 and Django 2.2 and 3.0 to CI tests

- Max is 200 and we'll get there quickly if we add another Python version. Utilizes #127
- Keep dependencies for six and django.utils.six

* Correctly run Travis test by updating tox.ini
* Originally using tox syntax but changed testenv to travis so that travis env and travis dependencies and stuff are used

* Tox tests should start running command

* testenv without dependencies broke travis. New spot in Tox
* testenv without dependencies broke travis
* I can't figure out where testenv is supposed to be
* Good thing there's squash

* Added missing six in test
* Also added six package to Tox for Django 3.0 coverage.
* The missing six package caused several problems in several tests due to using an incorrect DB

* Resolves #138
* Need to add the panels here in order to satisfy tests

* Adds CachalotPanel to Python 2 backwards compatibility
* Forgot super class took those like save()

* Added databases to certain test cases
* APITestCase, DebugToolbarTestCase, SignalsTestCase required a database set
* Fixes errors like these: https://travis-ci.org/noripyt/django-cachalot/jobs/648691385#L4892

* Dropped OFFICIAL support for Python 3.4 + MySQL
* MySQL and its client on 3.4 is f--king up a lot of the testing and I can't bear with it. We can revisit it later, but, honestly, who uses Python 3.4... and if an organization is, then they will either have no problem with Postgres and SQLite or know that MySQL doesn't work.

* Drop Py3.4 from running. Fixed databases
* Now goes with setting's databases rather than hardcoded since some tests don't have other databases.

* Fix ReadTestCase

Django 2.2+ changed self.queryset at line 1000 with self.query=queryset.query

* Django Dependency Removed from utils.py

* Last commit used Django version. This one used try except

* Fixed assertNumQuery; added allow_failures for 3.4
* Primary: More information in test_utils.py with method is_django_21_below_and_is_sqlite
* The problem with the entire build lie in the self.is_sqlite for the tests. SQLite will make 2 queries when creating or destroying or updating instead of 1.
* In summary, if SQLite is the DB and Django

* Changed build matrix to allow failures for 3.4 instead of taking it out completely so that we can get it to work soon.

* Remove -> From function return
* I love backwards compatibility

* SQLite2 in multi_db.py returned incorrect bool

* Django 2.1 and SQLite checker doesn't work for some tests
* Some tests DO HAVE the BEGIN query that is returned... Not sure why. If the next test show completely different WriteTestCase problems, then we need to find alternative.
* Removed check from atomic

* Adjust Django and is_sqlite errors
* CI testing the Tox errors: https://travis-ci.org/noripyt/django-cachalot?utm_medium=notification&utm_source=github_status

* Adjust Django and is_sqlite errors (590 CI)
* CI testing the Tox errors: https://travis-ci.org/noripyt/django-cachalot?utm_medium=notification&utm_source=github_status
* Adjustment 2

* Make include matrix and Adjust Django and is_sqlite errors (594 CI)
* CI testing the Tox errors: https://travis-ci.org/noripyt/django-cachalot?utm_medium=notification&utm_source=github_status
* Adjustment 3

* Adjust Django and is_sqlite errors (596 CI)
* CI testing the Tox errors: https://travis-ci.org/noripyt/django-cachalot?utm_medium=notification&utm_source=github_status
* Adjustment 4
* Added my intro to ReadTheDocs

* Adjust Django and is_sqlite errors (598 CI)
* CI testing the Tox errors: https://travis-ci.org/noripyt/django-cachalot?utm_medium=notification&utm_source=github_status
* Adjustment 5

* Drop Python 3.4 from tests since PyLibMC not cooperating at that level.

* Bump package version up 1 minor for Django 2.2 and 3.0
2020-02-12 00:52:12 -05:00
Petr Dlouhý
782f00300e fixes for Django 3.0 (#144)
Use six since django.utils.six is dropped.
2020-02-09 23:05:06 -05:00
Andrew-Chen-Wang
aced88edb7 Updated README, new maintainer
* Added Django 3.0 support to avoid conflicts when pip installing
* README shows cache comparisons and usage time
* Travis updated
* gitignore updated from GitHub's main page
2020-02-09 22:57:35 -05:00
Bertrand Bordage
861f20ed67 Handles .union, .intersection, & .difference. 2018-07-27 16:43:57 +02:00
Bertrand Bordage
74e000b8e2 Adds Django 2.0 support. 2018-05-04 20:26:26 +02:00
Bertrand Bordage
259b76291a Minor amends to #102. 2018-05-04 14:57:23 +02:00
Kosei Kitahara
df42746729
Remove EOL version specific macros 2018-04-17 14:51:41 +09:00
Bertrand Bordage
bc49fd18ea Multiple Python optimisations. 2017-06-07 08:59:35 +02:00
Bertrand Bordage
da4e21b515 Adds CACHALOT_DATABASES and removes dynamic setting support.
Dynamic setting support is removed because it’s not thread-safe.
2017-06-04 18:37:39 +02:00
Bertrand Bordage
8d334f9855 Python optimisations. 2017-06-03 19:53:01 +02:00
Bertrand Bordage
b5827cd936 Removes a useless check. 2017-06-03 18:47:06 +02:00
Bertrand Bordage
b634d18dc5 Correctly adds the long type. 2017-06-03 18:27:58 +02:00
Bertrand Bordage
2d5ad63fbd Adds the Python type long to the cachable param types. 2017-06-03 18:25:07 +02:00
Bertrand Bordage
412f82061e Prints again a debug line to understand why Travis CI is failing… -_- 2017-06-03 18:09:45 +02:00
Bertrand Bordage
4522106632 Supports RawSQL. 2017-06-03 17:59:21 +02:00
Bertrand Bordage
cb877355ac Adds bytearray to the list of cachable params. 2017-06-03 12:21:25 +02:00
Bertrand Bordage
799fbf28e0 Displays uncachable params to debug an issue only on Travis CI. 2017-06-03 12:07:53 +02:00
Bertrand Bordage
85ebf42353 Fixes Python 2. 2017-06-03 11:00:54 +02:00
Bertrand Bordage
f86a56d110 Fixes Django 1.11 compatibility. 2017-06-03 02:00:15 +02:00
David Jean Louis
179d8f2e21 Fixed django>=1.11 support.
Since Django 1.11 the ``query`` argument of the SQLCompiler constructor has always a ``subquery`` property, in fact if the SQL query has no real sub query it is set to False.
As a result, the test done by Django-cachalot in the ``_get_tables`` function is no more accurate and cause a dramatic slow down on 1.11 django installs.
This fix should be backwards compatible with older versions of Django.
2017-06-02 17:29:11 +02:00
Bertrand Bordage
f6cfeb6226 Stops automatically invalidating other caches than CACHALOT_CACHE.
This had a negative impact on performance, and it was not working reliably.
It is clearer to invalidate only `CACHALOT_CACHE`, and to detail what
to do in the docs when we change `CACHALOT_CACHE`.
2016-09-29 19:11:21 +02:00
Bertrand Bordage
c5d5ee7907 Never caches select_for_update queries. 2016-09-29 11:57:38 +02:00
Bertrand Bordage
246873b42f Don’t invalidate uncachable queries. 2016-09-07 00:44:51 +02:00
Bertrand Bordage
522b5af899 Use CACHALOT_TIMEOUT in 3 remaining places. 2016-09-06 23:21:01 +02:00
Bertrand Bordage
944ebb9b73 Removes old Django 1.7 code. 2016-07-21 12:19:31 +02:00
Bertrand Bordage
e0841077e2 Revert "Simplifies the cache key hashing."
This reverts commit beac70251f.
2016-02-17 19:38:41 +01:00
Bertrand Bordage
cfcd0f2805 Changes two documented types. 2016-01-12 11:42:57 +01:00
Bertrand Bordage
58fd71c925 Small Python optimisations & simplifications. 2016-01-11 22:57:42 +01:00
Bertrand Bordage
beac70251f Simplifies the cache key hashing. 2016-01-11 22:06:16 +01:00
Bertrand Bordage
3e7a9a0808 Prevents queries with Now from being cached. 2015-12-28 05:51:38 +01:00
Bertrand Bordage
3a97912f3d Handles and tests JSONField. 2015-12-28 03:14:57 +01:00
Bertrand Bordage
2ffe564e3e Fixes Django 1.7+1.8 compatibility. 2015-12-18 17:07:53 +01:00
Bertrand Bordage
746616b7b1 Fixes version number comparison. 2015-12-18 16:46:00 +01:00
Bertrand Bordage
885d68b008 Fixes Django 1.9 compatibility. 2015-12-18 15:56:28 +01:00
Bertrand Bordage
87ed73390f Tests and handles Decimal type in query parameters. 2015-10-28 17:08:03 +01:00
Bertrand Bordage
6d6bbdeb6f Tests FloatField and cache queries using it. 2015-10-28 16:51:26 +01:00