-
Notifications
You must be signed in to change notification settings - Fork 92
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
Updates #115
Conversation
If only a subset of annotations is renamed before calling the base class, and then renamed back using add new key/remove old key, then the ordering of annotations is changed (annotations are stored in a OrderedDict internally). This will cause issues if ordering is important (e.g., in a union).
…figured to use psqlextra.backend
Hey @Photonios this commit b70d239 breaks my application. I have to stop using the default manager because it aliased |
Thanks for the heads up! I am going to figure out a fix or roll it back in the next release somehow. |
@Photonios here is a brief example class SomeReport(PostgresPartitionedModel):
class PartitioningMeta:
method = PostgresPartitioningMethod.RANGE
key = ["report_date"]
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
account = models.ForeignKey(to=Account, on_delete=models.DO_NOTHING)
report_date = models.DateField()
metric = models.IntegerField()
# ...
result = AmsCampaignReport.objects.filter(
account__in=some_set_of_accounts,
report_date__range=(start, stop)
).values(
"account_id",
date=F("report_date")
).annotate(
total_metric=Sum(F("metric"))
).all()
# {"account_id": xxxx, "date": "2020-10-01", "total_metric_new": 123}
# vs before this used to be
# {"account_id": xxxx, "date": "2020-10-01", "total_metric": 123} |
Hi! Thanks for the example. Could you tell me the Django and Postgres version you're using? I also noticed that in your example: |
@Photonios We are using postgres 11 and django 3.0 I've updated the example. Sorry it was some cut and paste issue that the |
@warmwaffles Sorry for the delay on this. I've reproduced your example as a test, but I cannot confirm the issue you're describing: #116 The tests pass on all Python and Django versions (from Python 3.5 to 3.9, Django 2.0 to 3.1). Could you show me how to adjust the test I linked to reproduce the problem you're describing? |
@Photonios I am getting a similar issue as @warmwaffles, but agree with you that it isn't always present. I'm running Postgres 10.14 and Django 3.1. In my experience this bug happens when I introduce a Case object. (Edited to make it more readable.)
I get the value as intended for I hope this makes sense and helps you to replicate the issue. |
Hi @DanielAlderman! Thanks for the extra details. Could you post the contents of the EDIT: Nevermind, |
@warmwaffles @DanielAlderman With the help of @DanielAlderman 's example, I managed to reproduce the issue and I've fixed it in this commit: 96fd08b I've released this fix in Please give this version a shot and let me know if you still have trouble. |
Hi @Photonios Thanks for looking at this so quickly, I've installed |
No description provided.