db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4658) Allow explicit casts of string values to BOOLEAN
Date Thu, 17 Jun 2010 09:29:22 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12879720#action_12879720

Knut Anders Hatlen commented on DERBY-4658:

The patch looks fine to me. Some minor comments, though:

In BooleanConstantNode.init(), would it be better to pass Boolean.TRUE as the second argument
to super.init()? That's the argument that specifies nullability. Perhaps that would also remove
the need to call setNullability(true) in CastNode?

The tests look fairly complete, but they all use true/false/unknown in lowercase. Would it
be worthwhile to add a test case to verify that strings with upper case or mixed case also
can be cast to boolean?

And, a nit, this change in BooleanConstantNode.init() is unnecessary since (arg1 instanceof
Boolean) implies (arg1 != null):

-		if (arg1 instanceof Boolean)
+		if ( (arg1 != null) && (arg1 instanceof Boolean) )

Perhaps, for clarity, it may be better to have the null case first, though:

if (arg1 == null) {
} else if (arg1 instanceof Boolean) {
} else {

> Allow explicit casts of string values to BOOLEAN
> ------------------------------------------------
>                 Key: DERBY-4658
>                 URL: https://issues.apache.org/jira/browse/DERBY-4658
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Rick Hillegas
>            Assignee: Rick Hillegas
>         Attachments: derby-4658-01-aa-booleanCasts.diff
> The SQL Standard allows strings to be explicitly cast to BOOLEAN values. Strings are
the only type (other than BOOLEAN itself) which can be cast to BOOLEAN. As part of our expanding
support for the BOOLEAN datatype, we should allow these casts.
> Casting string types to boolean is defined by part 2, section 6.12 (<cast specification>),
general rule 20:
> a) Trim whitespace off the string
> b) Then apply the rules in section 5.3 (<literal>). This means that the trimmed
string must be 'TRUE', 'FALSE', or 'UNKNOWN', regardless of case.
> c) Otherwise, raise an exception.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message