Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    Is isEqualTo:(NSNull null) valid in qualifier?
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Journeyman
Posted
Hi,

I'm building a qualifier that will select all projects that have tasks that have no parent task. Here's the qualifier I created:

hasParentTaskQual := BDQualifier qualifierWhereValueOfKey:'tasks.parentTaskID' isEqualTo:(NSNull null).


Will Daylite correctly turn this qualifier into an SQL query something like "and task.parentTaskID is null" ?

Thanks,

Brendan
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Veteran
Picture of adam
Posted Hide Post
Hi Brendan, try this:

hasParentTaskQual := BDQualifier qualifierWhereValueOfKey:'tasks.parentTaskID' isEqualTo:nil.


adam
 
Posts: 643 | Location: san francisco bay area | Registered: June 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
I first tried that, but then Daylite crashed. I'll try again.
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Veteran
Picture of adam
Posted Hide Post
Hm, that's not good. Did the console show anything useful?


adam
 
Posts: 643 | Location: san francisco bay area | Registered: June 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
2007-03-20 13:37:03.274 Daylite[14360] objc: FREED(id): message description sent to freed object=0x19212010


The crash reporter built-in to Daylite came up for a brief moment, but then disappeared, so I can't get a stack trace for you.

Thanks,

Brendan
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Veteran
Picture of adam
Posted Hide Post
It sounds like something in your script is trying to message an object that has been released from memory. What's the context of this particular qualifier? What are you qurying against?

Cheers,


adam
 
Posts: 643 | Location: san francisco bay area | Registered: June 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
I'm trying to fetch all Organizations that have projects with tasks that have complete dates between a start and end date, that are done, that have no parent tasks (e.g. they are the root task).

Here's my code:

sys log:'fetching organizations'.

"projects with parent tasks with status Done"
doneTasksQual := BDQualifier qualifierWhereValueOfKey:'tasks.statusCode' isEqualTo:7.
hasParentTaskQual := BDQualifier qualifierWhereValueOfKey:'tasks.parentTaskID' isEqualTo: (NSNull null).

"user input values"
startDate := (element valueForKeyPath:'userInput.startDate') dateAsBeginningOfDay.
endDate := (element valueForKeyPath:'userInput.endDate') dateAsEndOfDay.
keyword := (element valueForKeyPath:'userInput.selectedKeyword').
taskType := (element valueForKeyPath:'userInput.selectedTaskType').

sys log:'selectedTaskType: '.
sys log:taskType.

"projects with tasks completed between start and end date"
startQual := BDKeyValueQualifier keyValueQualifierWithKey:'tasks.completeDate' operatorSelector:#isGreaterThan: value:startDate.
endQual := BDKeyValueQualifier keyValueQualifierWithKey:'tasks.completeDate' operatorSelector:#isLessThan: value:endDate.

quals := {hasParentTaskQual, doneTasksQual, startQual, endQual}.

keyword ~= nil ifTrue:
[
"projects with selected keyword"
keywordQual := BDQualifier qualifierWhereValueOfKey:'keywords.name' isEqualTo:keyword.
quals insert:keywordQual at:0.
].

taskType ~= nil ifTrue:
[
"tasks with selected task type"
taskTypeQual := BDQualifier qualifierWhereValueOfKey:'tasks.typeCode' isEqualTo:taskType.
quals insert:taskTypeQual at:0.
].

andQualifier := (((BDAndQualifier alloc) initWithQualifierArray:quals) autorelease).

sys log:andQualifier.

"fetch qualifying projects"
projects := objectContext objectsForEntityNamed:'Project' matchingQualifier:andQualifier.

"this returns an array of arrays of organizations, so we flatten them to a single array"
organizations := (projects valueForKeyPath:'organizations') flattenArrayOfArrays.

distinctOrgs := organizations distinct.

"remove null organizations"
distinctOrgs := distinctOrgs difference:{nil}.
distinctOrgs := distinctOrgs difference:{(NSNull null)}.

(distinctOrgs count) > 0 ifTrue:
[
sys log: ((distinctOrgs count) stringValue) ++ ' orgs found.'.
].
sys log:'done fetching organizations'.
sys log: (distinctOrgs valueForKeyPath:'name').

"now return the distinct set in case there are duplicates"
distinctOrgs.
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
If I could turn on SQL logging, I could see if the queries are correct to the database. Is there any flag I can set to turn SQL logging on?

Thanks,

Brendan
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Veteran
Picture of adam
Posted Hide Post
Is Daylite still hanging on the qualifier where you're trying to check if parentTaskID is null? Or is the script getting through that but not returning the right things otherwise?


adam
 
Posts: 643 | Location: san francisco bay area | Registered: June 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
It's getting through, but I'm not getting proper results. The list of projects coming back seems to include ones that shouldn't match the qualifiers specified. Originally I didn't have the parentTaskID qualifier, so I added it to see if that made the results come back properly. You see, when I run the report, I get back organizations and projects, but sometimes I get back "no data" where there would normally be tasks. However, the report is supposed to filter out projects and organizations that don't have tasks that match the qualifiers.

Thanks,

Brendan
 
Posts: 84 | Location: Calgary, Canada | Registered: December 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    Is isEqualTo:(NSNull null) valid in qualifier?

© Copyright 2006 Marketcircle Inc. All rights reserved.