Disable/Remove "DeletedAt IS NULL"

57 views
Skip to first unread message

Brad

unread,
Aug 8, 2011, 2:21:56 PM8/8/11
to ColdFusion on Wheels
Hi everyone,
I thought I got this association thing down. Apparently not… This may
not be an association issue but than again I’ve been wrong before. So
here’s setup…

[Project.cfc - model]
<cffunction name="init">
<cfset belongsTo(name="customer", foreignKey="customerid")>
<cfset belongsTo(name="user", joinType="outer")>
<cfset hasMany(name="tasks", dependent="deleteAll")>
</cffunction>

[task.cfc model]
<cffunction name="init">
<cfset belongsTo(name="project", foreignKey="projectid")>
</cffunction>

[projects.cfc – controller]
<cffunction name="show">
<cfset project = model("Project").findByKey(key="#params.key#",
include="customer,user,tasks", returnAs="query", order="createdAt
DESC")>
</cffunction>

CFdump on projects/show/5 produces this SQL:
SQL:
SELECT
projects.id,projects.pname,projects.dueDate,projects.descriptions,projects.customerid,projects.userid,projects.createdAt,projects.updatedAt,projects.deletedAt,customers.cfname,customers.clname,customers.cemail,customers.cphone,customers.cfax,customers.ccompanyname,customers.caddress,customers.ccity,customers.cstate,customers.czip,customers.authcode,customers.createdAt
AS customercreatedAt,customers.updatedAt AS
customerupdatedAt,customers.deletedAt AS
customerdeletedAt,users.ufname,users.ulname,users.uemail,users.uphone,users.authcode
AS userauthcode,users.role,users.isactive,users.createdAt AS
usercreatedAt,users.updatedAt AS userupdatedAt,users.deletedAt AS
userdeletedAt,tasks.id AS taskid,tasks.projectid,tasks.userid AS
taskuserid,tasks.tname,tasks.tdescriptions,tasks.tlog,tasks.tstatus,tasks.createdAt
AS taskcreatedAt,tasks.updatedAt AS taskupdatedAt,tasks.DeletedAt AS
taskDeletedAt
FROM projects INNER JOIN customers ON projects.customerid =
customers.id LEFT OUTER JOIN users ON projects.userid = users.id LEFT
OUTER JOIN tasks ON projects.id = tasks.projectid
WHERE
(
(
projects.id =
5
) AND
projects.id IN
(5)
) AND (
projects.deletedAt IS NULL AND customers.deletedAt IS NULL AND
users.deletedAt IS NULL AND tasks.DeletedAt IS NULL
)
ORDER BY projects.createdAt DESC,projects.id ASC

Everything works fine until I delete a task from a project and wheels
populate the DeletedAt column with a date. The same query return
nothing because of this “AND tasks.DeletedAt IS NULL “.

Question one: How do I get around this, I want to return the projects
even thou the project have deleted tasks. Is there a way to disable or
remove “AND tasks.DeletedAt IS NULL” from the query?

Question Two: why is there a “AND projects.id IN (5)” in addition to
projects.id = 5”? Am I missing something?

Thank you in advance for you response!

Brad

unread,
Aug 8, 2011, 2:28:28 PM8/8/11
to ColdFusion on Wheels
I forgot to mention that I'm running Fusegrid with Wheels version1.1.3
and mySQL.

Brad

unread,
Aug 9, 2011, 1:55:33 AM8/9/11
to ColdFusion on Wheels
It’s hard to believe that no one else has encountered this situation.
I’m really curious how others are handling this.

I’ve temporary gotten it to work by renaming the DeletedAt column in
Tasks to DeleteOn. I’m wondering if I’m missing something from Wheels
baked-in arsenal that would address this issue.

I’m fairly new andthis is just a thought so please bare with me...
Maybe an additional parameters that would allow you to exclude the”
DeletedAt is NULL”. Perhaps in the hasMany(). In my case it would be
something like this.

<cfset hasMany(name=”tasks”, excludeDeletedAt=”false”,
dependent=”deleteAll)>

Thoughts?
Suggestion?

I’ll take anything, as always thanks guys!

AJ Mercer

unread,
Aug 9, 2011, 2:12:43 AM8/9/11
to cfwh...@googlegroups.com
maybe try it with Wheels 1.1.5


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.




--

AJ Mercer
<webonix:net strength="Industrial" /> | <webonix:org community="Open" />
http://twitter.com/webonix

Brad

unread,
Aug 9, 2011, 2:29:56 AM8/9/11
to ColdFusion on Wheels
AJ,

Thank you for response, I'll definitely try 1.1.5 when time permits. I
found "includeSoftDeletes" paramenter in findByKey, this maybe what I
was looking for. I'll play with it and see if I can get to do what I
need to. I must have over looked it! Doh!

On Aug 8, 11:12 pm, AJ Mercer <ajmer...@gmail.com> wrote:
> maybe try it with Wheels 1.1.5
>
> *AJ Mercer*
> <webonix:net strength="Industrial" /> <http://webonix.net> | <webonix:org
> community="Open" /> <http://webonix.org>http://twitter.com/webonix
> Railo Community Manager <http://www.getrailo.org/index.cfm/community/team/>
Reply all
Reply to author
Forward
0 new messages