[sqlalchemy] delete cascade at execution time

2009-01-26 Thread Jonathon Anderson

Is there a way to specify cascading at query execution time, like

 Session.delete(instance, cascade=all, delete-orphan)

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Session.merge changing related objects?

2008-12-12 Thread Jonathon Anderson

I am experiencing strange behavior in with Session.merge in 0.5.0rc4,
where a flush cause merged objects on related entities to change
object identity. I think this is a bug, but I might be missing
something about Session.merge. (I've never used it before.)

My test case can be viewed on pastebin at http://pastebin.com/m72d6885b
(only TestMerge.test_merge_bug should fail).


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] problem selecting sql aggregate data

2008-10-15 Thread Jonathon Anderson

I keep getting an exception deep within sqlalchemy whenever I try to
select a bit of aggregate data using the Session (I'm using SA
0.5.0rc2). For now, assume that my metadata/mappers are sensible,
because I can't get over the thought that I'm just doing something
simple wrong with the query, but if there's nothing obviously wrong
here, I'll post mappers, etc

Python 2.4.2 (#1, Apr 13 2007, 16:09:19)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type help, copyright, credits or license for more information.
 from clusterbank.model import *
 from sqlalchemy import func
 Session.query(Project).all()[0]
Project name='systems' id=1L
 Session.query(Project).join(Project.allocations, 
 Allocation.charges).all()[0]
Project name='earlytesting' id=485L
 Session.query(Project, func.count(Charge)).join(Project.allocations, 
 Allocation.charges).group_by(Charge.id).all()
Traceback (most recent call last):
  File stdin, line 1, in ?
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/orm/query.py, line 1019, in first
ret = list(self[0:1])
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/orm/query.py, line 944, in __getitem__
return list(res)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/orm/query.py, line 1078, in __iter__
return self._execute_and_instances(context)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/orm/query.py, line 1081, in _execute_and_instances
result = self.session.execute(querycontext.statement,
params=self._params, mapper=self._mapper_zero_or_none(),
_state=self._refresh_state)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/orm/session.py, line 749, in execute
return self.__connection(engine, close_with_result=True).execute(
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/engine/base.py, line 848, in execute
return Connection.executors[c](self, object, multiparams, params)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/engine/base.py, line 899, in execute_clauseelement
return self._execute_compiled(elem.compile(dialect=self.dialect,
column_keys=keys, inline=len(params)  1), distilled_params=params)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/engine/base.py, line 908, in _execute_compiled
context = self.__create_execution_context(compiled=compiled,
parameters=distilled_params)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/engine/base.py, line 952, in __create_execution_context
return
self.engine.dialect.create_execution_context(connection=self,
**kwargs)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/databases/mysql.py, line 1532, in create_execution_context
return MySQLExecutionContext(self, connection, **kwargs)
  File /gpfs/home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/engine/default.py, line 167, in __init__
self.compiled_parameters = [compiled.construct_params(m) for m in
parameters]
  File /home/janderso/lib/python/SQLAlchemy-0.5.0rc2-py2.4.egg/
sqlalchemy/sql/compiler.py, line 211, in construct_params
pd[self.bind_names[bindparam]] = bindparam.value()
TypeError: __init__() takes exactly 3 arguments (1 given)


--~--~-~--~~~---~--~~
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: problem selecting sql aggregate data

2008-10-15 Thread Jonathon Anderson

 this would imply you're sending a class into a filter() expression or
 something similar (such as, MyClass.foo==SomeOtherClass).

I didn't understand at first, because the query in question

 Session.query(Project, func.count(Charge)).join(Project.allocations, 
 Allocation.charges).group_by(Charge.id).all()

has no filter() argument. But looking at the partial sql generated by
the above query revealed the only bind parameter:

 print Session.query(Project, func.count(Charge)).join(Project.allocations, 
 Allocation.charges).group_by(Charge.id)
SELECT projects.id AS projects_id, count(?) AS count_1
FROM projects JOIN allocations ON projects.id = allocations.project_id
JOIN charges ON allocations.id = charges.allocation_id GROUP BY
charges.id

It seems that func does not understand taking arguments of mapped
python objects. I don't even know that it should. In any case, using
an actual property/attribute/column fixed the problem:

 print Session.query(Project, 
 func.count(Charge.id)).join(Project.allocations, 
 Allocation.charges).group_by(Charge.id)
SELECT projects.id AS projects_id, count(charges.id) AS count_1
FROM projects JOIN allocations ON projects.id = allocations.project_id
JOIN charges ON allocations.id = charges.allocation_id GROUP BY
charges.id
 Session.query(Project, func.count(Charge.id)).join(Project.allocations, 
 Allocation.charges).group_by(Charge.id).all()
[]

Thank you for helping me find my (eventually obvious) problem.

On Oct 15, 8:19 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Oct 15, 2008, at 6:19 PM, Jonathon Anderson wrote:



  I keep getting an exception deep within sqlalchemy whenever I try to
  select a bit of aggregate data using the Session (I'm using SA
  0.5.0rc2). For now, assume that my metadata/mappers are sensible,
  because I can't get over the thought that I'm just doing something
  simple wrong with the query, but if there's nothing obviously wrong
  here, I'll post mappers, etc

 its interpreting a bind parameter as a callable unit and attempting to  
 call it.    Additionally the callable seems to be an uninstantiated  
 class.   The trace is occuring as you attempt to execute a Query.  So  
 this would imply you're sending a class into a filter() expression or  
 something similar (such as, MyClass.foo==SomeOtherClass).
--~--~-~--~~~---~--~~
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: integrity error not raised for null column

2008-02-15 Thread Jonathon Anderson

I'm trying to track down whose code is responsible for this problem.
Your example (and I suppose sqlalchemy) use an sqlite3 module, which
seems to only exist within the python source tree. upgrading pysqlite
from initd.org gives me a pysqlite2 module. (Using the
pysqlite2.dbapi2 module does not seem to carry the same error.)

So the bug seems present only in the python 2.5 sqlite3 module. What
next?

~jon

On Feb 15, 10:14 am, Michael Schlenker [EMAIL PROTECTED] wrote:
 Michael Bayer schrieb: no idea.  below is a revised version, where the main 
 revision is that  
  theres no SQLAlchemy ;).  So I think you should submit this to the bug  
  tracker onwww.sqlite.org.

  Actually this is sorta interesting since it would impact our own unit  
  tests regarding sqlite as well (which is why we run them with mysql  
  and postgres as part of our build as well).

 This is a known misfeature of sqlite..., its even documented in the CREATE
 TABLE manpage for sqlite.

 Michael

 --
 Michael Schlenker
 Software Engineer

 CONTACT Software GmbH           Tel.:   +49 (421) 20153-80
 Wiener Straße 1-3               Fax:    +49 (421) 20153-41
 28359 Bremenhttp://www.contact.de/         E-Mail: [EMAIL PROTECTED]

 Sitz der Gesellschaft: Bremen
 Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
 Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
--~--~-~--~~~---~--~~
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: integrity error not raised for null column

2008-02-15 Thread Jonathon Anderson

I think I understand the relationship between pysqlite2 and sqlite3
(the second being a stdlib snapshot of the first) and have found the
code in sqlalchemy that will use pysqlite2, if present, over sqlite3,
so having installed the latest version of pysqlite2, I should be fine.

Any idea why the library name changed? I think that's confusing me
more than anything.

I assume the stdlib sqlite module will be upgraded at Python 2.6?

~jon

On Feb 15, 2:03 pm, Jonathon Anderson [EMAIL PROTECTED] wrote:
 I'm trying to track down whose code is responsible for this problem.
 Your example (and I suppose sqlalchemy) use an sqlite3 module, which
 seems to only exist within the python source tree. upgrading pysqlite
 from initd.org gives me a pysqlite2 module. (Using the
 pysqlite2.dbapi2 module does not seem to carry the same error.)

 So the bug seems present only in the python 2.5 sqlite3 module. What
 next?

 ~jon

 On Feb 15, 10:14 am, Michael Schlenker [EMAIL PROTECTED] wrote:

  Michael Bayer schrieb: no idea.  below is a revised version, where the 
  main revision is that  
   theres no SQLAlchemy ;).  So I think you should submit this to the bug  
   tracker onwww.sqlite.org.

   Actually this is sorta interesting since it would impact our own unit  
   tests regarding sqlite as well (which is why we run them with mysql  
   and postgres as part of our build as well).

  This is a known misfeature of sqlite..., its even documented in the CREATE
  TABLE manpage for sqlite.

  Michael

  --
  Michael Schlenker
  Software Engineer

  CONTACT Software GmbH           Tel.:   +49 (421) 20153-80
  Wiener Straße 1-3               Fax:    +49 (421) 20153-41
  28359 Bremenhttp://www.contact.de/        E-Mail: [EMAIL PROTECTED]

  Sitz der Gesellschaft: Bremen
  Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
  Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
--~--~-~--~~~---~--~~
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] expunge vs clear

2008-02-02 Thread Jonathon Anderson

I'm using an orm configuration with a sessionmaker().mapper doing the
mapping between my classes and my metadata.

The documentation says that doing a Session.clear() should do the
equivalent of a Session.expunge(inst) for all instances attached to
the session.

I have one instance attached to the session, and do a Session.clear();
but if I then re-query to get that instance, I get

InvalidRequestError: Could not update instance '[EMAIL PROTECTED]',
identity key (class 'cobalt.model.base.Job', ('localhost', 0),
None); a different instance with the same identity key already exists
in this session.

If I replace the Session.close() with a Session.expunge(inst), the
error goes away.

Any ideas?

~jon


--~--~-~--~~~---~--~~
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] defining a StringSet type

2008-01-23 Thread Jonathon Anderson

I'm trying to use types.TypeDecorator to define a set of strings
stored in the database as a csv list, where the empty set is stored as
null. process_bind_param seems to work, as values set on the bound
field seem to get entered correctly; but process_result_value never
seems to be called when reading that field, or when loading an
instance from the database.

What am I doing wrong? (I'm using 0.4.2p3)

class StringSet (types.TypeDecorator):

A type that receives an iterable of strings, and returns a set
of those strings.

Stored in the database as a csv list of strings.


impl = types.String

def process_bind_param (self, value, engine):
if not value:
return None
else:
return ,.join(set(value))

def process_result_value (self, value, engine):
if not value:
return set()
else:
return set(value.split(,))

def copy (self):
return StringSet(self.impl.length)



--~--~-~--~~~---~--~~
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: defining a StringSet type

2008-01-23 Thread Jonathon Anderson

What do you mean by textual strings? Do you mean strings backed by a
TEXT type, rather than a fixed-length string?

Why won't that work?

On Jan 23, 10:57 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jan 23, 2008, at 11:09 AM, Jonathon Anderson wrote:



  I'm trying to use types.TypeDecorator to define a set of strings
  stored in the database as a csv list, where the empty set is stored as
  null. process_bind_param seems to work, as values set on the bound
  field seem to get entered correctly; but process_result_value never
  seems to be called when reading that field, or when loading an
  instance from the database.

  What am I doing wrong? (I'm using 0.4.2p3)

 would have to see how you're getting results from the database.  if  
 you are using textual strings, it wont work.
--~--~-~--~~~---~--~~
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: defining a StringSet type

2008-01-23 Thread Jonathon Anderson

Oh, no. I'm not doing any raw sql.

I have (at a most basic level):

things_table = Table(things, metadata,
Column(id, types.Integer, primary_key=True),
Column(values, StringSet, nullable=True),
)

class Thing (object):
pass

Session.mapper(Thing, things_table)

But when I do Thing.query.all()[0].values, process_result_value is
never called.

~jon

On Jan 23, 2:11 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jan 23, 2008, at 3:01 PM, Jonathon Anderson wrote:



  What do you mean by textual strings? Do you mean strings backed by a
  TEXT type, rather than a fixed-length string?

  Why won't that work?

 no, i mean:

 result = engine.execute(select * from table)

 will not work with any TypeEngine or TypeDecorators in place.

 as opposed to :

 result = engine.execute(table.select())

 which *will* work with all the types in place.
--~--~-~--~~~---~--~~
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: defining a StringSet type

2008-01-23 Thread Jonathon Anderson

So, in constructing my test case, I figured out what was going on.
(I'm sure this is often the case.)

http://pastebin.com/m612561a6

The problem is that process_result_value is only called when actually
loading values from the database, and since a session maintains an
object cache for object identity persistence, it it doesn't update the
instance value.

Is there some way to get the behavior I want in
test_values_sameinstance without closing/clearing the session, or
duplicating my logic in a python property?

~jon

On Jan 23, 3:31 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jan 23, 2008, at 4:25 PM, Jonathon Anderson wrote:





  Oh, no. I'm not doing any raw sql.

  I have (at a most basic level):

  things_table = Table(things, metadata,
     Column(id, types.Integer, primary_key=True),
     Column(values, StringSet, nullable=True),
  )

  class Thing (object):
     pass

  Session.mapper(Thing, things_table)

  But when I do Thing.query.all()[0].values, process_result_value is
  never called.

 unit tests pass on this end, can you provide a full test case  
 illustrating the issue ?
--~--~-~--~~~---~--~~
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: defining a StringSet type

2008-01-23 Thread Jonathon Anderson

I understand that solution. I did say without a python property.

But if that's the only real way to do it, so be it. Maybe I was just
looking for an excuse to learn how to define a custom type. ;)

~jon

On Jan 23, 9:56 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jan 23, 2008, at 10:16 PM, Jonathon Anderson wrote:



  So, in constructing my test case, I figured out what was going on.
  (I'm sure this is often the case.)

 http://pastebin.com/m612561a6

  The problem is that process_result_value is only called when actually
  loading values from the database, and since a session maintains an
  object cache for object identity persistence, it it doesn't update the
  instance value.

  Is there some way to get the behavior I want in
  test_values_sameinstance without closing/clearing the session, or
  duplicating my logic in a python property?

 sure the python property version is illustrated here:

 http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_...

 depending on what youre doing this may remove the need to have a  
 custom column type.
--~--~-~--~~~---~--~~
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] sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson

I'm seeing (seemingly random) instances of sqlalchemy not returning an
object for a relation. It seems to think that the relation_id
column is None.

The code in question is available at
http://trac.mcs.anl.gov/projects/clusterbank/browser/trunk/source/packages/clusterbank/model

Thanks in advance.

~jonathon

Python 2.4.2 (#1, Apr 13 2007, 16:09:19)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type help, copyright, credits or license for more information.
 from clusterbank.model import *
 Allocation.query.all()[0].resource_id
2007-11-30 14:07:43,495 INFO sqlalchemy.engine.base.Engine.0x..70
SELECT allocations.comment AS allocations_comment,
allocations.datetime AS allocations_datetime, allocations.start AS
allocations_start, allocations.expiration AS allocations_expiration,
allocations.amount AS allocations_amount, allocations.id AS
allocations_id, allocations.project_id AS allocations_project_id,
allocations.resource_id AS allocations_resource_id
FROM allocations ORDER BY allocations.id
2007-11-30 14:07:43,496 INFO sqlalchemy.engine.base.Engine.0x..70 []
3L
 Allocation.query.all()[0].resource
2007-11-30 14:07:14,310 INFO sqlalchemy.engine.base.Engine.0x..70
SELECT allocations.comment AS allocations_comment,
allocations.datetime AS allocations_datetime, allocations.start AS
allocations_start, allocations.expiration AS allocations_expiration,
allocations.amount AS allocations_amount, allocations.id AS
allocations_id, allocations.project_id AS allocations_project_id,
allocations.resource_id AS allocations_resource_id
FROM allocations ORDER BY allocations.id
2007-11-30 14:07:14,310 INFO sqlalchemy.engine.base.Engine.0x..70 []
2007-11-30 14:07:14,317 INFO sqlalchemy.engine.base.Engine.0x..70
SELECT resources.id AS resources_id
FROM resources
WHERE resources.id = %s ORDER BY resources.id
2007-11-30 14:07:14,317 INFO sqlalchemy.engine.base.Engine.0x..70
[None]

--~--~-~--~~~---~--~~
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: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson

Yep, it seems that this was just 0.4.0 getting confused about my
redundant relationships. It's working now.

Thanks for actually looking at my code.

On Nov 30, 4:36 pm, Jonathon Anderson [EMAIL PROTECTED] wrote:
 I just updated to sqlalchemy 0.4.1, and see the error. I'll remove the
 duplicate relations, and see if that clears this up.

 On Nov 30, 4:30 pm, Michael Bayer [EMAIL PROTECTED] wrote:

  On Nov 30, 5:18 pm, Jonathon Anderson [EMAIL PROTECTED] wrote:

   I'm on SA 0.4.0

   I was under the impression that you had to declare the relationship
   from both sides, and that backref was only used to update related
   objects when one side of the relation was changed. Can you point me to
   some docs for this?

  we have some tutorial docs 
  athttp://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_relati...

  the most specific M2M example is in the mapper config 
  docs:http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relatio...

  and the generated docstrings for relation() also have some info on
  it:  
  http://www.sqlalchemy.org/docs/04/sqlalchemy_orm.html#docstrings_sqla...

  but also, using 0.4.1 the config you had should raise an error which
  is also a form of documentation.

  it probably wouldn't hurt to add a very explicit Backreferences
  section to the mapper docs.
--~--~-~--~~~---~--~~
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: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson

I just updated to sqlalchemy 0.4.1, and see the error. I'll remove the
duplicate relations, and see if that clears this up.

On Nov 30, 4:30 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Nov 30, 5:18 pm, Jonathon Anderson [EMAIL PROTECTED] wrote:

  I'm on SA 0.4.0

  I was under the impression that you had to declare the relationship
  from both sides, and that backref was only used to update related
  objects when one side of the relation was changed. Can you point me to
  some docs for this?

 we have some tutorial docs 
 athttp://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_relati...

 the most specific M2M example is in the mapper config 
 docs:http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relatio...

 and the generated docstrings for relation() also have some info on
 it:  http://www.sqlalchemy.org/docs/04/sqlalchemy_orm.html#docstrings_sqla...

 but also, using 0.4.1 the config you had should raise an error which
 is also a form of documentation.

 it probably wouldn't hurt to add a very explicit Backreferences
 section to the mapper docs.
--~--~-~--~~~---~--~~
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: sqlalchemy not loading instances for relations (MySQL)

2007-11-30 Thread Jonathon Anderson

I'm on SA 0.4.0

I was under the impression that you had to declare the relationship
from both sides, and that backref was only used to update related
objects when one side of the relation was changed. Can you point me to
some docs for this?

~jon

On Nov 30, 3:26 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Nov 30, 2007, at 3:26 PM, Jonathon Anderson wrote:



  I'm seeing (seemingly random) instances of sqlalchemy not returning an
  object for a relation. It seems to think that the relation_id
  column is None.

  The code in question is available at
 http://trac.mcs.anl.gov/projects/clusterbank/browser/trunk/source/pac...

  Thanks in advance.

 from a cursory view, theres not much I can see wrong with the code,  
 although I see that you are declaring redundant relationships such as:

 allocations = relation(Allocation,  
 secondary=requests_allocations_table, backref=requests),
 requests = relation(Request, secondary=requests_allocations_table,  
 backref=allocations),

 so you are in fact creating two requests relations as well as two  
 allocations relations.  im not sure what version you're using but if  
 you're on SA 0.4.1 it should be raising an error when you do that.
--~--~-~--~~~---~--~~
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: a renaming proposal

2007-07-27 Thread Jonathon Anderson

What popular misunderstanding would that be?

I have no problem with any of the terminology from S/A. It all seems
unambiguous, and makes sense.

Of course, I also studied database theory, relational algebra, and
relational calculus at university.

~jon

On Jul 27, 5:29 am, avdd [EMAIL PROTECTED] wrote:
 On Jul 27, 9:45 am, jason kirtland [EMAIL PROTECTED] wrote:

  This is the last opportunity
  for terminology changes for a while, so I offer this up for discussion.

 Does anyone else think orm.relation is wrong?  Perhaps
 relationship if you must have a noun, or relates_to, etc, but
 relation could cement the popular misunderstanding of relational
 database.

 a.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---