Export to GitHub

mybatisnet - issue #32

Issue with select with iteration - "off by one" problem?


Posted on Aug 15, 2011 by Swift Ox

Hi, I am using mybatis.net 1.6.2.0 (data mapper) with data access 1.9.2.0

I have "iterated" select like this:

<select id="GetIdsByPolicyIdAndCodes" resultClass="int" parameterClass="System.Collections.IDictionary"> SELECT IDPredmetOsig FROM PredmetOsig WHERE (IDPolisa = #InsurancePolicyId#) AND SifPredmetOsig IN <iterate open="(" close=")" conjunction=","> #InsuredSubjectCodes[]# </iterate> </select>

InsuredSubjectCodes# is key of entry in dictionary where value is list of strings. It works correctly if list of strings is of size 2 or greater.

However if I pass list with just one element I got:

IBatisNet.DataAccess.Exceptions.DataAccessException : DaoProxy : unable to intercept method name 'GetIdsByPolicyIdAndCodes', cause : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index ----> System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Please provide any additional information below.

Ok, there is not much point in select...where...in with only one element but this is general purpose statement which should work regardless of size of input collection.

Status: New

Labels:
Type-Defect Priority-Low