[sqlalchemy] Re: How to map a Selectable such that objects can be created/inserted, updated, and deleted?

2007-06-18 Thread svilen
mapper() has a selectable= argument, go read about it. it can do just about anything u fancy. Is there a way to create object mappers with bean managed persistence, as the Java folks would call it? What I would like to do is to map a class to a Selectable such as a join. Now when an object

[sqlalchemy] Re: How to map a Selectable such that objects can be created/inserted, updated, and deleted?

2007-06-18 Thread klaus . barthelmann
Sorry but I don't see how the select_table parameter (used in inheritance hierarchies) relates to my question. Selecting things from a Selectable is not much of a problem, for example, and I need more than one table. On 18 Jun., 13:00, svilen [EMAIL PROTECTED] wrote: mapper() has a selectable=

[sqlalchemy] Re: How to map a Selectable such that objects can be created/inserted, updated, and deleted?

2007-06-18 Thread klaus . barthelmann
The MapperExtension might be what I need, however. On 18 Jun., 13:48, [EMAIL PROTECTED] wrote: Sorry but I don't see how the select_table parameter (used in inheritance hierarchies) relates to my question. Selecting things from a Selectable is not much of a problem, for example, and I need

[sqlalchemy] in_ operator as kwarg to filter_by

2007-06-18 Thread David S.
I know that you can: my_query.select_by(my_source.c.code.in_('1', '2')) Is there a way to use kwargs with in_ as you can with equality settings, as in: my_query.select_by(code='1') Since SA is NOT a framework, I imagine I could wrap the filter_by method to work out Django style kwargs like

[sqlalchemy] Problem when applying max_identifier_length

2007-06-18 Thread Cory Johns
Since upgrading to 0.3.8 (from 0.3.6), I've run in to a problem with long identifiers. It seems that _truncate_bindparam is being applied to both parts of the ClauseElements (that is, the parts both before and after the AS), and is testing = (instead of ) max_identifier_length, so that when I

[sqlalchemy] Re: dictionaries collection_class

2007-06-18 Thread Ron
Ok, I applied that change to the version I'm using (0.3.8). That fixed it. But I think I stumbled on another bug/inconcistancy. If I tried to str/repr obj.attr it failed. I looked around the code and this fix seemed to work, but I'm not sure if it fits in with how the class is intended to

[sqlalchemy] Re: dictionaries collection_class

2007-06-18 Thread jason kirtland
Ron wrote: Ok, I applied that change to the version I'm using (0.3.8). That fixed it. But I think I stumbled on another bug/inconcistancy. If I tried to str/repr obj.attr it failed. [...] Does that make sense? Or is the problem deeper in the code? It seems to go along with what you

[sqlalchemy] Re: How to map a Selectable such that objects can be created/inserted, updated, and deleted?

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 4:13 AM, [EMAIL PROTECTED] wrote: Is there a way to create object mappers with bean managed persistence, as the Java folks would call it? What I would like to do is to map a class to a Selectable such as a join. Now when an object is created, its attributes should be

[sqlalchemy] Re: How to map a Selectable such that objects can be created/inserted, updated, and deleted?

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 7:00 AM, svilen wrote: mapper() has a selectable= argument, go read about it. it can do just about anything u fancy. select_table is only used for polymorphic inheritance situations such that a mapper's select operations occur via a different selectable than that

[sqlalchemy] Re: in_ operator as kwarg to filter_by

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 11:47 AM, David S. wrote: I know that you can: my_query.select_by(my_source.c.code.in_('1', '2')) Is there a way to use kwargs with in_ as you can with equality settings, as in: my_query.select_by(code='1') Since SA is NOT a framework, I imagine I could wrap the

[sqlalchemy] Re: Problem when applying max_identifier_length

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 11:57 AM, Cory Johns wrote: Since upgrading to 0.3.8 (from 0.3.6), I've run in to a problem with long identifiers. It seems that _truncate_bindparam is being applied to both parts of the ClauseElements (that is, the parts both before and after the AS), and is

[sqlalchemy] Re: documentation unsearchable

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 2:30 PM, gardsted wrote: If I were to suggest something it would be a two-toc approach - a toc for python-programmers and one for sql-programmers. SQLAlchemy would like you to assume both roles. I see a lot of people blogging about ORMs are good because you dont

[sqlalchemy] Mapper with relation/custom join condition fails

2007-06-18 Thread Christoph Haas
Dear list... I'm having trouble with two assign-mappers with a custom JOIN condition. (And I admit that I'm not yet good at that in SQLAlchemy. So be gentle.) powerdns_records_table = Table( 'records', meta, Column('id', Integer, primary_key=True), Column('name', Unicode(80)),

[sqlalchemy] Re: postgresql: need schema-qualified foreign keys

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 4:25 AM, [EMAIL PROTECTED] wrote: In my first experiments with elixir I noticed that sqlalchemy doesn't handle foreign keys correctly on autoloaded tables. This has to to with schema handling in the postgresql driver. A foreign key referencing a table in the public

[sqlalchemy] Re: Mapper with relation/custom join condition fails

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 3:34 PM, Christoph Haas wrote: Yes, this may look a bit dirty. The JOIN condition is really that and I have no chance to alter the table schemas because that's what another application demands. The powerdns_records_table uses a string and dhcp_hosts_table uses a

[sqlalchemy] Re: in_ operator as kwarg to filter_by

2007-06-18 Thread David S.
django's method of shoving SQL operators into the names of keyword arguments seems horribly ugly to me. SQLAlchemy's approach is to use query.filter(sometable.c.col.in_(x, y)). it uses the same operators as everything else without the need to memorize magic codes to embed in keyword

[sqlalchemy] a couple of newbie questions: 'not exists' with reference to selected row

2007-06-18 Thread gardsted
Dear List. How do I do this more ormish? The statement is supposed to find the latest messages which havent yet been answered by 123456, assuming a later message is an answer;-) def play4(): print ### play4 # engine=create_engine(dburi)

[sqlalchemy] Re: Mapper with relation/custom join condition fails

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 3:34 PM, Christoph Haas wrote: assign_mapper(session_context, DhcpHost, dhcp_hosts_table) assign_mapper(session_context, DnsRecord, powerdns_records_table, properties={ 'dhcphost': relation(DhcpHost, primaryjoin=(cast

[sqlalchemy] Re: a couple of newbie questions: 'not exists' with reference to selected row

2007-06-18 Thread Michael Bayer
On Jun 18, 2007, at 4:52 PM, gardsted wrote: Dear List. How do I do this more ormish? The statement is supposed to find the latest messages which havent yet been answered by 123456, assuming a later message is an answer;-) def play4(): print ### play4 #

[sqlalchemy] Re: a couple of newbie questions: 'not exists' with reference to selected row

2007-06-18 Thread gardsted
Fantastic: and now i don't need the join to the persons table anymore - it stays hidden inside the message object, so i can just ask for sender.name or whatever i want - that's nice - If I have the objects, i can delegate the use of them to others, maybe leading to higher level of reuse (= less