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 #27589 -- Added managed triggers for SearchVectorField. #7678
Conversation
…ing TABLESPACE "ram" to the end of SQL
It would be appropriate to post on the django-developers mailing list to try to get feedback from people who are using the field. |
I'd also like to know if it is possible to manage the trigger as objects on their own, maybe using Another thing about adding triggers is that it changes backup procedure. Idk if it's common to exclude them on postgres ( |
As Adam mentioned there's a lot of reason to believe a trigger based approach is not always the best solution. Is there a reason this cannot live as a third-party package? For the trigger creation and removal part you could do without a custom database backend by hooking into the |
The primary reason I added this is so that the On the other hand, I can't think of anything a database trigger solves that is otherwise impossible to do with a In cases where you want to cut down on the number of queries or how much data you are sending to postgres then stored procedures become very useful. I'm open to doing a more general purpose stored procedure building system. But I don't think that should be a blocker for this feature. The fact that the underlying code for the new |
Can we keep this pull request open a bit longer to get more feedback. If it turns out that it's not worth to add this to @charettes Thanks for the tip about the |
@eukreign there's an example of the |
Thanks for all of the feedback. I've decided to close the pull request. Using |
Could you update (close?) the ticket and mailing list thread also? |
Actually, is it possible to do a from django.contrib.postgres.search import SearchVector
@receiver(pre_save, sender=Task)
def task_search_vector(sender, instance, **kwargs):
instance.search = SearchVector('name', 'description') When I save a Task, it throws the following exception:
Maybe the trigger approach is still useful? |
@eukreign yes, expressions can be used for INSERT as of https://code.djangoproject.com/ticket/24509 / 134ca4d |
@jarshwah as you can see from the traceback above it does not seem to work, at least not for |
@eukreign F expressions explicitly can't be used for INSERT as they don't make sense, since there is no row to select the value out of. |
Another thing to consider is that bulk changes do not fire signals per instance. |
I have created a separate package for this for anyone interested: |
Definitely looking forward to the As far as Is there a good way to make a field deferred by default? |
You should mention that on the DEP, maybe there's a use case for always deferring such fields.
Not yet unfortunately. |
This is a significantly enhanced version of
django.contrib.postgresql.search.SearchVectorField
with automatically generated and managed database trigger.Remaining todo's:
tsvector
column if the fields on which it depends have changed (need to add a conditional in the pl/pgsql function check if relevant columns have changed)There are probably a lot of other things that will need to be done. Please provide feedback, thanks!
https://code.djangoproject.com/ticket/27589