Truncate table with sqlkorma

130 Views Asked by At

I just can't get the query to simply truncate a table to work with korma:

(korma.core/defentity readings)
(korma.core/exec-raw ["TRUNCATE TABLE ?" [:name readings]]) 

and I get:

Syntax error in SQL statement "TRUNCATE TABLE ?[*]"; expected "identifier"; SQL statement:
TRUNCATE TABLE ? [42001-191]
1

There are 1 best solutions below

0
Jonah Benton On

As one of the comments suggests, bind parameter substitution is only for values in DML, not for schema in DML or DDL. It's a semantic distinction, not syntactic.

The

(k/exec-raw (str ...))

form should work, using the vector form even with an empty parameter vec may not.