mybatis/velocity-scripting

Boundary issue with the RepeatDirective

Closed this issue · 4 comments

The RepeatDirective takes the first 1000 items from the collection and ignores the remaining. It is appending the separator after the last item and before the closing character.
For example :

repeat($_parameter.ids $id ',' 'id IN (' ')')

    @{id}
  #end

Will generate
column IN (1,.......,1000,)

Hi Zaher, can you provide a test case?

On Fri, Mar 8, 2013 at 3:45 PM, Zaher hammoud notifications@github.comwrote:

The RepeatDirective takes the first 1000 items from the collection and
ignores the remaining. It is appending the separator after the last item
and before the closing character.
For example :
#repeat($_parameter.ids $id ',' 'id IN (' ')')
@{id}
#end
Will generate
column IN (1,.......,1000,)


Reply to this email directly or view it on GitHubhttps://github.com//issues/3
.

Frank D. Martínez M.

Frank,

The test case is provided with my commit (4a06211) . If you run it without my code fix it will fail with an Error/Exception.

Zaher

Below is the failing test case :

@test
public void testDynamicSelectWithIterationBoundary() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {

  List<Name> names = new ArrayList<Name>();
  for (int i = 0; i < 1001; i++) {
    names.add(new Name(i));
}

  Map<String, List<Name>> param = new HashMap<String, List<Name>>();
  param.put("names", names);
  List<Name> answer = sqlSession.selectList("org.mybatis.scripting.velocity.use.selectNamesWithIterationComplex", param);
  assertEquals(5, answer.size());
} finally {
  sqlSession.close();
}

}

Hi Zaher,

Thanks for your help. I will review this on Tuesday when I will be at home
again.

Many thanks,

Frank.

On Fri, Mar 8, 2013 at 10:23 PM, Zaher hammoud notifications@github.comwrote:

Below is the failing test case :

@test https://github.com/Test
public void testDynamicSelectWithIterationBoundary() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {

List names = new ArrayList();
for (int i = 0; i < 1001; i++) {
names.add(new Name(i));
}

Map<String, List> param = new HashMap<String, List>();
param.put("names", names);
List answer = sqlSession.selectList("org.mybatis.scripting.velocity.use.selectNamesWithIterationComplex", param);
assertEquals(5, answer.size());
} finally {
sqlSession.close();
}

}


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-14657091
.

Frank D. Martínez M.