Re: [SQLObject] How to provide default non-null values for foreign keys?

2008-07-23 Thread Luke Opperman
As Oleg notes, your default argument call to byName is evaluated at class creation time ie, before you've created the Sales Department record. In the same way, if you had: when = DateTimeCol(default=now()) the default would always be the value returned by now() at the time the class is imported

Re: [SQLObject] RelatedJoin

2008-05-16 Thread Luke Opperman
First off, let me say I feel RelatedJoin and MultipleJoin should be deprecated to be renamed RawRelatedJoin/RawMultipleJoin, there are two better alternatives available since at least 0.8: * SQLRelatedJoin and SQLMultipleJoin * ManyToMany and OneToMany Yes, the docs need a massive overhaul on

Re: [SQLObject] j-magic (was: basic RelatedJoin + select question)

2008-03-18 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: >Thank you very much! Now if I only can formulate a short description for > it. ".j attribute on SO classes" is not very informative. >"New magic attribute 'j' similar to 'q' that automagically does join > with the other table in FK/MultipleJoin"? Yeah, t

Re: [SQLObject] basic RelatedJoin + select question

2008-03-17 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: >Looks good, and 'j' is pretty good "magic" name, IMHO. Will you work on > a patch? > r3342 in trunk. New subclass of sqlbuilder.SQLObjectTable named SQLObjectTableWithJoins that has the .joinName/.foreignKeyName (and falls back to SQLObjectTable attrs as w

Re: [SQLObject] basic RelatedJoin + select question

2008-03-10 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: > > On Mon, Mar 10, 2008 at 08:57:35AM -0700, Daniel Fetchinson wrote: > > On Mon, Mar 10, 2008 at 3:12 AM, Oleg Broytmann phd.pp.ru> wrote: > > > On Sun, Mar 09, 2008 at 08:52:28PM -0700, Daniel Fetchinson wrote: > > > > class zoo( SQLObject ): > > > > cag

Re: [SQLObject] Help on class design

2007-12-15 Thread Luke Opperman
> > No, RelatedJoin doesn't expose an API to do a join with the > > intermediate > > table. > > Ok, that what I thought. I'll do the join myself then. > > Thanks > -fred- However, you're certainly free to have both a RelatedJoin and a MultipleJoin, ie: class Mbox(SQLObject): ... msg_t

Re: [SQLObject] A SelectResults derived class to handle join queries

2007-08-03 Thread Luke Opperman
As with the general questions that come up around .select() and joins, the underlying issue is the expectation that "instances of a SQLObject-derived class are returned". So in your work here, the main bit is creating a fake class that is "enough" like a SQLObject. Also in trunk (views.py) is an a

Re: [SQLObject] Automatic expressions to allow for arbitrary orderBy clause

2007-07-25 Thread Luke Opperman
It's missing something, presumably you want to return the traversed FKs (or their .q expression) in addition to the classes found in the search (building the expressions as X.id == Y.id will not get the results intended, you want X.fkToYID == Y.id). I'd probably let .q handle more of the work in Bu

Re: [SQLObject] Anyone using RowCreatedSignal? (and RowDestroySignal?)

2007-04-18 Thread Luke Opperman
Alright, after professing my preference for post-Signal over post_funcs in the previously mentioned cases, I have to admit that for RowDestroySignal I need post_funcs behavior. For consistency then I'll propose the following changes: RowCreate, RowUpdate, and RowDestroy signals should all take a p

[SQLObject] Anyone using RowCreatedSignal?

2007-04-18 Thread Luke Opperman
Not RowCreateSignal (called before insert, allowing modification of kwargs) but RowCreatedSignal (called after insert). It is currently defined as (kwargs, post_funcs), but never calls post_funcs and would make a lot more sense to send the newly created instance. The docs suggest there may also be

Re: [SQLObject] Tagging model problems

2007-04-16 Thread Luke Opperman
Nick Murdoch locayta.com> writes: > I'm coming across difficulty while trying to find out which tags a user > has used for a particular page. At the moment I've had to resort to the > following code, but I'm sure this should be possible as a pure select() > statement or similar. > > # page an

Re: [SQLObject] sqlbulder, sresults, views - update

2007-03-28 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: > > #3 is also intended to fix the "TypeError:unhashable instance using > > sqlbuilder.Table" bug (SF#1642143) that was recently added > >Just yesterday I applied the patch > http://sourceforge.net/tracker/index.php?func=detail&aid=1673013&group_id=74338&atid

[SQLObject] sqlbulder, sresults, views - update

2007-03-28 Thread Luke Opperman
After some time away, a chance to cleanup my changes to SelectResults and SQLBuilder and submit them to all of you. Those changes fall into the following areas: 1. SelectResults use SQLBuilder Select queries. 2. SQLBuilder Select supports rest of SelectResults options (reversed, distinct, etc) 3.

Re: [SQLObject] SQLBuilder & Views

2007-02-20 Thread Luke Opperman
Johan Dahlin async.com.br> writes: > I wrote something similar a couple of weeks ago, I didn't submit it to > the mailing list because it was not in my opinion clean enough to be > submitted upstream. Indeed, I make no specific claims that my code is ready to be released into the wild yet. :) T

[SQLObject] SQLBuilder & Views

2007-02-19 Thread Luke Opperman
Ok, want to let you all in on something magical that made my weekend. This is an extension to my earlier thread on using SQLBuilder more consistently in SQLObject. On Saturday I expanded and refactored slightly on my last efforts, including cleaning up the reaching into DBConnection._SO_selectOne/

Re: [SQLObject] SelectResults / DBConnection.queryForSe lect using sqlbuilder.Select

2007-02-16 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: > > Hello! > > On Wed, Feb 14, 2007 at 10:11:34PM +, Luke Opperman wrote: > > Ok, put a slightly updated version on SF Patch #1653898 > >Wow! Though it is rather large it is a clever patch from a developer > with good u

Re: [SQLObject] SelectResults / DBConnection.queryForSele ct using sqlbuilder.Select

2007-02-14 Thread Luke Opperman
I meant SF #1660094, clearly. :) - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and ea

Re: [SQLObject] SelectResults / DBConnection.queryForSele ct using sqlbuilder.Select

2007-02-14 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: >IWB interesting to see the code. Ok, put a slightly updated version on SF Patch #1653898 The description there is pretty complete, the relevant changes for the Alias/Join part are below, but note the big caveat from the SF description: the db argument to

Re: [SQLObject] SelectResults / DBConnection.queryForSele ct using sqlbuilder.Select

2007-02-13 Thread Luke Opperman
Ok, two things today: 1. Preview implementation of just the "use sqlbuilder.Select for queryForSelect" part is in trac #291, but trac is now down. I've attached the patch (against svn r2158) to this message too. 2. Found a fun problem with sqlbuilder.SQLJoin. Since Alias's don't have a __sqlrepr_

Re: [SQLObject] SelectResults / DBConnection.queryForSele ct using sqlbuilder.Select

2007-02-12 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: >That would be hard to implement, I am afraid. Select() is (must be) much > more generic, supporting groupBy and many other features of SQL SELECT... Correct that Select by itself must be more generic, I wouldn't be opening up direct select() kw access to gr

Re: [SQLObject] SelectResults / DBConnection.queryForSele ct using sqlbuilder.Select

2007-02-12 Thread Luke Opperman
Oleg Broytmann phd.pp.ru> writes: > >I have a desire to do that, but not much time... Not swimming in time here, but this is looking like a promising approach to my current critical work. >Do you mean SelectResults.ops["orderBy"], ops["join"], ops["start"], > ops["end"], etc.? Indeed,

[SQLObject] SelectResults / DBConnection.queryForSelect using sqlbuilder.Select

2007-02-12 Thread Luke Opperman
Bringing this subject up again, had someone done some work on unifying these, in particular having SelectResults provide the fully constructed query to the DB layer in the form of a sqlbuilder.Select? My current desire is to be able to retrieve / replace the full query of a SelectResults, and to b

Re: [SQLObject] Managing explicit many to many relationships

2006-12-28 Thread Luke Opperman
Ben Sizer gmail.com> writes: > So, how would I implement queries like the following? > > # All User 1's skills where competence > 3 > SELECT * from User INNER JOIN Skill USING (user_id) INNER JOIN > Skilltype USING (stype_id) WHERE user_id = 1 AND Skilltype.competence > > 3 Well, note that SQLO

Re: [SQLObject] third column in a MultipleJoin table

2006-12-13 Thread Luke Opperman
> One thing I'm wondering: is there some source of documentation that I'm > missing? The filter() method doesn't seem to be described anywhere in the > official docs at http://www.sqlobject.org/SQLObject.html > > Dan Indeed, documentation on SelectResults is pretty sparse - http://www.sqlobject.o

Re: [SQLObject] third column in a MultipleJoin table

2006-12-13 Thread Luke Opperman
Depending on what you're actually trying to do, there's a few options. One, if you just want filtered results (like user.activeRoles), that's a simple filter on user.roles. If you really want to loop over all roles and get information from the intermediate table, you probably want both a SQLRelated

Re: [SQLObject] _idName

2006-12-08 Thread Luke Opperman
Completely untested, but what about: class A(SQLObject): class sqlmeta: idName = 'Ident' class A1(A): class sqlmeta(A.sqlmeta): table = 'TableA1' - Luke Quoting Robert <[EMAIL PROTECTED]>: > Hello, > > I have encountered a situation where I'd like to define a common

Re: [SQLObject] how can I migrate this idiom from django db to sqlobject?

2006-10-21 Thread Luke Opperman
Django is handling two pieces of the puzzle, only one of which is SQLObject a replacement for: database model, and admin UI. In Django presumably the "human-readable" descriptions are never in the database, so it functionally behaves like the EnumCol at the db level. Options for you seem to be a)

Re: [SQLObject] select(orderBy=(-Table.q.field)) bug

2006-10-13 Thread Luke Opperman
Yep, docs could be slightly clearer that the - works with the string and the reversed works in both cases. I'd also probably mention sqlbuilder.DESC, since it's the parallel to -. ''' With a string, you can use "-colname" to specify descending order, with a SQLBuilder (.q) field you can use DESC(T

Re: [SQLObject] order by sum and group by

2006-08-04 Thread Luke Opperman
Quoting Sean McBride <[EMAIL PROTECTED]>: > Number 2 sounds decent to me too, but I can see a potential problem: A > class that had a DerivedJoinSum on it (or another one of the derived > accumulators) would ALWAYS have to do the more complicated select > statement behind the scenes in order to ge

Re: [SQLObject] order by sum and group by

2006-08-04 Thread Luke Opperman
Quoting Rick Flosi <[EMAIL PROTECTED]>: > I think it might not exist b/c it isn't very SQLObjecty. > You'd be returning an object with a new field in it, SUM(), which isn't > part of the SQLObject and probably a subset of the SQLObject fields as > well. This isn't very OO which is what I think SQL

Re: [SQLObject] SelectResults internal

2006-08-01 Thread Luke Opperman
That restriction was based on the lack of synchronization of instance caches, applied in r1581 & a further fix in r1683. As I recall, those are both after 0.7. However, if you are *exclusively* using transactions (don't have a main plain connection whose instance cache matters), you can still use

Re: [SQLObject] SelectResults internal

2006-08-01 Thread Luke Opperman
> Then, a query for each getattr : > 1/QueryOne: SELECT thastate_id FROM validdata WHERE id = 78 > 1/QueryR : SELECT thastate_id FROM validdata WHERE id = 78 > 1/COMMIT : auto > 1/QueryOne: SELECT tsastate_id FROM validdata WHERE id = 78 > 1/QueryR : SELECT tsastate_id FROM validdata W

Re: [SQLObject] SQLBuilder and the 'in' statement

2006-07-24 Thread Luke Opperman
No, but there is the IN operator: Table.select(IN(Table.q.value, possibleValues)) - Luke Quoting Jonathon Anderson <[EMAIL PROTECTED]>: > > Is is possible to use the 'in' keyword with SQLBuilder/SQLObject? For > example: > > possibleValues = [1, 2, 3] > Table.select(Table.q.value in possibleVal

[SQLObject] Patch: Transaction.commit(close=True) fails to synchronize deletes

2006-07-18 Thread Luke Opperman
http://sourceforge.net/tracker/index.php?func=detail&aid=1524615&group_id=74338&atid=540674 With close=True, Transaction.commit() calls _makeObsolete before synchronizing the main connection cache - this resets Transaction._deletedCache, so objects deleted in the transaction are never expired. In

Re: [SQLObject] quirk, bug, or what?

2006-06-27 Thread Luke Opperman
Apologies, didn't see that you mentioned the SQLObject version. Anyways, tested with r1675 and same successful result as below. Quoting Luke Opperman <[EMAIL PROTECTED]>: > Going to need to know what that unhelpful exception message was, what version > of SQLObject, database

Re: [SQLObject] quirk, bug, or what?

2006-06-27 Thread Luke Opperman
Going to need to know what that unhelpful exception message was, what version of SQLObject, database, etc. Threw your code into a test file, using svn SQLObject, sqlite and postgres, and it works fine: [EMAIL PROTECTED]:~/code $ python2.4 -i test1.py >>> me >>> me.memberJID >>> - Luke Quoting

Re: [SQLObject] SQL'ish count versus len()

2006-06-27 Thread Luke Opperman
Forgot to copy the list before, gist was use SQL*Join instead, so that it uses a SelectResults instance. That's also the answer here: you can then use .count, .filter, .sum, etc on the join property. j.transactions.count() Quoting Michael Gauckler <[EMAIL PROTECTED]>: > Hi, > > thank your for t

Re: [SQLObject] pickling an SQLObject?

2006-06-09 Thread Luke Opperman
I don't recall whether getstate/setstate are necessary - i think so, just for the protocol. the key is overriding new/getnewargs. i also don't recall how generally applicable this is, regarding different connection schemes etc. ## Pickle protocol hacks def __new__(cls, *args, **kw):

Re: [SQLObject] Using SQLBuilder to create a queryAll custom query

2006-04-20 Thread Luke Opperman
sqlbuilder.Select looks like it's supposed to handle lists or tuples (although yes, by type-checking). And then in __sqlrepr__ it appears it is using things = self.items[:] Presumably this is intended a) to make a copy so that appending to things doesn't update self.items and b) to cast to a lis

Re: [SQLObject] RelatedJoin efficiency

2006-04-20 Thread Luke Opperman
You could use a SQLRelatedJoin, and then do: coll.members.count() - Luke Quoting Oleg Broytmann <[EMAIL PROTECTED]>: On Thu, Apr 20, 2006 at 03:54:18PM +0300, Max Ischenko wrote: Is there a way to use a COUNT(*) query in context like these? There is no currently. Oleg. -- Oleg Bro

[SQLObject] Patch: Bug1458595 delete in transaction does not use transaction connection

2006-04-04 Thread Luke Opperman
Patch [ 1464379 ] Alternate fix for Bug 1458595 (with test) http://sourceforge.net/tracker/index.php?func=detail&aid=1464379&group_id=74338&atid=540674 - Luke --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that

[SQLObject] SQLJoins do not respect sqlmeta._perConnection

2006-03-30 Thread Luke Opperman
Bug in SQLMultipleJoin and SQLRelatedJoin, the non-SQL versions check inst.sqlmeta._perConnection and load the joined objects using inst._connection, but the SQL versions never specify a connection. I won't have time to write a test for this patch till at least tomorrow or early next week, but fig

Re: [SQLObject] Re: Problem encapsulating sqlobject connections

2006-03-23 Thread Luke Opperman
In SQLObject, a class is a table, an instance is a row of that table. You appear to be confusing object initialization with class initialization - things in sqlmeta apply to how the class is defined, basically happens at import time. __init__ is not called until you try to create an instance of th

Re: [SQLObject] Transaction and cache in r1581

2006-02-08 Thread Luke Opperman
Quoting Justin Azoff <[EMAIL PROTECTED]>: The problem I was seeing was similar to this, but not the same. The stale values were not coming from sqlobject caching at all, but from the MVCC in postgresql... Using transactions for all reads will get around this problem, but the root cause is th

Re: [SQLObject] Transaction and cache in r1581

2006-02-08 Thread Luke Opperman
Quoting John Speno <[EMAIL PROTECTED]>: As all of our sqlobjects have 'cacheValues = False' set. Obviously, this didn't help the transaction problem before the fix, bu should the fix introduced in r1581 to cache.py fix our inconsistency problems? The fix in r1581 was originally written in ord