pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

Postgresql tables including spaces in their names are no more supported

Open Alex-NRCan opened this issue 2 years ago • 2 comments

Description Following a recent commit of Monday April 25th 2022 (SHA-1: 15e7deabed7dbcb48a77241d43f1d1ebe62d4ed4), we've been experiencing a new issue connecting to postgresql tables which contain spaces in their names. The commit refers to a fix regarding SQL injection, which is great, but it introduced an issue with postgresql tables containing spaces in their names. Admittedly, having spaces in a database table name isn't very good practice, but Postgresql does support that.

Steps to Reproduce Configure yml to connect to a postgresql table with spaces in their name. Run pygeoapi openapi generate [...] to get an invalid name syntax error message.

Expected behavior The connection to the postgresql table should be working (it was working before).

Environment

  • OS: Windows
  • Python version: 3.9.7
  • pygeoapi version: 0.13.dev0

Additional context I can make it work with spaces by replacing line 130 with this (not too fancy, but proves the issue) line of code which adds quotes around the table name

#self.cur.execute(query_cols, (self.table,))
self.cur.execute(query_cols, ('"' + self.table + '"',))

Alex-NRCan avatar Apr 29 '22 14:04 Alex-NRCan

Comment from the bleachers: Yikes, that sounds like disaster managing a PostgreSQL database with spaces in tablenames, this will cause breaks in so much FOSS4G software downstream (and since my work is on Windows, I know from experience that this becomes a mixture of single and double quote chaos ha, breaking most software and likely not even supported by the FOSS4G commandline utilities).

jmckenna avatar Apr 30 '22 11:04 jmckenna

As per RFC4, this Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.

github-actions[bot] avatar Mar 10 '24 21:03 github-actions[bot]

As per RFC4, this Issue has been closed due to there being no activity for more than 90 days.

github-actions[bot] avatar Mar 31 '24 03:03 github-actions[bot]