lpsmith / postgresql-simple

Mid-level client library for accessing PostgreSQL from Haskell
Other
206 stars 71 forks source link

Statement quote failure (create table) #249

Closed rsoeldner closed 6 years ago

rsoeldner commented 6 years ago

I run into this issue with variable table names:

mkTableStmt :: Query
mkTableStmt = [sql| CREATE TABLE ? (hi integer); |]

the formatQuery con mkTableStmt ["Foo"]

will generate the following: "CREATE TABLE 'Foo' ( hi integer);"

which will fail with *** Exception: SqlError {sqlState = "42601", sqlExecStatus = FatalError, sqlErrorMsg = "syntax error at or near \"'Foo'\"", sqlErrorDetail = "", sqlErrorHint = ""}

The problem is the single quote, which is not allowed in this place, the " is allowed.

Is this intended ?

Cheers

lpsmith commented 6 years ago

Hi, you might want to check out the Identifier and QualifiedIdentifier types.