Skip to content

Commit

Permalink
Merge pull request #103 from wesokes/develop
Browse files Browse the repository at this point in the history
update versions
  • Loading branch information
somewes authored Dec 29, 2020
2 parents fd0c6e5 + 3cc53d3 commit 263b2aa
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 44 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ sudo: false
python:
- "3.6"
- "3.7"
- "3.8"

env:
matrix:
- DJANGO=2.0
- DJANGO=2.1
- DJANGO=2.2
- DJANGO=3.0
- DJANGO=3.1
- DJANGO=master

addons:
postgresql: '9.6'

matrix:
exclude:
- { python: "3.7", env: DJANGO=2.0 }

include:
- { python: "3.6", env: TOXENV=flake8 }

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.rst
include LICENSE
recursive-include requirements *
6 changes: 6 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

v2.0.0
------
* Add support Django 3.0, 3.1
* Add support for python 3.8
* Drop support for Django 2.1

v1.2.0
------
* Add Django 2.1
Expand Down
10 changes: 3 additions & 7 deletions querybuilder/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
from django.db.models import Q, AutoField
from django.db.models.query import QuerySet
from django.db.models.constants import LOOKUP_SEP
try:
# Django 1.9
from django.apps import apps
get_model = apps.get_model
except ImportError: # pragma: no cover
# Django < 1.9
from django.db.models import get_model
from django.apps import apps
get_model = apps.get_model
import six


from querybuilder.fields import FieldFactory, CountField, MaxField, MinField, SumField, AvgField
from querybuilder.helpers import set_value_for_keypath
from querybuilder.tables import TableFactory, ModelTable, QueryTable
Expand Down
23 changes: 17 additions & 6 deletions querybuilder/tests/json_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from django import VERSION
from django.test.testcases import TestCase
from django.test.utils import override_settings
from querybuilder.fields import JsonField
Expand Down Expand Up @@ -45,7 +46,12 @@ def test_one(self):
'querybuilder_tests_metricrecord WHERE (querybuilder_tests_metricrecord.data->>\'two\' = %(A0)s)'
)
)
self.assertEqual(query.select(), [{'my_two_alias': 'two'}])

# Django 3.1 changes the raw queryset behavior so querybuilder isn't going to change that behavior
if VERSION[0] == 3 and VERSION[1] == 1:
self.assertEqual(query.select(), [{'my_two_alias': '"two"'}])
else:
self.assertEqual(query.select(), [{'my_two_alias': 'two'}])

query = Query().from_table(MetricRecord, fields=[one_field]).where(**{
one_field.get_where_key(): '1'
Expand All @@ -57,7 +63,12 @@ def test_one(self):
'querybuilder_tests_metricrecord WHERE (querybuilder_tests_metricrecord.data->>\'one\' = %(A0)s)'
)
)
self.assertEqual(query.select(), [{'my_one_alias': 1}])

# Django 3.1 changes the raw queryset behavior so querybuilder isn't going to change that behavior
if VERSION[0] == 3 and VERSION[1] == 1:
self.assertEqual(query.select(), [{'my_one_alias': '1'}])
else:
self.assertEqual(query.select(), [{'my_one_alias': 1}])

query = Query().from_table(MetricRecord, fields=[one_field]).where(**{
one_field.get_where_key(): '2'
Expand Down Expand Up @@ -93,11 +104,11 @@ def test_one(self):
record = JsonQueryset(model=MetricRecord).filter(**{'data->two': 'one'}).first()
self.assertIsNone(record)

record = JsonQueryset(model=MetricRecord).filter(**{'data->two': 'two'}).first()
self.assertEqual(record.data['two'], 'two')
records = list(JsonQueryset(model=MetricRecord).filter(**{'data->two': 'two'}))
self.assertEqual(records[0].data['two'], 'two')

record = JsonQueryset(model=MetricRecord).filter(**{'data->one': '1'}).first()
self.assertEqual(record.data['one'], 1)
records = list(JsonQueryset(model=MetricRecord).filter(**{'data->one': '1'}))
self.assertEqual(records[0].data['one'], 1)

record = JsonQueryset(model=MetricRecord).filter(**{'data->one': '2'}).first()
self.assertIsNone(record)
Expand Down
7 changes: 5 additions & 2 deletions querybuilder/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
try:
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField
except ImportError:
from jsonfield import JSONField
try:
from django.contrib.postgres.fields import JSONField
except ImportError:
from jsonfield import JSONField
from django.db import models


Expand Down
2 changes: 1 addition & 1 deletion querybuilder/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.0'
__version__ = '2.0.0'
4 changes: 4 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Django>=2.2
pytz>=2015.6
fleming>=0.6.0
six
28 changes: 13 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ def get_version():
raise RuntimeError('Unable to find version string in {0}.'.format(VERSION_FILE))


def get_lines(file_path):
return open(file_path, 'r').read().split('\n')


install_requires = get_lines('requirements/requirements.txt')
tests_require = get_lines('requirements/requirements-testing.txt')


setup(
name='django-query-builder',
version=get_version(),
Expand All @@ -31,29 +39,19 @@ def get_version():
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Development Status :: 5 - Production/Stable',
],
license='MIT',
install_requires=[
'Django>=1.11',
'pytz>=2015.6',
'fleming>=0.4.4',
'six',
],
tests_require=[
'psycopg2',
'django-nose>=1.4',
'django-dynamic-fixture',
'jsonfield==0.9.20',
'mock'
],
install_requires=install_requires,
tests_require=tests_require,
test_suite='run_tests.run_tests',
include_package_data=True,
)
16 changes: 8 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[tox]
envlist =
flake8
py{36}-django20
py{36,37}-django21
py{36,37}-django22
py{36,37}-djangomaster
py{36,37,38}-django30
py{36,37,38}-django31
py{36,37,38}-djangomaster

[testenv]
setenv =
DB = postgres
deps =
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
django22: Django>=2.2,<3.0
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
djangomaster: https://github.com/django/django/archive/master.tar.gz
-rrequirements/requirements-testing.txt
commands =
Expand All @@ -25,7 +25,7 @@ commands = flake8 querybuilder

[travis:env]
DJANGO =
2.0: django20
2.1: django21
2.2: django22
3.0: django30
3.1: django31
master: djangomaster

0 comments on commit 263b2aa

Please sign in to comment.