[sqlalchemy] Re: r3695 causes strange error

2007-11-07 Thread Michael Bayer


On Nov 7, 2007, at 2:03 AM, [EMAIL PROTECTED] wrote:

 - something changed in the traversing (AbstractClauseProcessor -  
 r3727)
 and it does not find proper things...

ACP has been entirely rewritten.   if you can provide simple tests in  
the form that theyre present in test/sql/generative.py and/or test/sql/ 
selectable.py that would be helpful.  I have a feeling its not  
missing things, its just doing it slightly differently.


--~--~-~--~~~---~--~~
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: r3695 causes strange error

2007-11-06 Thread sdobrev

[EMAIL PROTECTED] wrote:
 sorry, here the files
   
and the line 83 ( marked XXX ) there must be =None to get the error.

--~--~-~--~~~---~--~~
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: r3695 causes strange error

2007-11-06 Thread Michael Bayer

ugh can you attach a zipfile please, they came out inline


On Nov 6, 2007, at 5:46 PM, [EMAIL PROTECTED] wrote:

 sorry, here the files

 hi.
 i have somewhat messy setup (~test case), about association with
 intermediate table/class, double pointing to one side and single
 pointing to another. i do set up both A-links in one item; and set up
 only first in another item, the other link (a2_link) is pre-set to  
 None.
 And, i have the error below since r3695.
 The error seems to disappear if i do not explicitly initiate the  
 a2_link
 to None - dont touch it or set to some object.
 Any idea what's wrong?
 ...
  File /home/az/src/dbcook/sqlalchemy/orm/sync.py, line 91, in  
 execute
rule.execute(source, dest, obj, child, clearkeys)
  File /home/az/src/dbcook/sqlalchemy/orm/sync.py, line 139, in  
 execute
raise exceptions.AssertionError(Dependency rule tried to blank- 
 out
 primary key column '%s' on instance '%s' % (str(self.dest_column),
 mapperutil.instance_str(dest)))
 sqlalchemy.exceptions.AssertionError: Dependency rule tried to  
 blank-out
 primary key column 'IntermediateAB.a2_link_id' on instance
 '[EMAIL PROTECTED]'



 
 from sa_gentestbase import *
 setup()
 Base.__repr__ = Base.__str__

 #===
 #PYTHONPATH=`pwd`/..:/home/az/src/hor-trunk python mapper/ 
 relation.py -v generate
 #config: db=, debug=, default_lazy=False, echo=False,  
 force_lazy=False, generate=True, log_sa=, lower_pu=True
 #= generated SA set-up

 t = Test_SA( 'setUp' )
 t.setUp()
 meta = t.meta

 table_A = Table( 'A', meta,
Column( 'name', String, ),
Column( 'db_id',   primary_key= True,   type_= Integer, ),
 )
 table_B = Table( 'B', meta,
Column( 'name', String, ),
Column( 'db_id',   primary_key= True,   type_= Integer, ),
 )
 table_IntermediateAB = Table( 'IntermediateAB', meta,
Column( 'color', String, ),
Column( 'a_link_id', Integer, ForeignKey( 'A.db_id', ),
 nullable= False,   primary_key= True, ),
Column( 'a2_link_id', Integer, ForeignKey( 'A.db_id', ),
 nullable= True,   primary_key= True, ),
Column( 'b_boza_id', Integer, ForeignKey( 'B.db_id', ),
 nullable= False,   primary_key= True, ),
 )

 meta.create_all()

 class A( Base):
props = ['db_id', 'name']
 class B( Base):
props = ['db_id', 'name']
 class IntermediateAB( Base):
props = ['db_id', 'color', 'a_link', 'a2_link', 'b_boza']

 mapper_A = mapper( A, table_A,)
 mapper_A.add_property( 'all_ab', relation( IntermediateAB,
#collection_class= bound method type._CollectionFactory  
 of class '__main__.IntermediateAB',
lazy= True,
primaryjoin= table_IntermediateAB.c.a_link_id ==  
 table_A.c.db_id,
remote_side= table_IntermediateAB.c.a_link_id,
uselist= True,
) )

 mapper_B = mapper( B, table_B,)

 mapper_IntermediateAB = mapper( IntermediateAB,  
 table_IntermediateAB, allow_null_pks=True)
 mapper_IntermediateAB.add_property( 'a_link', relation( A,
foreign_keys= table_IntermediateAB.c.a_link_id,
lazy= False,
primaryjoin= table_IntermediateAB.c.a_link_id ==  
 table_A.c.db_id,
remote_side= table_A.c.db_id,
uselist= False,
) )
 mapper_IntermediateAB.add_property( 'a2_link', relation( A,
foreign_keys= table_IntermediateAB.c.a2_link_id,
lazy= False,
primaryjoin= table_IntermediateAB.c.a2_link_id ==  
 table_A.c.db_id,
remote_side= table_A.c.db_id,
uselist= False,
) )
 mapper_IntermediateAB.add_property( 'b_boza', relation( B,
foreign_keys= table_IntermediateAB.c.b_boza_id,
lazy= False,
primaryjoin= table_IntermediateAB.c.b_boza_id ==  
 table_B.c.db_id,
remote_side= table_B.c.db_id,
uselist= False,
) )

 

 #

 a  = A( name= 'a1')
 a3 = A( name= 'a3')
 b1 = B( name= 'b1' )
 b2 = B( name= 'b2' )

 a.all_ab.append( IntermediateAB( b_boza= b1, color='green', a2_link  
 = a3) )
 a.all_ab.append( IntermediateAB( b_boza= b2, color='',
a2_link = a3   #XXX
 ) )

 print '', [i.b_boza for i in a.all_ab]

 s= create_session()
 for z in locals().values():
if isinstance( z, Base): s.save(z)
 s.flush()
 s.clear()

 for t in table_B, table_A, table_IntermediateAB:
print t,':', str( list( t.select().execute() ))

 s= create_session()
 aa = s.query( A ).filter_by(name='a1').first()
 print aa
 print 'xxx'
 l = [i.b_boza for i in aa.all_ab]
 print '', l
 assert len(l) ==2


 #expected output:
 # [B/id=None( name=b1 ), B/id=None( name=b2 )]
 #=== whole database:
 #class '__main__.B' : [(u'b1', 1), (u'b2', 2)]
 #class '__main__.A' : [(None, u'a3', 1), (None, u'a1', 2)]
 #class '__main__.IntermediateAB' : [(None, u'green', 2, 1, 1),  
 (None, u'', 2, None, 2)]
 #A/id=2( name=a1 )
 #xxx
 # [B/id=1( name=b1 ), B/id=2( name=b2 )]
 #$Id: 

[sqlalchemy] Re: r3695 causes strange error

2007-11-06 Thread Michael Bayer

nevermind, this one was pretty straightforward and r3695 didnt  
actually break things, it just revealed the lack of checking for  
things elsewhere, so works in r3747.

On Nov 6, 2007, at 5:50 PM, [EMAIL PROTECTED] wrote:


 [EMAIL PROTECTED] wrote:
 sorry, here the files

 and the line 83 ( marked XXX ) there must be =None to get the error.

 


--~--~-~--~~~---~--~~
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: r3695 causes strange error

2007-11-06 Thread sdobrev

Michael Bayer wrote:
 nevermind, this one was pretty straightforward and r3695 didnt  
 actually break things, it just revealed the lack of checking for  
 things elsewhere, so works in r3747.
   
yes, that works.
but now multiple other things broke. pf

 - the mapper.properties in its new get()/iterate() form is not 
available yet when mapper-extensions are setup (e.g. at 
ext.instrument_class). i need to find which attribute-name is being 
mapped to certain table.column... maybe i can get without it..

 - something changed in the traversing (AbstractClauseProcessor - r3727) 
and it does not find proper things...

 - r3735 - i started getting again these:
 File /home/az/src/dbcook/sqlalchemy/orm/util.py, line 261, in __getitem__
return self.row[key]
  File /home/az/src/dbcook/sqlalchemy/engine/base.py, line 1247, in 
__getitem__
return self.__parent._get_col(self.__row, key)
  File /home/az/src/dbcook/sqlalchemy/engine/base.py, line 1470, in 
_get_col
rec = self._key_cache[key]
  File /home/az/src/dbcook/sqlalchemy/util.py, line 72, in __missing__
self[key] = val = self.creator(key)
  File /home/az/src/dbcook/sqlalchemy/engine/base.py, line 1375, in 
lookup_key
raise exceptions.NoSuchColumnError(Could not locate column in row 
for column '%s' % (str(key)))
NoSuchColumnError: Could not locate column in row for column 'A_tbl.db_id'

details later.


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