Re: Logging changes?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Nov 29 2007 - 11:30:26 EST

  • Next message: Kevin Menard: "Re: Logging changes?"

    Hi Michael,

    Can be nice for long parameter lists (such as inserts in tables with
    lots of columns).

    Does it require gathering some extra info during query translation
    phase to match parameters against column names? I guess that shouldn't
    add much overhead... just a sanity check...

    > 1->description:'Apple PowerBook 12" 1.5 GHz G4...',
    > 2->name:'PowerBook12S', 3->price:1699, 4->primaryKey:901

    Been playing with formatting a bit. Wonder if the form below makes it
    more readable? I guess that depends on personal preferences...

        description(1):'Apple PowerBook 12" 1.5 GHz G4...',
    name(2):'PowerBook12S', price(3)=1699, primaryKey(4)=901

    Andrus

    On Nov 29, 2007, at 4:22 PM, Michael Gentry wrote:

    > I was working on one thing and got distracted and changed the query
    > logging code a little bit. I wanted to get thoughts before checking
    > it in, especially since I had to change QueryLogger.logQuery() -- I
    > added an extra parameter for the database column attributes. The log
    > now includes the position number of the bind variable and the column
    > it is binding to.
    >
    > Here is an example from my demo/test application:
    >
    >
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: --- will run 1 query.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: INSERT INTO Items
    > (description, name, price, primaryKey) VALUES (?, ?, ?, ?)
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: [batch bind:
    > 1->description:'Apple PowerBook 17" 1.67 GHz G...',
    > 2->name:'PowerBook17S', 3->price:2699, 4->primaryKey:900]
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: [batch bind:
    > 1->description:'Apple PowerBook 12" 1.5 GHz G4...',
    > 2->name:'PowerBook12S', 3->price:1699, 4->primaryKey:901]
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: [batch bind:
    > 1->description:'Apple iMac 17" 1.8 GHz G5 with...', 2->name:'iMac17C',
    > 3->price:1299, 4->primaryKey:902]
    > ...
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: === updated 11 rows.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: +++ transaction
    > committed.
    >
    >
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: --- will run 1 query.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: --- transaction
    > started.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: SELECT t0.primaryKey,
    > t0.firstName, t0.lastName FROM Customers t0 WHERE (t0.firstName = ?)
    > AND (t0.lastName = ?) [bind: 1->firstName:'Jonathan',
    > 2->lastName:'Kent']
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: === returned 1 row. -
    > took 2 ms.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: +++ transaction
    > committed.
    >
    >
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: --- will run 1 query.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: --- transaction
    > started.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: UPDATE LineItems SET
    > quantity = ? WHERE primaryKey = ? AND quantity = ? AND itemFK = ? AND
    > orderFK = ?
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: [bind: 1->quantity:1,
    > 2->primaryKey:880, 3->quantity:2, 4->itemFK:909, 5->orderFK:881]
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: === updated 1 row.
    > cayenne INFO [main 11-29 08:14:20] QueryLogger: +++ transaction
    > committed.
    >
    >
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: --- will run 3
    > queries.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: --- transaction
    > started.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: DELETE FROM LineItems
    > WHERE primaryKey = ? AND quantity = ? AND itemFK = ? AND orderFK = ?
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: [bind:
    > 1->primaryKey:883, 2->quantity:1, 3->itemFK:902, 4->orderFK:884]
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: === updated 1 row.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: DELETE FROM Orders
    > WHERE primaryKey = ? AND isFilled = ? AND orderID = ? AND customerFK =
    > ?
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: [bind:
    > 1->primaryKey:884, 2->isFilled:'false', 3->orderID:'Q1000000',
    > 4->customerFK:881]
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: === updated 1 row.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: DELETE FROM Customers
    > WHERE primaryKey = ? AND firstName = ? AND lastName = ?
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: [bind:
    > 1->primaryKey:881, 2->firstName:'Jonathan', 3->lastName:'Kent']
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: === updated 1 row.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: +++ transaction
    > committed.
    >
    >
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: --- will run 1 query.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: --- transaction
    > started.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: SELECT t0.customerFK,
    > t0.primaryKey, t0.orderID, t0.isFilled FROM Orders t0 WHERE
    > t0.isFilled = ? [bind: 1->isFilled:0]
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: === returned 4 rows.
    > - took 1 ms.
    > cayenne INFO [main 11-29 08:14:21] QueryLogger: +++ transaction
    > committed.
    >
    >
    > I think it makes it easier to figure out what is binding where, but at
    > the expense of being more verbose. Does it seem a worthwhile change?
    > If so, I'll clean it up a tad and check it in.
    >
    > Thanks,
    >
    > /dev/mrg
    >



    This archive was generated by hypermail 2.0.0 : Thu Nov 29 2007 - 11:31:00 EST