Comments (5)
@warmwaffles thanks for checking, I also would love to get a new release out the door. Have you had a chance to review the discussion at #17 (comment)? That outlines some reasons for why I'm holding off on a release at this time. TLDR I'm concerned that the changes in #18 are too fragile to force on everyone without warning.
I would consider a beta release if it can be done in a way that will only affect people who opt-in to using it (i.e., not be automatically installed by pip install --upgrade django-cte
). I'll have to research if that's possible.
As a temporary workaround you can install a specific commit like so:
pip install "git+git://github.com/dimagi/django-cte@ab0cf7e6a0be7a41c6b646377a2e70b1e896c4c1#egg=django-cte"
from django-cte.
@millerdev I'll pull that into my project and see if this helps me. Will report back on Monday mid day.
from django-cte.
I've had to table the upgrade to 3.0 because there are other issues outstanding with other libraries. I'll revisit this once I get those other issues resolved.
from django-cte.
@millerdev so I had to clone this project into my main project and found that QJoin
has issues when trying to join on a non FK field. In my case, I was joining on a text field and was encountering errors.
Here's my "solution", it's not pretty, I don't know why it works, but it does.
class CTEQuery(Query):
# ...
def set_group_by(self, allow_aliases=True):
"""
Expand the GROUP BY clause required by the query.
This will usually be the set of all non-aggregate fields in the
return data. If the database backend supports grouping by the
primary key, and the query would be equivalent, the optimization
will be made automatically.
"""
# Column names from JOINs to check collisions with aliases.
if allow_aliases:
column_names = set()
seen_models = set()
for join in list(self.alias_map.values())[1:]: # Skip base table.
model = join.join_field.related_model
# ---------------------------------------------------
# This is shimmed in from the original implementation
# ---------------------------------------------------
if not model:
continue
if model not in seen_models:
column_names.update(
{field.column for field in model._meta.local_concrete_fields}
)
seen_models.add(model)
group_by = list(self.select)
if self.annotation_select:
for alias, annotation in self.annotation_select.items():
signature = inspect.signature(annotation.get_group_by_cols)
if "alias" not in signature.parameters:
annotation_class = annotation.__class__
msg = (
"`alias=None` must be added to the signature of "
"%s.%s.get_group_by_cols()."
) % (annotation_class.__module__, annotation_class.__qualname__)
warnings.warn(msg, category=RemovedInDjango40Warning)
group_by_cols = annotation.get_group_by_cols()
else:
if not allow_aliases or alias in column_names:
alias = None
group_by_cols = annotation.get_group_by_cols(alias=alias)
group_by.extend(group_by_cols)
self.group_by = tuple(group_by)
from django-cte.
django-cte v1.2.0 released! 🎉
from django-cte.
Related Issues (20)
- Improve documentation HOT 3
- is there a way to select from a cte without joining it with a model? HOT 5
- Usage in the context of time series HOT 1
- Combining with django-reversion HOT 2
- Can I count all children in Queryset annotate? HOT 7
- annotate() usage in recursion HOT 5
- Unneccessary outer join breaks query HOT 1
- With(empty_qs) throws Error HOT 1
- “no such column”/“column does not exist” errors in Django 4.2 HOT 9
- Not able to do full outer join with django_cte HOT 2
- hnej
- `.update()` does not work when accessing nested tables HOT 1
- Minor : typo in the doc
- How to use as default manager? HOT 1
- Prefetch objects with their nested children
- issue while trying to use with_cte on EmptyResultSet HOT 1
- issue while using cte with union querysets
- Django 4.2 error: each UNION query must have the same number of columns HOT 3
- it's wrong number when i wnat to get total number by using count()
- WITH query name specified more than once HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-cte.