sripathikrishnan / jinjasql

Template Language for SQL with Automatic Bind Parameter Extraction
MIT License
820 stars 90 forks source link

Sqlite3 execute fails to execute when bind_params is ordered dict type #22

Closed dnswrsrx closed 4 years ago

dnswrsrx commented 5 years ago

Again, might just be an issue pertaining to sqlite3?

When preparing the query, the bind parameter is type ordered_dict. Executing the query and this bind parameter in sqlite3 raises a ValueError: parameters are of unsupported type exception. However, when we turn the bind parameter into a list (list(bind_parameter)), sqlite3 will execute the query just fine.

I wrote a gist to reproduce this bug.

nbon12 commented 5 years ago

I got the same issue for postgres, and the solution was also the same, list(bind_params) fixed it.

voyc-jean commented 4 years ago

Similar issue here with Postgres. As above, either cast OrderedDict to list or, the solution that I went with, set the param_style to pyformat:

j = JinjaSql(param_style='pyformat')

sripathikrishnan commented 4 years ago

I just pushed a fix for this issue - see https://github.com/hashedin/jinjasql/commit/543810a44e257573b6b6eacdf993a16e01505118

I will push a new release 0.1.8 later today.