-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lenientString to SqlRow #84
Conversation
* Like [[stringOption]], but calls `getString` instead of `getObject`, so may | ||
* convert other types into Strings, depending on the driver. | ||
*/ | ||
def lenientStringOption(column: String): Option[String] = getResultSetOption(resultSet.getString(column)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as strictString
and strictStringOption
?
01676c1
to
1eaab4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like flipping those back is a more consistent solution. Everything else looks good
def strictString(column: String): String = resultSet.getString(column) | ||
def strictStringOption(column: String): Option[String] = getResultSetOption(resultSet.getString(column)) | ||
def strictString(column: String): String = string(column) | ||
def strictStringOption(column: String): Option[String] = stringOption(column) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd flip this personally. Have stringOption
call through to strictStringOption
rather than the other way around.
If 'strict' represents "matching the behavior from the ResultSet directly", and 'standard' methods represent 'the interface we want', then it makes sense for strictString
to call the resultSet, and it make sense of stringOption
to say "the behavior we want matches the ResultSet behavior"
@@ -73,8 +73,8 @@ class SqlRow(val resultSet: java.sql.ResultSet) extends ResultSetWrapper { | |||
def strictShortOption(column: String): Option[Short] = getResultSetOption(resultSet.getShort(column)) | |||
def strictSQLXML(column: String): SQLXML = resultSet.getSQLXML(column) | |||
def strictSQLXMLOption(column: String): Option[SQLXML] = getResultSetOption(resultSet.getSQLXML(column)) | |||
def strictString(column: String): String = resultSet.getString(column) | |||
def strictStringOption(column: String): Option[String] = getResultSetOption(resultSet.getString(column)) | |||
def strictString(column: String): String = string(column) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are changing strictString to get the "throw NoSuchElementExceptionbehavior, rather than
nullor
0`. Why aren't we changing strictLong as well? (Again, this is why I'd 'flip' the implementation of strictString and strictStringOption back)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I meant to undo that change.
Instead of calling getObject and inspecting the type. This makes the parsers more consistent. And restores the previous behavior of ColReaders. This makes it so longOption, bigDecimalOption, and stringOption, etc. may not throw exceptions in cases where it did before. But I think this is probably the behavior that would be expected.
1eaab4b
to
0d6e141
Compare
And use it for ColReader to restore previous behaviour