[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 4:17 PM, Ants Aasma wrote: >> really, the work to do here is 5% the patch to the in_() method, and >> 95% making me a really nice unit test suite that will generatively >> test IN for every contingencyincluding the bind param stuff in >> #476 (but simpler code than whats

[sqlalchemy] Re: weird ORACLE behaviour with limit/offset

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 3:43 PM, vkuznet wrote: > > Hi, > I added to my query the limit and offset (using ORACLE). To my > surprise results ARE varying if I'll print my select or not before > executing query. What I mean is the following > > sel = select () > #print sel > sel.execute() > > so, i

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread sdobrev
#476 - forget the visitor stuff; i use the simpler code that is in the text of "02/15/07 09:59:22 changed by svil" comment, for some 2 months now, and all is ok. i've added the patch/code to that ticket as well as to #474/475. On Friday 13 April 2007 23:17:37 Ants Aasma wrote: > On Apr 13, 10:

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Ants Aasma
On Apr 13, 10:16 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > OK, first thing i wasnt sure about, is CASE supported on every DB > that we support. I took a look at our CASE unit test and it appears > it applies to all DBs...(although i cant verify it passes on > firebird). Works on Firebird 1.

[sqlalchemy] Re: [PATCH] Filtered one_to_many relationships (Experimental)

2007-04-13 Thread sdobrev
> we arent writing to anything here, this is strictly a read-only > function. if you want to modify the collection, you create a real > relation() separately. the controversy was over should the > relation () and the generative loader be mixed (which I think they > should not, even though its sl

[sqlalchemy] weird ORACLE behaviour with limit/offset

2007-04-13 Thread vkuznet
Hi, I added to my query the limit and offset (using ORACLE). To my surprise results ARE varying if I'll print my select or not before executing query. What I mean is the following sel = select () #print sel sel.execute() so, if I will not print my select, I'll get *smaller* number of results

[sqlalchemy] Re: [PATCH] Filtered one_to_many relationships (Experimental)

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 3:10 PM, [EMAIL PROTECTED] wrote: >> >> then: >> >> m = session.query(MyClass).get(1) >> somechildren = m.children[3:5] >> someotherchildren = m.children.filter_by(foo='bar').filter_by >> (x==y).list() >> > hm, that seems like a way... more or less what i've done so far, on a

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 2:37 PM, Ants Aasma wrote: > > On Apr 13, 6:40 pm, "Rick" <[EMAIL PROTECTED]> wrote: >> Sorry, it looks like is already being discussed. (Serve me right for >> reading in threaded mode.) From my SA-newbie POV, I'd love it if >> col.in_() compiled down to false or 0 (whateve

[sqlalchemy] Re: [PATCH] Filtered one_to_many relationships (Experimental)

2007-04-13 Thread sdobrev
On Friday 13 April 2007 21:20:18 Michael Bayer wrote: > On Apr 13, 2007, at 12:51 PM, [EMAIL PROTECTED] wrote: > > haven't thought yet of where/how to hack this... > > i may have to abandon *-to-many-relations() alltogether, as i > > don't want/need them loaded - only filtered at view-time. > > or

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Ants Aasma
On Apr 13, 6:40 pm, "Rick" <[EMAIL PROTECTED]> wrote: > Sorry, it looks like is already being discussed. (Serve me right for > reading in threaded mode.) From my SA-newbie POV, I'd love it if > col.in_() compiled down to false or 0 (whatever works). col.in_() is easy to get working correctly, t

[sqlalchemy] Re: Multiple inheritance and Backrefs

2007-04-13 Thread percious
Figured it out on my own :-) You need the following for a mapper: ... properties = { ... 'forks':relation(Fork, secondary=UtensileTable, primaryjoin=PlaceSetting.c.id==UtensileTable.c.placeSettingID, secondaryjoin=UtensileTable.c.id==ForkTable.c.id,

[sqlalchemy] Re: count and distinct

2007-04-13 Thread Michael Bayer
you know i was going to say "hey we should add a distinct() function" but then i checked and its already there: select([func.count(table.c.column.distinct())]).execute() this method is actually on _CompareMixin and I should look into getting it into the generated docs somehow. also i think

[sqlalchemy] Re: [PATCH] Filtered one_to_many relationships (Experimental)

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 12:51 PM, [EMAIL PROTECTED] wrote: > haven't thought yet of where/how to hack this... > i may have to abandon *-to-many-relations() alltogether, as i don't > want/need them loaded - only filtered at view-time. > or can i make some super- (or sub-) relation thing (propertyLoade

[sqlalchemy] count and distinct

2007-04-13 Thread vkuznet
Hi, I found that if I do select([func.count(table.c.column)],distinct=True).execute() the resulting query is select distinct count(column) from table but it's not what I wanted. If my column has duplicates you got counting them, rather then count unique names. The proper SQL query would be sele

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 11:40 AM, Rick wrote: > > Sorry, it looks like is already being discussed. (Serve me right for > reading in threaded mode.) From my SA-newbie POV, I'd love it if > col.in_() compiled down to false or 0 (whatever works). sure...but I was just saying, i get much more antsy i

[sqlalchemy] Re: [PATCH] Filtered one_to_many relationships (Experimental)

2007-04-13 Thread sdobrev
i have some heretical thought about this... my context is: i have a many2many relation, which is always used as a one to many for one particular item; i.e. an additionaly filtered many2many by a runtime argument. e.g. imagine those users <-> addresses, but always used as "addresses for a parti

[sqlalchemy] Re: threading.currentThread().session = create_session() ??

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 10:49 AM, Arun Kumar PG wrote: > Hi All, > > I have a web application where I have multiple DAOs that may be > called during phases within a request. Since I want to make sure > that I get the same session with every DAO I was wondering if I can > add a runtime session

[sqlalchemy] Multiple inheritance and Backrefs

2007-04-13 Thread percious
I am trying to do something like this: PlaceSettingTable = Table("place_setting", metadata, Column('id', Integer, primary_key=True) ) UtensileTable = Table("utensile", metadata, Column('id', Integer, primary_key=True),

[sqlalchemy] Re: Many to many optimization

2007-04-13 Thread Michael Bayer
On Apr 12, 2007, at 11:38 PM, Kaali wrote: > > I actually tried to use query.instances, but it behaved quite oddly. I > didn't debug or even echo the SQL calls yet, but it made accessing > those instances very slow. The actual instances call was quick, but > when accessing the objects from the r

[sqlalchemy] Re: SELECT LIKE

2007-04-13 Thread King Simon-NFHD78
Disrupt07 wrote > > @Simon > Thanks. But what is ? Is it SQLAlchemy or pure SQL? > It is a Query object, as described here: http://www.sqlalchemy.org/docs/datamapping.html If you haven't read them yet, I'd recommend working through a tutorial - I found this one really helpful: http://ww

[sqlalchemy] Re: SELECT LIKE

2007-04-13 Thread Disrupt07
@Simon Thanks. But what is ? Is it SQLAlchemy or pure SQL? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group,

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Rick
Sorry, it looks like is already being discussed. (Serve me right for reading in threaded mode.) From my SA-newbie POV, I'd love it if col.in_() compiled down to false or 0 (whatever works). On Apr 13, 11:35 am, "Rick" <[EMAIL PROTECTED]> wrote: > Wouldn't the semantics of IN seem to imply that

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Rick
Wouldn't the semantics of IN seem to imply that the expression "foo IN ", should always evaluate to false? Clearly, "foo" is not in the empty set. I can't think of a use case where I'd use IN and want the expression "anything IN " to evaluate to True. I'm another user who would use column.in_(),

[sqlalchemy] Re: SELECT LIKE

2007-04-13 Thread King Simon-NFHD78
Disrupt07 wrote: > > I have a table storing users' info. > table: userinfo > columns: name, surname, age, location, ... > > I need to query this table using SQLAlchemy's ORM methods (e.g. > select(), select_by(), get_by()). The query should be like >SELECT * FROM userinfo WHERE name LIKE 'B

[sqlalchemy] SELECT LIKE

2007-04-13 Thread Disrupt07
I have a table storing users' info. table: userinfo columns: name, surname, age, location, ... I need to query this table using SQLAlchemy's ORM methods (e.g. select(), select_by(), get_by()). The query should be like SELECT * FROM userinfo WHERE name LIKE 'Ben%' ORDER BY name, age Which SQL

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Ants Aasma
On Apr 13, 1:47 pm, "Koen Bok" <[EMAIL PROTECTED]> wrote: > request_table = Table('request', metadata, > Column('id', Integer, primary_key=True), > Column('number', Integer, unique=True, nullable=True, > default=text('(SELECT coalesce(max(number), 0) + 1 FROM > req

[sqlalchemy] threading.currentThread().session = create_session() ??

2007-04-13 Thread Arun Kumar PG
Hi All, I have a web application where I have multiple DAOs that may be called during phases within a request. Since I want to make sure that I get the same session with every DAO I was wondering if I can add a runtime session attribute to the current thread returned Python's threading.currentThre

[sqlalchemy] Re: Child to parent - Uni-directional relationships - Is that supported ?

2007-04-13 Thread Arun Kumar PG
cool thx. On 4/13/07, svilen <[EMAIL PROTECTED]> wrote: > > > > > I have a Parent - Child (1:N) relationship between Class and Exam > > table. > > > > Class -> Exam > > 1 :N > > > > Now since a "Class" could have millions of "Exam" I don't want have > > an attribute on Class called exa

[sqlalchemy] Re: Child to parent - Uni-directional relationships - Is that supported ?

2007-04-13 Thread svilen
> I have a Parent - Child (1:N) relationship between Class and Exam > table. > > Class -> Exam > 1 :N > > Now since a "Class" could have millions of "Exam" I don't want have > an attribute on Class called exams. Instead I only want an > attribute on "Exam" to the parent "Class". > > C

[sqlalchemy] Child to parent - Uni-directional relationships - Is that supported ?

2007-04-13 Thread Arun Kumar PG
Hi Guys, I have a Parent - Child (1:N) relationship between Class and Exam table. Class -> Exam 1 :N Now since a "Class" could have millions of "Exam" I don't want have an attribute on Class called exams. Instead I only want an attribute on "Exam" to the parent "Class". Can we do th

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Koen Bok
request_table = Table('request', metadata, Column('id', Integer, primary_key=True), Column('number', Integer, unique=True, nullable=True, default=text('(SELECT coalesce(max(number), 0) + 1 FROM request)'))) This seems to work well. But is this a good way to do th

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Ants Aasma
On Apr 13, 12:23 pm, "Koen Bok" <[EMAIL PROTECTED]> wrote: > Ok, I'd rather handle it on the database level. Is that just a matter > of creating a function and calling it on insert? You need a sequence that has locks and rolls back on rollback. Simplest way is to use a table: CREATE TABLE sequenc

[sqlalchemy] Re: query().filter_by(boolean)

2007-04-13 Thread Marco Mariani
Michael Bayer wrote: > please file a ticket for this. done, #535 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Koen Bok
Ok, I'd rather handle it on the database level. Is that just a matter of creating a function and calling it on insert? Koen On Apr 13, 4:47 am, "Ants Aasma" <[EMAIL PROTECTED]> wrote: > On Apr 13, 2:47 am, Jorge Godoy <[EMAIL PROTECTED]> wrote: > > > IF you insist on doing that at your code, mak