Skip to content

Commit

Permalink
Failed test case submission for issue mybatis#62
Browse files Browse the repository at this point in the history
  • Loading branch information
mallim committed Jul 16, 2013
1 parent 11bf862 commit 0b94647
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package org.apache.ibatis.submitted.call_setters_on_nulls;

import java.io.Reader;
import java.sql.Connection;
import java.util.Map;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.apache.ibatis.session.SqlSession;
Expand All @@ -28,6 +24,11 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.Reader;
import java.sql.Connection;
import java.util.List;
import java.util.Map;

public class CallSettersOnNullsTest {

private static SqlSessionFactory sqlSessionFactory;
Expand Down Expand Up @@ -86,4 +87,19 @@ public void shouldCallNullOnMap() {
}
}

@Test
public void shouldCallNullOnMapForSingleColumn() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
Mapper mapper = sqlSession.getMapper(Mapper.class);
List<Map<String,Object>> oneColumns = mapper.getNameOnly();
for( Map<String,Object> onecol: oneColumns )
{
Assert.assertTrue( onecol.containsKey( "NAME" ) );
}
} finally {
sqlSession.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@

drop table users if exists;

drop table users2 if exists;

create table users (
id int,
name varchar(20)
);

create table users2(
id int,
name varchar(20)
)

insert into users (id, name) values(1, NULL);

insert into users2 (id, name) values( 2, 'mary' );
insert into users2 (id, name) values( 3, 'angel' );
insert into users2 (id, name) values( 1, NULL );


Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/
package org.apache.ibatis.submitted.call_setters_on_nulls;

import java.util.List;
import java.util.Map;

public interface Mapper {

User getUserMapped(Integer id);
User getUserUnmapped(Integer id);
Map getUserInMap(Integer id);
List<Map<String,Object>> getNameOnly();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@
<result property="name" column="name" />
</resultMap>

<select id="getNameOnly" resultType="map">
select name from users2
</select>

</mapper>

0 comments on commit 0b94647

Please sign in to comment.