Skip to content

Commit

Permalink
cleanup: remove remaining mysql code, patch up dependencies, fix typos (
Browse files Browse the repository at this point in the history
fossasia#53)

Co-authored-by: Martin Bähr <[email protected]>
  • Loading branch information
eMBee and Martin Bähr committed May 6, 2024
1 parent dea5072 commit f003473
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
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

0 comments on commit f003473

Please sign in to comment.