Dapper: How to turn Arrays support off in v1.31

Created on 27 Aug 2014  Â·  18Comments  Â·  Source: StackExchange/Dapper

The ability to turn off arrays support has been removed on version 1.31

FeatureSupport.Get(cn).Arrays = false;
This doesn't work anymore since the property can only be set privately. I wonder the reason behind this.
There are some queries in PostGreSQL in which it is convenient to turn array support off.

Thanks.
Diego

postgresql needs-investigation

Most helpful comment

after upgrading dapper NuGet package my queries using IN operator stopped working

One possible solution for PostgreSQL is to use WHERE id = ANY(@Ids) instead of WHERE id IN @Ids as described here.

All 18 comments

I just got bitten by this too, after upgrading dapper NuGet package my queries using IN operator stopped working. Taken straight from my code:

c# static BLFactory() { // new workaround for dapper / npgsql misfeature // http://stackoverflow.com/questions/22561318/why-does-dapper-generate-different-sql-with-without-a-mini-profiler-connection // https://code.google.com/p/dapper-dot-net/issues/detail?id=107&q=postgres // // original workaround described above was silently removed (made readonly) in // b3927ce1340592310a8991e059d7ed39c609663d (between versions 1.30 and 1.31) // see https://github.com/StackExchange/dapper-dot-net/issues/150 NpgsqlConnection conn = new NpgsqlConnection(); var features = Dapper.FeatureSupport.Get(conn); features.GetType().GetProperty("Arrays").SetValue(features, false, null); }

Any break was not intended. Will look.
On 22 Oct 2014 11:28, "Petr BÄ›han" [email protected] wrote:

I just got bitten by this too, after upgrading dapper NuGet package my
queries using IN operator stopped working. Taken straight from my code:

    static BLFactory() {
        // new workaround for dapper / npgsql misfeature
        // http://stackoverflow.com/questions/22561318/why-does-dapper-generate-different-sql-with-without-a-mini-profiler-connection
        // https://code.google.com/p/dapper-dot-net/issues/detail?id=107&q=postgres
        //
        // original workaround described above was silently removed (made readonly) in
        // b3927ce1340592310a8991e059d7ed39c609663d (between versions 1.30 and 1.31)
        // see https://github.com/StackExchange/dapper-dot-net/issues/150
        NpgsqlConnection conn = new NpgsqlConnection();
        var features = Dapper.FeatureSupport.Get(conn);
        features.GetType().GetProperty("Arrays").SetValue(features, false, null);
    }

—
Reply to this email directly or view it on GitHub
https://github.com/StackExchange/dapper-dot-net/issues/150#issuecomment-60122429
.

after upgrading dapper NuGet package my queries using IN operator stopped working

One possible solution for PostgreSQL is to use WHERE id = ANY(@Ids) instead of WHERE id IN @Ids as described here.

It would be great to have this solved. Conditions like WHERE id IN @Ids don't work at all with Dapper and PostgresSQL and there seems to be not workaround.

Just got this today

@NickCraver @mgravell what needs investigating? this issue still exists on 1.50.3-beta1

Issue is this:

https://github.com/StackExchange/dapper-dot-net/blob/91725fb309a9e5948f760fac420dd805659f0749/Dapper/FeatureSupport.cs#L13
https://github.com/StackExchange/dapper-dot-net/blob/91725fb309a9e5948f760fac420dd805659f0749/Dapper/SqlMapper.cs#L1868

No way to turn it off so when npgsql receives something like select * from table where if not in (@ids) it errors with "42883: operator does not exist: integer <> integer[]" as its trying to compare it to an array of ints for an int. Only way to get it executing is to change the sql to be select * from table where id != ALL(ARRAY[@ids])

Sorry, this fell between some cracks. Will fix asap

On 18 Nov 2016 6:18 p.m., "Jonathan Channon" [email protected]
wrote:

Issue is this:

https://github.com/StackExchange/dapper-dot-net/blob/
91725fb309a9e5948f760fac420dd805659f0749/Dapper/FeatureSupport.cs#L13
https://github.com/StackExchange/dapper-dot-net/blob/
91725fb309a9e5948f760fac420dd805659f0749/Dapper/SqlMapper.cs#L1868

No way to turn it off so when npgsql receives something like select *
from table where if not in (@ids) it errors with "42883: operator does
not exist: integer <> integer[]" as its trying to compare it to an array
of ints for an int. Only way to get it executing is to change the sql to be select

  • from table where id != ALL(ARRAY[@ids])

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/StackExchange/dapper-dot-net/issues/150#issuecomment-261602459,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABDsHK-ddxXV47GGkDr5Enq5Z4jFfUtks5q_ev8gaJpZM4Cb30Y
.

:+1:

Any update to this?

On 18 November 2016 at 19:05, Marc Gravell notifications@github.com wrote:

Sorry, this fell between some cracks. Will fix asap

On 18 Nov 2016 6:18 p.m., "Jonathan Channon" notifications@github.com
wrote:

Issue is this:

https://github.com/StackExchange/dapper-dot-net/blob/
91725fb309a9e5948f760fac420dd805659f0749/Dapper/FeatureSupport.cs#L13
https://github.com/StackExchange/dapper-dot-net/blob/
91725fb309a9e5948f760fac420dd805659f0749/Dapper/SqlMapper.cs#L1868

No way to turn it off so when npgsql receives something like select *
from table where if not in (@ids) it errors with "42883: operator does
not exist: integer <> integer[]" as its trying to compare it to an array
of ints for an int. Only way to get it executing is to change the sql to
be select

  • from table where id != ALL(ARRAY[@ids])

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
issues/150#issuecomment-261602459>,
or mute the thread
ddxXV47GGkDr5Enq5Z4jFfUtks5q_ev8gaJpZM4Cb30Y>
.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/StackExchange/dapper-dot-net/issues/150#issuecomment-261614233,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGapuAKglErq266rL1irnftDcJSIt6Dks5q_fcJgaJpZM4Cb30Y
.

I'm running into exactly the same problem using PostgreSQL with Dapper.
Unfortunately FeatureSupport has now been made a private type so it is impossible to disable via Reflection. Looking forward to a fix for this one.

👀

Is there a workaround for this issue?

Is there any update on this issue @mgravell l? It looked like a fix was imminent as of November 2016, but the issue is still there.

A fix for this issue would simplify my life. Currently I am commenting and uncommenting Postgres and MSSql specific query lines when I switch between providers. It works but it's hokey.

Bump!

Attending to the issue title it seems like a feature request, but it is actually a bug report.

Postgres driver is broken if queries like this select * from table where if not in (@ids) can not be executed.

One possible solution for PostgreSQL is to use WHERE id = ANY(@Ids) instead of WHERE id IN @Ids as described here.

This workaround has different interactions with Postgres indexes: https://dba.stackexchange.com/questions/125413/index-not-used-with-any-but-used-with-in

Was this page helpful?
0 / 5 - 0 ratings

Related issues

valinoment picture valinoment  Â·  4Comments

Abdallah-Darwish picture Abdallah-Darwish  Â·  3Comments

nhathongly picture nhathongly  Â·  3Comments

ishamfazal picture ishamfazal  Â·  5Comments

yozawiratama picture yozawiratama  Â·  5Comments