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

2007-06-19 Thread klaus . barthelmann

This looks like a good solution. I'll need some time to provide a test
case, however.

If the change breaks existing code, how are cross-schema references
supposed to be handled?

Best regards
  Klaus

On 18 Jun., 21:54, Michael Bayer [EMAIL PROTECTED] wrote:
 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 schema from outside gets the table
  name without the schema part and thus locates the table in its own
  schema. I've appended a trivial fix below.

 im afraid this patch breaks several postgres reflection unit tests,
 since the schema attribute of Table is assumed to be of the default
 schema if not present.  by making it present here, it fails to locate
 tables within its own metadata.  i found when trying to create the
 test case for this issue it required explicitly stating the default
 schema name as the schema of the inside table.  that is also a bug.

 the patch that fixes the all issues for the test I was able to create
 is:

 Index: lib/sqlalchemy/schema.py
 ===
 --- lib/sqlalchemy/schema.py(revision 2742)
 +++ lib/sqlalchemy/schema.py(working copy)
 @@ -701,7 +701,7 @@
   raise exceptions.ArgumentError(Invalid foreign
 key column specification:  + self._colspec)
   if m.group(3) is None:
   (tname, colname) = m.group(1, 2)
 -schema = parenttable.schema
 +schema = None
   else:
   (schema,tname,colname) = m.group(1,2,3)
   table = Table(tname, parenttable.metadata,
 mustexist=True, schema=schema)

 meaning, if you say ForeignKey(sometable.somecolumn) for a
 particular Column, the schema is assumed to be the default
 schema, not the schema specified for the Table which contains the
 ForeignKey object.  this means creating a ForeignKey between two
 tables A and B, both with schema=myschema, would have to look like
 ForeignKey(myschema.a.somecol), even though both tables are in the
 same myschema schema.   Im OK with that but not sure how disruptive
 this change would be.

 if you can provide a test case illustrating your scenario (using
 Table/MetaData/Engine objects only; no elixir classes please), that
 would help greatly.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[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= 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 is created, its attributes should be inserted into several
  tables. Likewise, updates or deletes of objects should spread over
  several tables. For this to happen, I think I would need to hook
  into the ORM.

  Any ideas? I'm afraid that this is connected with the VIEWs on the
  sqlalchemy todo list.

  Best regards,
  Klaus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[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 more
 than one table.

 On 18 Jun., 13:00, svilen [EMAIL PROTECTED] wrote:

  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 is created, its attributes should be inserted into several
   tables. Likewise, updates or deletes of objects should spread over
   several tables. For this to happen, I think I would need to hook
   into the ORM.

   Any ideas? I'm afraid that this is connected with the VIEWs on the
   sqlalchemy todo list.

   Best regards,
   Klaus


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---