[sqlalchemy] Re: single table inheritance : query a subtype and its subtypes

2009-02-16 Thread GustaV
Oh my mistake. It works totally! On 13 fév, 21:29, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 13, 2009, at 12:05 PM, GustaV wrote: Hello! In a configuration looking like this: class Parent:   pass class Child(Parent):   pass class ChildChild(Child):   pass I

[sqlalchemy] single table inheritance : query a subtype and its subtypes

2009-02-13 Thread GustaV
( SQL : WHERE type IN (2) ), and I'd like to avoid to manually list the classes that inherit Child class. Thanks GustaV --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: autoflush during instanciation

2009-01-29 Thread GustaV
u'INSERT INTO parent (dumb) VALUES (?)' [None] which let me think the object was somehow added to the autoflush... I hope that will help to solve this. GustaV --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] autoflush during instanciation

2009-01-28 Thread GustaV
for NOT NULL column, etc. Is it a normal behavior? I though a Session.add() should be called explicitly to add the object to the session. Do the object shouldn't be added after the __init__ call anyway? Thanks a lot GustaV --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: autoflush during instanciation

2009-01-28 Thread GustaV
meta.Session = orm.scoped_session(sm) On 28 jan, 16:46, Michael Bayer zzz...@gmail.com wrote: On Jan 28, 10:45 am, GustaV buisson.guilla...@gmail.com wrote: Hi all, In the __init__ method of a mapper, the load of a relation may lead to an autoflush operation. When it happens, the object

[sqlalchemy] cascade delete-orphan

2009-01-15 Thread GustaV
= Parent() c = Child() assoc1 = Assoc(parent=p1, child=c) assoc2 = Assoc(parent=p2, child=c) p1.children = [ ] will lead to: - delete assoc1 (ok) - delete c (not ok) - update assoc2.c_id = null (not ok) So why is it not really a delete-orphan? :) Thanks GustaV

[sqlalchemy] Re: cascade delete-orphan

2009-01-15 Thread GustaV
and raising errors in 0.6. The conditions are, using delete-orphan without delete, and using delete-orphan with secondary. Neither is supported at this time. On Jan 15, 2009, at 11:30 AM, GustaV wrote: Hi all, I try to set up a many-to-many relation with an association object. But I want

[sqlalchemy] Re: cascade delete-orphan

2009-01-15 Thread GustaV
What is the best way to achieve the auto delete of the child then (refering to the example earlier)? I think about using an attribute extension... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] Circular Dependency on arbitrary foreign key and backref

2008-10-30 Thread GustaV
Hi everybody. I'm stuck in something bad: I use a relation with a arbitrary foreign key + backref (the reason is that I use single table inheritance, and the relation happen only on one of the subclasses, so I can't set the foreign key on the table...). But I get quickly a circular dependency!

[sqlalchemy] Re: child counting + delete

2008-10-27 Thread GustaV
that the Session stays in sync with what's currently in it. the CASCADE then occurs after this when SQLA deletes the parent row. On Oct 27, 2008, at 4:57 PM, GustaV wrote: The reason I ask that is that it is not really safe to use both DB cascades and SA delete management. The time comes

[sqlalchemy] child counting + delete

2008-10-22 Thread GustaV
Hi all! In a 1-N relation between a country and its regions, I'm using an attribute extension to update the current count of regions into countries. It works very well when I append or remove regions from country. But if I delete one of the region directly (session.delete(region)), the country

[sqlalchemy] Re: child counting + delete

2008-10-22 Thread GustaV
, 2008, at 2:05 PM, GustaV wrote: Hi all! In a 1-N relation between a country and its regions, I'm using an attribute extension to update the current count of regions into countries. It works very well when I append or remove regions from country. But if I delete one of the region

[sqlalchemy] InnoDB - Foreign Key must be an Index

2008-10-01 Thread GustaV
Hi all, I'm experiencing an issue on MySQL (5.0.51a) when sqlalchemy create the tables with foreign keys. The SQL issued : CREATE TABLE `referenced` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ) TYPE = InnoDB; CREATE TABLE `referencing` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `f`

[sqlalchemy] Re: InnoDB - Foreign Key must be an Index

2008-10-01 Thread GustaV
- I've just tried to execute your first example causing the error on my 5.0.45 mysql server and tables were created ok. Can you post the code snippet causing the error? Regards, Alex On 1 окт, 16:59, GustaV [EMAIL PROTECTED] wrote: Hi all, I'm experiencing an issue on MySQL (5.0.51a

[sqlalchemy] Re: Adjacency List + Alternate Join Conditions == ???

2008-09-14 Thread GustaV
): @property def neighbors(self): return object_session(self).query(Tile).filter(Tile.idself.id).all() have the possibility to query neighbors for many objects at a time. On Sep 12, 4:22 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 12, 2008, at 4:08 AM, GustaV wrote: The main

[sqlalchemy] declarative_base and UNIQUE Constraint

2008-09-14 Thread GustaV
How do I create a unique constraint with the declarative plugin (latest version 0.5) ? both: __table_args__ = ( UniqueConstraint('region.x', 'region.y'), {'mysql_engine':'InnoDB'} ) __table_args__ = ( UniqueConstraint(x, y), {'mysql_engine':'InnoDB'} ) don't work. Thanks!

[sqlalchemy] Re: Adjacency List + Alternate Join Conditions == ???

2008-09-12 Thread GustaV
. Eagerloading does that that's why I want relations... Maybe today that demand doesn't make any sense, but last time I used DB, it was much more efficient to issue 1 big request rather than 50 small ones. On Sep 11, 8:24 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 11, 2008, at 2:04 PM, GustaV wrote

[sqlalchemy] Re: Adjacency List + Alternate Join Conditions == ???

2008-09-11 Thread GustaV
even a flush! :) On Sep 10, 3:29 am, Michael Bayer [EMAIL PROTECTED] wrote: On Sep 9, 2008, at 7:27 PM, GustaV wrote: t4 = session.query(Tile).get(4) print t4.neighbors[0]._data will print None you have to adjust the other mapping appropriately: related_tiles = mapper(Tile, tile_alias

[sqlalchemy] Adjacency List + Alternate Join Conditions == ???

2008-09-09 Thread GustaV
Hello, I'm looking into something a bit tricky : having a relation between a table and itself (an adjacency list then) with a non-trivial join condition. Let's say for example, in the case of a Checkers game board for example, to query the neighboring tiles of a given tile. To do the query

[sqlalchemy] Re: Adjacency List + Alternate Join Conditions == ???

2008-09-09 Thread GustaV
= sessionmaker(bind=engine)() t1 = Tile(id=1) t2 = Tile(id=2) t3 = Tile(id=3) t4 = Tile(id=4) session.add_all([t1, t2, t3, t4]) session.commit() assert t2.neighbors == [t1] assert t4.neighbors == [t1, t2, t3] assert t1.neighbors == [] On Sep 9, 2008, at 4:50 PM, GustaV wrote: Hello

[sqlalchemy] Re: Extension Mapper

2008-08-30 Thread GustaV
' On 29 août, 18:32, Michael Bayer [EMAIL PROTECTED] wrote: in r5069, extension can be a list of SessionExtension objects. You can also append to session.extensions. On Aug 29, 2008, at 11:36 AM, GustaV wrote: You must be right. Of course, Turbogears2 already add an extension to the session

[sqlalchemy] Re: Extension Mapper

2008-08-30 Thread GustaV
set up for the *next* flush, use after_flush_postexec(). On Aug 30, 2008, at 10:08 AM, GustaV wrote: It almost works. A small problem though : when I get and modify instances (a priori not loaded before the flush) in after_flush method, they are correctly added in the dirty list

[sqlalchemy] Re: Extension Mapper

2008-08-29 Thread GustaV
better? On Aug 29, 3:57 am, Michael Bayer [EMAIL PROTECTED] wrote: On Aug 28, 2008, at 6:57 PM, GustaV wrote: Hi all. I'm currently working on a map (like in geography :) ) When a new tile in inserted in the DB, I'm using an extension mapper to update some neighbor's properties (like

[sqlalchemy] Extension Mapper

2008-08-28 Thread GustaV
Hi all. I'm currently working on a map (like in geography :) ) When a new tile in inserted in the DB, I'm using an extension mapper to update some neighbor's properties (like the neighbors count). The after_insert method helps a lot... but: When I modify another object than the one being

[sqlalchemy] Random result

2008-08-23 Thread GustaV
Hi all, Really, you do an amazing job on that stuff, it's a pleasure to work with! A short question though. It's possible to get a random order on selects in mysql using the RAND() in parameter of ORDER BY. I know similar (but different) was possible on others. What about sqlalchemy? The goal is

[sqlalchemy] Re: Random result

2008-08-23 Thread GustaV
, Michael Bayer [EMAIL PROTECTED] wrote: On Aug 23, 2008, at 12:10 PM, GustaV wrote: Hi all, Really, you do an amazing job on that stuff, it's a pleasure to work with! A short question though. It's possible to get a random order on selects in mysql using the RAND() in parameter of ORDER

[sqlalchemy] Listening append() and remove()

2008-08-21 Thread GustaV
Hi all! I'm looking for an easy way to get informed when someone append or remove an object from a specific one-to-many relation. For example to keep a count on the parent object, with no need to query the children. There are a lot of stuff about it, but I'm not sure how to do it really: - 1st :