From: Steve F. <st...@m3...> - 2002-04-02 23:45:47
|
Thanks for the prompt. We'll take a look (unless you're being modest and know that this fix should really be made). One thought, though, is it likely that you would write code that gets both the string and the other type? If not, you could always set 'aBoolean" to be "false" yourself. Has this actually been a problem for you, or are you concerned about conforming to the spec? Steve ----- Original Message ----- From: "Benjamin Rosenbaum" <ben...@co...> To: <moc...@li...> Sent: Tuesday, April 02, 2002 3:26 PM Subject: [MO-java-dev] Question about MockResultSet.getString > > Hi all > > My impression is that java.sql.ResultSet.getString(...) gives you a > String representation even if the datatype is not a String (that is, it > tries to do a conversion for you). > > Currently if you do: > > String columns[] = { "aString", "anInt", "aBoolean", "aDouble" }; > Object values[] = { "FOO", new Integer(123), new Boolean(false), > new Double(0.02) }; > > ResultSet rset = new MockSingleRowResultSet(columns, values); > > return rset.getString("aBoolean"); > > You get an exception. Is this the correct behavior? > > My impression is that the proper behavior is what I get when I do > > String columns[] = { "aString", "anInt", "aBoolean", "aDouble" > }; > Object values[] = { "FOO", new Integer(123), new Boolean(false), > new Double(0.02) }; > > ResultSet rset = new MockSingleRowResultSet(columns, values) > { > public String getString(String columnName) throws > SQLException > { > return super.getObject(columnName).toString(); > } > }; > > return rset.getString("aBoolean"); > > > Should MockResultSet be changed accordingly? > > cheers > > Ben Rosenbaum > COMIT AG > > > > > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > |