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
Fixed #31300 -- Added GeneratedField model field. #16860
Conversation
@jpnauta Here's the first draft of Oracle support. |
I'm not sure why the jenkins builds aren't running properly. @felixxm any ideas? |
This might have coincided with the degraded performance/incident of GitHub actions on the 16th May (see here). Push up a small change (can reword a commit) and see if this fixes it? I can't see this PR in the list of stuff picked up by jenkins |
I'm new here. I think by pushing a small change and monitoring Jenkins, you can assess if the issue persists or if the new commit triggers the build successfully. This can help determine if the previous problem was due to the degraded performance of GitHub Actions or if there might be other underlying issues with Jenkins configuration or integration. |
That doesn't appear to have fixed things. |
Found an error log: https://djangoci.com/view/PR%20Builders/job/pr-mariadb/lastFailedBuild/console |
I'd start by fixing conflicts and rebasing from the |
I was hoping to avoid that because I didn't want to rebase @jpnauta's commits so this PR could cleanly land back on his. |
f540194
to
8b0c9fa
Compare
@felixxm At DjangoCon Europe sprints we discussed the Oracle error we're getting here and I think we settled on updating the Jenkins install to set |
@felixxm I've removed the extra feature flag. The main blocker I think is #16860 (comment), followed by fixing the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixxm I've removed the extra feature flag. The main blocker I think is #16860 (comment), followed by fixing the merge conflicts.
Tests should pass when a database doesn't support collations. I've added comments with required feature flags checks.
Can we make the error nicer for now? This feels like something we can try to find a solution for in Django 5.1 to me. Does explicitly registering the lookup with |
IMO, no, I don't know how we would detect that.
Not really as registering all class-related lookups on |
Not really as registering all class-related lookups on |
@pauloxnet Can you check the following patch? diff --git a/django/db/models/fields/generated.py b/django/db/models/fields/generated.py
index 56a2854d3c..8bf6969f9d 100644
--- a/django/db/models/fields/generated.py
+++ b/django/db/models/fields/generated.py
@@ -44,6 +44,8 @@ class GeneratedField(Field):
if self._output_field is not None
else self._resolved_expression.output_field
)
+ for lookup_name, lookup in self.output_field.get_class_lookups().items():
+ self.register_lookup(lookup, lookup_name=lookup_name)
def generated_sql(self, connection):
return self._resolved_expression.as_sql(
|
I'll try it ASAP |
It worked 👍🏻 >>> from geometricfigures.models import Document
>>> from django.contrib.postgres import search
>>> str(Document.objects.filter(search_vector=search.SearchQuery("deadline", config="english")).only("id").query)
'SELECT "geometricfigures_document"."id" FROM "geometricfigures_document" WHERE "geometricfigures_document"."search_vector" @@ (plainto_tsquery(english::regconfig, deadline))'
>>> str(Document.objects.filter(vector=search.SearchQuery("deadline", config="english")).only("id").query)
'SELECT "geometricfigures_document"."id" FROM "geometricfigures_document" WHERE "geometricfigures_document"."vector" @@ (plainto_tsquery(english::regconfig, deadline))'
>>> Document.objects.filter(vector=search.SearchQuery("deadline", config="english")).only("id")
<QuerySet [<Document: Document object (2)>]>
>>> Document.objects.filter(search_vector=search.SearchQuery("deadline", config="english")).only("id")
<QuerySet [<Document: Document object (2)>]> |
Thanks for checking 👍 |
1e15431
to
b4ed887
Compare
97717da
to
6ce7c09
Compare
I did further tests locally only finding problems for non-immutable functions in PostgreSQL. Apart from the documentation suggestions I've already sent, I have nothing more to add. Great job to all contributors, I think this is another great feature added to Django. |
fe89d97
to
c48c0f7
Compare
We're almost there 😪 only docs left 🚀 I'll continue later today/tomorrow. |
Squashed commits and pushed edits to release notes. |
c48c0f7
to
3313d07
Compare
Thanks Adam Johnson and Paolo Melchiorre for reviews. Co-Authored-By: Lily Foote <code@lilyf.org> Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
3313d07
to
f333e35
Compare
@jpnauta Thanks 👍 Welcome aboard 👍 @LilyFoote Thanks for pushing this to the finish line 🥇 |
Since the database always computed the value, the object must be reloaded | ||
to access the new value after :meth:`~Model.save()`, for example, by using | ||
:meth:`~Model.refresh_from_db()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always true? I'm wondering if for databases supporting RETURNING
we can/do update the instance to make a refresh unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, we could use UPDATE ... RETURNING
but let's leave some new features/cleanups for Django 5.1 😉
Thanks @LilyFoote @felixxm for pushing this through the finish line! It was a pleasure collaborating with you both 🥳 |
Builds on top of #16417.