sripathikrishnan / jinjasql

Template Language for SQL with Automatic Bind Parameter Extraction
MIT License
815 stars 89 forks source link

Extended array support #25

Open Photonios opened 5 years ago

Photonios commented 5 years ago

JinjaSQL makes the assumption that any iterable is going to be used in a IN clause. PostgreSQL has an array data type and arrays can actually be binded.

This PR adds a flag to disable the existing behaviour of raising MissingInClauseException when using an array as a value without |inclause.

bjmc commented 3 years ago

Is there any interest in getting this merged? I'd like to be able to generate Postgres array literals using jinjasql

clayadavis commented 3 years ago

Perhaps it would be preferable to keep the existing behavior when using an array as a value without a filter, but add a new filter like |array to make this more explicit and simpler to merge.

sripathikrishnan commented 2 years ago

I pushed a fix for this issue with commit 2dee6577a1f83396be5b6fa8192597ef328b11d8

I feel that the old behaviour is incorrect. Making an assumption about the type of bind parameter is not the job of JinjaSQL.

Instead of adding another filter like @clayadavis suggested, or adding another constructor flag like @Photonios suggested in the PR - I am going ahead and removing the MissingClauseException check altogether.

This is a backwards incompatible change, although a very minor one. As a result, I will bump the version major number to indicate a breaking change.

Thanks for all the help on this ticket!