empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele (JIRA) <empire-db-...@incubator.apache.org>
Subject [jira] [Resolved] (EMPIREDB-189) DBDatabase.getSingleInt with default does not return the default but throws an exception.
Date Thu, 05 Sep 2013 08:33:52 GMT

     [ https://issues.apache.org/jira/browse/EMPIREDB-189?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Rainer Döbele resolved EMPIREDB-189.
------------------------------------

       Resolution: Fixed
    Fix Version/s: empire-db-2.4.2

After long thoughts about this issue, I came to the conclusion that there is obviously no
reason why to distinguish between a result of NULL or an empty query i.e. in most cases the
caller does not need to distinguish as both represent a failed result. Hence there is no need
to distinguish in the method's behavior.

Changing the methods' signature or create even more new overloads to the already (plenty)
existing methods would have been a too strong measure for this issue. But IMO it is acceptable
to change the behaviour of those methods that take a defaultValue parameter to return the
default value in either case.
For those methods without a default value, I would instead throw a QueryNoResult Exception
in both cases, i.e. either if the query returned no result or the result was null as the result
is undefined for such a case (and cannot be converted to a number). Only in the case of querySingleString()
as a query result of NULL should return an empty String. 

Details for the behavior of each method can be found in the Javadoc.
                
> DBDatabase.getSingleInt with default does not return the default but throws an exception.
> -----------------------------------------------------------------------------------------
>
>                 Key: EMPIREDB-189
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-189
>             Project: Empire-DB
>          Issue Type: Bug
>    Affects Versions: empire-db-2.4.1
>            Reporter: Harald Kirsch
>            Assignee: Rainer Döbele
>             Fix For: empire-db-2.4.2
>
>
> The method getSingleInt with default value should return the default value if there is
no record found in the database.
> Instead it throws QueryNoResultException, which correctly comes right out of querySingleValue.
> getSingleInt should catch the exception and return the default provided.
> Alternatively, I would rather add the default value also to getSingleValue to prevent
the expensive generation of an exception in this case. This, however, would make it difficult
to have null as the default value. But I think this is rather not a meaningful default in
a db context anyway.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message