dvdmgl / django-pg-fts

Implementation PostgeSQL for Full Text Search for Django >= 1.7
http://django-pg-fts.readthedocs.org/
Other
27 stars 13 forks source link

Make trigger function protect fts field against django updates #5

Closed askholme closed 9 years ago

askholme commented 9 years ago

The current trigger does not work with certain parts of the django ORM. Specifically if a field is changed after creation and the change does not affect one of the full text indexes columns then the fts field will be set to ''

To reproceudre call objects.create(..) to create an object change a non fts column on the object call .save() again

the UPDATE query from django will now contain <fts_field> = '' since '' was the value when .create() saved the object and django does not check for other updates.

Since non of the fts fields has changed the IF clause will block the recalculation of the FTS index and as a result the fts_field will get set to ''.

This simply ensures that the fts field cannot be changed by django