tattocau / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
1 stars 1 forks source link

Parameterized list does not work with Postgres as documented #107

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Executing any query on Postgres which uses a parameterized list query as shown 
in the examples (e.g. where Id in @Ids", new { Ids = new int[] { 1, 2, 3 }})

What is the expected output? What do you see instead?
Should execute the query, but we get a Postgres error instead: operator does 
not exist: character varying = text[].

What version of the product are you using? On what operating system?
Running on mono 2.10.8.1 on Ubuntu precise, but shouldn't matter.

Please provide any additional information below.
The problem is simple... In Postgres you can't use the IN SQL operator to check 
against arrays, you must use the special ANY keyword. Basically:
Bombs: DELETE FROM table WHERE id IN @Ids
Works: DELETE FROM table WHERE id = ANY @Ids

This makes the SQL for parameterized lists database-dependent. At the very 
least maybe add a note in the dapper doc page?

Original issue reported on code.google.com by r...@roji.org on 25 Jul 2012 at 2:30

GoogleCodeExporter commented 8 years ago
A Stackoverflow question with the same problem (and a workaround):

http://stackoverflow.com/questions/22561318/why-does-dapper-generate-different-s
ql-with-without-a-mini-profiler-connection

Original comment by stma...@gmail.com on 5 Aug 2015 at 1:20