[英]Fiware Cygnus PostgreSQL sink does not create table when entity id contains special characters
It appears that cygnus-ngsi and its PosgreSQL sink can't create a postgres table when the entity has an id that contains the -
chracter, eg urn:ngsi-ld:Motion:001
as recommended in the Fiware tutorials .当实体的 id 包含
-
字符时, cygnus-ngsi及其 PosgreSQL 接收器似乎无法创建 postgres 表,例如urn:ngsi-ld:Motion:001
如Fiware 教程中推荐的那样。
I setup a simple stack with Orion, an IoT-Agent as well as Cygnus-NGSI and a PostgreSQL database.我使用 Orion、物联网代理以及 Cygnus-NGSI 和 PostgreSQL 数据库设置了一个简单的堆栈。
However, PostgreSQL reports the error但是PostgreSQL报错
2020-11-10 08:39:33.404 UTC [66] ERROR: syntax error at or near "-" at character 44
2020-11-10 08:39:33.404 UTC [66] STATEMENT: CREATE TABLE IF NOT EXISTS openiot.urn_ngsi-ld_motion_001_thing (recvTimeTs text,recvTime text,fiwareServicePath text,entityId text,entityType text,attrName text,attrType text,attrValue text,attrMd text)
The error does not occur when a different entity id is used.使用不同的实体 ID 时不会发生该错误。 Data is then persisted as expected.
然后数据按预期持久化。
Cygnus should replace non-alphanumeric characters inentity ids with _
, however, that does not appear to be happening. Cygnus 应该用
_
替换非字母数字字符 inentity id ,但是,这似乎没有发生。 Is this just a bug or do I need some sort of name mapping to solve this?这只是一个错误还是我需要某种名称映射来解决这个问题?
Looking to encoding section in the Postgresql sink documentation it seems no special encoding is done for -
.查看Postgresql sink 文档中的 encoding 部分,似乎没有对
-
进行特殊编码。
Thus, -
progresses as it is to Postgresql table creation logic and raises an error, due to it is forbidden in table names by the database.因此,
-
按照 Postgresql 表创建逻辑的方式进行并引发错误,因为数据库禁止在表名中使用它。
You can explore the name mappings option (although I'm not sure if you can change entity ids using it...).您可以探索名称映射选项(尽管我不确定您是否可以使用它更改实体 ID...)。 Another possible workaround (pretty simple) is not using
-
in entity ids, eg: urn:ngsild:Motion:001
另一种可能的解决方法(非常简单)不在实体 ID 中使用
-
,例如: urn:ngsild:Motion:001
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.