本文介绍了Postgres ts_vector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我使用Seqeulize和Nodejs。 我的表名是Users,它有一个userName列。我已经命名了ts向量列userNameVector。在尝试创建列和设置触发器时,我不断收到错误errorMissingColumn。 显然它告诉我我的列userName不存在但我三重检查,它确实如此。 节点控制台中的日志如下: 执行(默认):ALTER TABLEUsersADD COLUMNuserNameVectorTSVECTOR 执行(默认):UPDATEUsersSETuserNameVector= to_tsvector('english',userName)执行(默认):CREATE INDEX userName_search_idx ONUsers使用gin(userNameVector); 执行(默认):CREATE TRIGGER userName_vector_update BEFORE INSERT或UPDATE ON每个行的用户执行过程tsvector_update_trigger(userNameVector,'pg_catalog.english',用户名) {[错误:列用户名不存在] 严重程度:'错误',代码:'42703',位置:'62',文件:'parse_relation.c',行:'2655',例程:'errorMissingColumn', sql:'UPDATE用户SETuserNameVector= to_tsvector(\'english\',userName)'} 解决方案看起来像是另一种误导性的CaMeL案例名称。 默认情况下,Postgres标识符是较低的。如果您使用非标准名称(合法,全部小写),并在创建时对其进行双引号引用,则必须在其余时间重复引用它们。所以: userName而不是 userName 相关: 关于标识符的手册 如果符合条件,防止插入 I am using Seqeulize with Nodejs.My table name is "Users" and it has a column "userName". I have named the ts vectored column userNameVector. In trying to create the column and set the triggers, I keep getting the error "errorMissingColumn".Apparently it is telling me that my column "userName" doesn't exist but I triple checked and it does.The log from the node console is as follows:Executing (default): ALTER TABLE "Users" ADD COLUMN "userNameVector" TSVECTORExecuting (default): UPDATE "Users" SET "userNameVector" = to_tsvector('english', userName)Executing (default): CREATE INDEX userName_search_idx ON "Users" USING gin("userNameVector");Executing (default): CREATE TRIGGER userName_vector_update BEFORE INSERT OR UPDATE ON "Users" FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger("userNameVector", 'pg_catalog.english', userName){ [Error: column "username" does not exist] severity: 'ERROR', code: '42703', position: '62', file: 'parse_relation.c', line: '2655', routine: 'errorMissingColumn', sql: 'UPDATE "Users" SET "userNameVector" = to_tsvector(\'english\', userName)' } 解决方案 Looks like another case of misguided CaMeL case names.Postgres identifiers are lower-cased by default. If you use non-standard names (legal, all lower-case) and double-quote them at creation, you have to double-quote them for the rest of their life. So:"userName" instead of userNameRelated:The manual on identifiersPrevent insert if condition is met 这篇关于Postgres ts_vector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-24 12:28