Skip to content

Commit

Permalink
release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
iNishant committed Apr 26, 2024
1 parent 2eedbc2 commit 0bf1daa
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 13 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
branches:
- 'main'

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev-requirements.txt
- name: Build and release
run: |
python -m build
twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} dist/*
16 changes: 7 additions & 9 deletions django_querysets_single_query_fetch/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,11 @@ def _get_django_sql_for_queryset(self, queryset: QuerySet) -> str:
return ""

for param in params:
if (
isinstance(param, str)
or isinstance(param, UUID)
or isinstance(param, datetime.datetime)
):
if isinstance(param, str):
# this is to handle special char handling
param = QuotedString(f"{param}").getquoted().decode("utf-8")
param = QuotedString(param).getquoted().decode("utf-8")
elif isinstance(param, UUID) or isinstance(param, datetime.datetime):
param = f"'{param}'"
elif isinstance(param, int) or isinstance(param, float):
# type which can be passed as is
pass
Expand Down Expand Up @@ -319,9 +317,9 @@ def _get_instances_from_results_for_model_iterable(
obj_fields_cache = {}
# because of json_agg some field level parsing/handling broke, patch it for prefetched objects
for prefetched_obj_name, prefetched_obj in obj._state.fields_cache.items():
obj_fields_cache[
prefetched_obj_name
] = self._transform_object_to_handle_json_agg(obj=prefetched_obj)
obj_fields_cache[prefetched_obj_name] = (
self._transform_object_to_handle_json_agg(obj=prefetched_obj)
)
obj._state.fields_cache = obj_fields_cache
instances.append(obj)
return instances
Expand Down
1 change: 1 addition & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
19 changes: 15 additions & 4 deletions testapp/tests/test_behaviour_for_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,25 @@ def test_fetch_count(self):

def test_quotes_inside_the_string_in_select_query_will_work(self):
name = "Ap's"
product_with_name_contain_quotes = baker.make(
product = baker.make(
StoreProduct,
store=self.store,
category=self.category,
selling_price=100.33,
name=name,
)
product = QuerysetsSingleQueryFetch(
products = QuerysetsSingleQueryFetch(
querysets=[StoreProduct.objects.filter(name=name)]
).execute()
self.assertEqual(product_with_name_contain_quotes.id, product[0][0].id)
).execute()[0]
self.assertEqual(product.id, products[0].id)

def test_search_by_datetime_will_work(self):
stores = QuerysetsSingleQueryFetch(
querysets=[
OnlineStore.objects.filter(
created_at=self.store.created_at, id=self.store.id
)
]
).execute()[0]
self.assertEqual(len(stores), 1)
self.assertEqual(self.store.id, stores[0].id)
1 change: 1 addition & 0 deletions testproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path

Expand Down

0 comments on commit 0bf1daa

Please sign in to comment.