tmenier / AsyncPoco

A long-"awaited" fully asynchronous PetaPoco fork
Other
127 stars 33 forks source link

Support array based parameters in Postgresql #53

Open d-p-y opened 6 years ago

d-p-y commented 6 years ago

Hi, At this moment it is not possible to use Postgresql's ANY() operator to pass arrays as sql input parameters.

When trying code such as


        public class SomeEntity
        {
            public int Id {get; set; }
        }

        public Task<List<SomeEntity>> AcceptRejectRule (AsyncPoco.Database dbConn) {            
            object ids = new [] { 1, 2, 3, 4 };
            return dbConn.FetchAsync<SomeEntity>("where id = ANY(@0)", ids);
        }

It fails because it generates: sql query: select id from SomeEntity where id = ANY(@0, @1, @2, @3) query parameters: SqlParameter(@0, 1), SqlParameter(@1, 2),SqlParameter(@2, 3),SqlParameter(@3, 4)

Implementation proposal as PR will follow shortly.