Skip to content

Commit

Permalink
Merge pull request #111 from ambitioninc/develop
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
somewes authored May 28, 2019
2 parents ed843ad + 7471e6c commit 26b8011
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
21 changes: 9 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
dist: xenial

language: python

sudo: false

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"

env:
matrix:
- DJANGO=1.10
- DJANGO=1.11
- DJANGO=2.0
- DJANGO=2.1
- DJANGO=2.2
- DJANGO=master

addons:
postgresql: '9.5'
postgresql: '9.6'

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

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

exclude:
- { python: "2.7", env: DJANGO=master }
- { python: "2.7", env: DJANGO=2.0 }
- { python: "3.4", env: DJANGO=master }
- { python: "3.6", env: DJANGO=1.10 }

allow_failures:
- env: DJANGO=master

Expand Down
5 changes: 5 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

v1.4.0
------
* Only support django >= 2.0 and python >= 3.6
* Fix bulk upsert sql issue to distinguish fields by table

v1.3.2
------
* Fix bulk_update not properly casting fields
Expand Down
9 changes: 8 additions & 1 deletion manager_utils/manager_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ def _get_upserts_distinct(queryset, model_objs_updated, model_objs_created, uniq
# Keep track of the created models
created_models = []

# Add table name to unique fields
table_name = queryset.model._meta.db_table
unique_fields_sql = [
'"{0}"."{1}"'.format(table_name, unique_field)
for unique_field in unique_fields
]

# If we created new models query for them
if model_objs_created:
created_models.extend(
queryset.extra(
where=['({unique_fields_sql}) in %s'.format(
unique_fields_sql=', '.join(unique_fields)
unique_fields_sql=', '.join(unique_fields_sql)
)],
params=[
tuple([
Expand Down
2 changes: 1 addition & 1 deletion manager_utils/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.2'
__version__ = '1.4.0'
19 changes: 10 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
[tox]
envlist =
flake8
py{27,34,35}-django110
py{27,34,35,36}-django111
py{34,35,36}-django20
py{35,36}-djangomaster
py{36}-django20
py{36,37}-django21
py{36,37}-django22
py{36,37}-djangomaster

[testenv]
setenv =
DB = postgres
deps =
django110: Django>=1.10,<1.11
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
djangomaster: https://github.com/django/django/archive/master.tar.gz
-rrequirements/requirements-testing.txt
commands =
coverage run setup.py test
coverage run --concurrency=multiprocessing setup.py test
coverage combine
coverage report --fail-under=100

[testenv:flake8]
Expand All @@ -25,7 +26,7 @@ commands = flake8 manager_utils

[travis:env]
DJANGO =
1.10: django110
1.11: django111
2.0: django20
2.1: django21
2.2: django22
master: djangomaster

0 comments on commit 26b8011

Please sign in to comment.