java.jdbc

jdbc insert-records can not handle spaces in columnames

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Postgres on Debian

Description

If a database contains column-names that include spaces an sql/insert-record will fail. However, inserting via sql/do-commands or sql/insert-rows works as expected.

Attached you find a file showing the error.

Activity

Hide
Cees van Kemenade added a comment - - edited

Further analysis based on a suggestion of Sean leads to:

It seems to be that there is an issue in the naming-strategy in this issue. Either in the way I define it of the way it is implemented
(sql/with-connection db
(sql/with-naming-strategy {:keyword identity :entity (fn [x] (str \" x \"))}
...
))

When I remove the naming-strategy and replace the offending insert by a manual quoting strategy via
(sql/insert-records "test_jdbc_naming3" {((fn [x] (str \" x \")) "b- b") 7})
which corresponds to
(sql/insert-records "test_jdbc_naming3" {"\"b- b\"" 7})
then the code runs fine.

So the issue is located in the handling of the naming-strategy, or in the way I defined the naming-strategy (for postgres).

Show
Cees van Kemenade added a comment - - edited Further analysis based on a suggestion of Sean leads to: It seems to be that there is an issue in the naming-strategy in this issue. Either in the way I define it of the way it is implemented (sql/with-connection db (sql/with-naming-strategy {:keyword identity :entity (fn [x] (str \" x \"))} ... )) When I remove the naming-strategy and replace the offending insert by a manual quoting strategy via (sql/insert-records "test_jdbc_naming3" {((fn [x] (str \" x \")) "b- b") 7}) which corresponds to (sql/insert-records "test_jdbc_naming3" {"\"b- b\"" 7}) then the code runs fine. So the issue is located in the handling of the naming-strategy, or in the way I defined the naming-strategy (for postgres).
Hide
Sean Corfield added a comment -

Fixed in 0.3.0-SNAPSHOT by wiring as-str variable into compatibility layer as :entities argument.

Show
Sean Corfield added a comment - Fixed in 0.3.0-SNAPSHOT by wiring as-str variable into compatibility layer as :entities argument.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: