Skip to content
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

PostgreSQL sink does not create table when entity id contains special characters #1977

Open
jlsiewert opened this issue Nov 11, 2020 · 4 comments · May be fixed by #2220
Open

PostgreSQL sink does not create table when entity id contains special characters #1977

jlsiewert opened this issue Nov 11, 2020 · 4 comments · May be fixed by #2220

Comments

@jlsiewert
Copy link

jlsiewert commented Nov 11, 2020

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, e.g. urn:ngsi-ld:Motion:001 as recommended in the Fiware tutorials.

I setup a simple stack with Orion, an IoT-Agent as well as Cygnus-NGSI and a PostgreSQL database.

However, PostgreSQL reports the error

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.
Data is then persisted as expected.

Cygnus should replace non-alphanumeric characters in entity ids with _, however, that does not appear to be happening.
Is this just a bug or do I need some sort of name mapping to solve this?

@fgalan
Copy link
Member

fgalan commented Feb 10, 2021

@fgalan
Copy link
Member

fgalan commented Feb 10, 2021

The limitation should be at least documented. Maybe every sink should have a "Syntax restrictions" section (or a better name :) to describe this kind of things, starting with Postgresqt sink based on this issue.

@jlsiewert
Copy link
Author

This limitation should probably be documented in this project as well as in the getting started guide.

Looking at the current encoding this leaves the dash in a weird space, especially because even Unicode seems to be supported in entities id.
Considering that it is recommended to append the literal urn:ngsi-ld: in front of each id it feels like this sink should handle dashes and colons as well.

@fgalan
Copy link
Member

fgalan commented Feb 10, 2021

Considering that it is recommended to append the literal urn:ngsi-ld: in front of each id it feels like this sink should handle dashes and colons as well.

Maybe the authors of that document should change the recommendation to urn:ngsild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants