Chris Peters
unread,Feb 10, 2012, 11:51:27 AM2/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ColdFusion on Wheels
Database: SQL Server 2008
ColdFusion: 9.0.1
Wheels: 1.1.2
In a system I'm working on, we have "service transactions" that record
services that our client performs for their customers. There is an
action in the system where you can "adjust" a service transaction.
What that does is mark the service transaction as "isAdjusted" and
creates a new record that is a copy with the adjustments applied. This
sounds complex, but there is quite a bit of callback magic that
happens to many other tables in the database when you do one of these
service transactions. (It handles equipment inventory and records tons
of other info that's used for invoicing purposes.)
In the adjust() method of the model, I start my own database
transaction, do the operations on the current and new transactions,
and commit or rollback manually based on whether validation and
callbacks run successfully on the objects. To get this working, I pass
transaction="none" to the Wheels ORM on any of its save(), update(),
create(), whatever() operations.
Here's a simplified version of the code that shows where the real
issue is.
transaction
{
// Update this record so it's marked as adjusted and undo equipment
changes
if (local.currentServiceTransaction.undo(transaction="none"))
{
if (local.newServiceTransaction.save(transaction="none"))
transaction action="commit";
else
transaction action="rollback";
}
else
{
transaction action="rollback";
}
}
The problem is with the undo() method that gets called in the first if
statement. Here's basically what it does:
<cffunction name="undo">
<cfargument name="transaction" type="string" required="false"
default="commit" hint="Whether or not to wrap this process in a
transaction.">
<cfreturn this.update(isAdjusted=1,
transaction=arguments.transaction, callbacks=false, validate=false)
and variables.
$undoClientServices(transaction=arguments.transaction)>
</cffunction>
The call to this.update() is the most important part to note.
Now look back to my first code snippet. Let's say that
local.currentServiceTransaction.undo() returns true, and it proceeds
to local.newServiceTransaction.save(). If that returns false, it's
supposed to rollback the entire transaction, but it doesn't.
isAdjusted remains true, when it should have rolled back to false.
Is this working the ways it's supposed to, or is it a bug?
Sorry if this is a little hard to follow. I can provide more details
if needed.
- Chris