May 11, 2015; 13:03
Tim Taplin
issues with casting results to custom type in DS
so, trying to put Ke’s wonderful DS library to work in a project where I’m trying to be as lean as possible.
I’m using the active_statements and their ability to return custom objects for each row of data. However, I’m running into an issue with the objects that are returned.
I’ve defined a ds type, created a method using active statement, but when I try to access a property of the custom object, it is empty.
here is the active statement:
define events => ds(::localpulse.events)->where('id > 0')->as(::pulse_event)
here is pulse_event
define pulse_event => type {
parent activerow
data public title::string = 'Raw'
public onCreate(...) => {
.’title’ = ‘Events'
log_critical('called events onCreate')
..onCreate(:#rest)
}
public getTitle() => {
return .'title'
}
}
I then call this as such:
local('data' = events())
and attempt to use the data:
with datarow in #data do {^
//this data is accessible, the data columns
#datarow->find('id’)
#datarow->find('label’)
#datarow->find('desc_short’)
//but this which is a property of the custom type is not
#datarow->title
//calling type returns the custom type’s name
#datarow->type
^}
The log statement inside the onCreate does not show up in the lasso log file. I had set the title to default to Raw and then set to the correct title to see if it was failing to reach that step for some reason, but it does not return either value. If I remove the data public title line, I get an error when calling #datarow->title, but when defined, I get nothing.
Any help or thoughts would be appreciated.
Tim Taplin
ps. it has been pointed out that in this case, ds is using the getType method to create an instance of the type and this may have side effects which explain my problems, but hoping that there’s a simple way around this issue.
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
May 11, 2015; 15:37
Brad Lindsay
Re: issues with casting results to custom type in DS
May 12, 2015; 09:55
Ke Carlton
Re: issues with casting results to custom type in DS