I'm trying to convert a text column to tsvector, using a Rails migration:
change_column :people, :title, "tsvector USING title::tsvector"
It's getting caught up on special characters such as:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error in tsvector: "Project Manager: Software"
For some reason if I update the column, by say adding a space to the end, and rerun them migration, it works.
Any ideas why? So far it's happened with fields tat contain: :, &, í
CodePudding user response:
to_tsvector()
is for converting plain text to a tsvector.
::tsvector
is for asserting that the given text is already a valid representation of a tsvector, which yours is not.