Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove remaining mysql code, patch up dependencies, fix typos #53

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions src/pretix/helpers/templatetags/jsonfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
from django.db import NotSupportedError
from django.db.models import Expression, JSONField

def mysql_compile_json_path(key_transforms):
path = ['$']
for key_transform in key_transforms:
try:
num = int(key_transform)
path.append('[{}]'.format(num))
except ValueError: # non-integer
path.append('.')
path.append(key_transform)
return ''.join(path)

def postgres_compile_json_path(key_transforms):
return "{" + ','.join(key_transforms) + "}"

Expand All @@ -41,17 +30,9 @@ def as_sql(self, compiler, connection, function=None, template=None, arg_joiner=
params.append(json_path)
template = '{} #> %s'.format(arg_sql)
return template, params
elif '.mysql' in connection.settings_dict['ENGINE']:
params = []
arg_sql, arg_params = compiler.compile(self.source_expression)
params.extend(arg_params)
json_path = mysql_compile_json_path(self.path)
params.append(json_path)
template = 'JSON_EXTRACT({}, %s)'.format(arg_sql)
return template, params
else:
raise NotSupportedError(
'Functions on JSONFields are only supported on PostgreSQL and MySQL at the moment.'
'Functions on JSONFields are only supported on PostgreSQL.'
)

def copy(self):
Expand Down
6 changes: 3 additions & 3 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def run(self):
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Framework :: Django :: 3.0'
'Framework :: Django :: 3.2'
],

keywords='tickets web shop ecommerce',
Expand All @@ -125,8 +125,9 @@ def run(self):
'django-hierarkey==1.0.*,>=1.0.4',
'django-filter==2.4.*',
'django-scopes==1.2.*',
'django-localflavor==3.0.*',
'reportlab>=3.5.65',
'Pillow=8.*',
'Pillow==8.*',
'PyPDF2==1.26.*',
'django-libsass==0.8',
'libsass==0.20.*',
Expand Down Expand Up @@ -158,7 +159,6 @@ def run(self):
'mt-940==3.2',
'django-i18nfield==1.9.*,>=1.9.1',
'psycopg2-binary',
'django-mysql',
'tqdm==4.*',
'vobject==0.9.*',
'pycountry',
Expand Down
5 changes: 1 addition & 4 deletions src/tests/api/test_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,7 @@ def test_item_create_with_addon(token_client, organizer, event, item, category,
format='json'
)
assert resp.status_code == 400
assert resp.content.decode() in [
'{"addons":["The minimum count needs to be equal to or greater than zero."]}',
'{"addons":[{"min_count":["Ensure this value is greater than or equal to 0."]}]}', # mysql
]
assert resp.content.decode() == '{"addons":["The minimum count needs to be equal to or greater than zero."]}'
with scopes_disabled():
assert 2 == Item.objects.all().count()

Expand Down
Loading