divdat (5) [Avatar] Offline
#1
Sorry, I had some errors in my example in the previous post ....

Why does the method

getProperty(String JavaDoc property)
throw a MissingPropertyException
if a properties value is NULL coming back from an query?

Yet, the method getAt(int index)
returns a string if it is NULL?

I can understand if the property itself doesn't exist in a List to throw the MissingPropertyException, but if the property exists, but the value is NULL, why not return the result.toString() as it does in the getAt method?

It makes it kind of convoluted to have to know if a property MIGHT be a null value in a database, and so you mix/match a println such as
for (i in 0..myList.size()-1) {
println myList[i].firstColumnIsAlwaysNotANull + " " + \r
myList[i].secondColumnMightBeNull //throws the Exception
}

vs.

for (i in 0..myList.size()-1) {
println myList[i].firstColumnIsAlwaysNotNull + " " + \r
myList[i][0]?.toString()
}

Thanks for your help.
divdat (5) [Avatar] Offline
#2
Re: GroovyRowResult
Sorry, I had some errors in my example in the previous post .... again ....

Why does the method

getProperty(String JavaDoc property)
throw a MissingPropertyException
if a properties value is NULL coming back from an query?

Yet, the method getAt(int index)
returns a string if it is NULL?

I can understand if the property itself doesn't exist in a List to throw the MissingPropertyException, but if the property exists, but the value is NULL, why not return the result.toString() as it does in the getAt method?

It makes it kind of convoluted to have to know if a property MIGHT be a null value in a database, and so you mix/match a println such as
for (i in 0..myList.size()-1) {
println myList[i].firstColumnIsAlwaysNotANull + " " + \r
myList[i].secondColumnMightBeNull //throws the Exception
}

vs.

for (i in 0..myList.size()-1) {
println myList.firstColumnIsAlwaysNotNull + " " + \r
myList[i][0]?.toString()
}

Thanks for your help.
Mittie (397) [Avatar] Offline
#3
Re: GroovyRowResult
Hi divdat,

where did you find the code that you are referring to?
Could you please refer to the section/page/listing number?

thanks
Dierk
divdat (5) [Avatar] Offline
#4
Re: GroovyRowResult
Dierk,

I'm sorry, the code is from http://kickjava.com/src/groovy/sql/GroovyRowResult.java.htm

I followed the examples in your book, Groovy In Action, and then was trying to a program to work, utilizing the information on page 337 of the book ("NOTE The list items are implemented as GroovyRowResult objects, the equivalent of GroovyResultSet as used with eachRow.")

After finding that I am having trouble with NULL values for properties using this, I found the source code mentioned above, and that is where I think the problem lies. Maybe I have an earlier version of Groovy (groovy-1.0.5-jsr-05) and this has been fixed since? Or maybe it isn't a problem but how I am trying to use it?

Also, for some reason, I can't get my source example to post correctly in this forum. It is removing square brackets and content within them, but I think you get the idea of what I am trying to convey.

Thanks for your help!
divdat (5) [Avatar] Offline
#5
Re: GroovyRowResult
Dierk,

I'm sorry to have wasted your (and others) time on this.

I researched this a bit more, and the bug has been fixed.

I downloaded the Groovy 1.6.1 version to replace my old one, and the GroovyRowResult
getProperty method is working properly ---- returning a NULL string for a property.
Mittie (397) [Avatar] Offline
#6
Re: GroovyRowResult
No problem.

keep groovin'
Dierk