[sqlalchemy] Re: polymorphic mapping with more than 2 level of inheritance

2007-01-30 Thread sdobrev
Here one more random pick, of same errors.
There are only these 3 kinds of errors in the whole run, lazy+eager, 
about 9800 cases, and about 4700 errors (also attached): 
 - some B being loaded as C /4500
 - sqlError- no such column pu_B.linkB_id /224
 - circularDep /42
The first one plays tricks, sometimes it happens, sometimes does not - 
there are ~7000 errors while using the sawrapper, but then only 4500 
off the generated src-testcases.

In postgres, all that is not circ-dep becomes the no-such-column 
error. So probably that's something to check first.

ciao
svil

All testfiles and latest sawrap+tests is at 
http://linuxteam.sistechnology.com/o2rm/all-ABC-noeager.tbz
http://linuxteam.sistechnology.com/o2rm/sawrap0130.tar.bz2
Run as
sawrap/tests $ PYTHONPATH=.. python test_ABC_inh_ref_all.py dummy doC
play with the options (-h) until u decide what u want, then remove 
the 'dummy' arg.
e.g. PYTHONPATH=.. python test_ABC_inh_ref_all.py doC eager 
generate=failed,one Clinks=C

  here next portion - 3 kinds, one case per kind.

 hm.hmmm. on sqlite they were 3 failing - now only 2;
 on postgres all 3 fail...

 The cirlcular dep one - is there because i cannot get where the
 circ-dep is. The post-updates are invented by the mincut algo, and
 i don't see why such configuration is not working.

 Maybe something related to the not-really-inherited
 but-inheriting-something relations for concrete mappers? A.linkA is
 not post_update, while the B.linkA and C.linkA are.
 It goes away if A.linkA also gets a post_update.

 These are from all-possibilities for C.linkC=None, no_eager


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



z.py
Description: application/python


[sqlalchemy] Re: polymorphic mapping with more than 2 level of inheritance

2007-01-30 Thread svilen
 nevermind, try 2276.  it was yet another cache that was contributed
 by someone...

on 2280, still growing - something about sessions?
$ py tt.py repeat=1000 leak
('leak' will do the gc.colect/print)


 On Jan 29, 4:12 pm, Michael Bayer [EMAIL PROTECTED] wrote:
  sorry, there was one more quoting fix that was needed. passes
  with PG on 2274.
 
  as far as the memory, ive no idea whats going on.  well thats not
  true, my best guess is that unittest is holding onto every
  testcase it makes as a callable, with all of that callable's
  state.  playing around with GC, i can ensure that all SA
  collections are empty, I also found another collection lying
  about to empty out when clear_mappers() is called (thats in
  2275)...BUT...something is holding on to all the mappers,
  metadatas, etc, and it is not any global collection within SA.  i
  call gc.collect(), insure all module-level collections are
  totally empty (theres three), and the number of Mapper instances
  inside of gc.get_objects() grows and grows.
  adding this to tearDown():
 
  import gc
  gc.collect()
  print MAPPER REG:, dict(mapperlib.mapper_registry)
  print SESION REG:, dict(session._sessions)
  print CLASSKEYS:, dict(util.ArgSingleton.instances)
  for x in gc.get_objects():
  if isinstance(x, Mapper) or isinstance(x,
  BoundMetaData): print x
 
  On Jan 29, 2:42 pm, svilen [EMAIL PROTECTED] wrote:
   huh?
   Here is rev 2273, either the poly-branch, or the trunk - all
   the same - that error.
   Just in case, the files again.
  
   ---
   And while on it, u can run the case with repeat=1000 argument
   and see how memusage grows. i've put some functionality to
   reuse db-engine there - argument reuse_db;
   but regardless if u specify reuse_db or not, or is it
   db=sqlite:/// or postgres: memory goes up.
   Either i'm doing something wrong, or there's something fishy.
  
   $ python _test-pg-punion-mixedcasename.py db=postgres:///proba
   reuse_db repeat=1000
  
 nope i get this and it works:
   
SELECT pu_A.linkA_id AS pu_A_linkA_id, pu_A.atype AS
pu_A_atype, pu_A.name AS pu_A_name, pu_A.db_id AS
pu_A_db_id, pu_A.data2 AS pu_A_data2
FROM (SELECT A.linkA_id AS linkA_id, A.name AS name,
A.db_id AS db_id, CAST(NULL AS TEXT) AS data2, 'A' AS atype
FROM A UNION ALL SELECT B.linkA_id AS linkA_id,
B.name AS name, B.db_id AS db_id, B.data2 AS data2, 'B'
AS atype FROM B) AS pu_A ORDER BY pu_A.oid
   
On Jan 29, 1:42 pm, svilen [EMAIL PROTECTED] wrote:
 here's something about postgres:

 pu_A = polymorphic_union( {
 'A': table_A,
 'B': table_B,
 }, 'atype', 'pu_A', ) #concrete

 On postgres, the above fails - does not like the 'pu_A'.
 If it's lowercase/omitted, it's ok.

 i think u did already say that about mixed casing in some
 post above; should i just scratch that name/alias (it is
 there only for clarity)?

 $ python _test_ABC_all.py db=postgres:///proba

 SQLError: (ProgrammingError) missing FROM-clause entry for
 table pu_a
  'SELECT pu_A.id AS pu_A_id, pu_A.linkA_id AS
 pu_A_linkA_id, pu_A.atype AS pu_A_atype, pu_A.name AS
 pu_A_name, pu_A.data2 AS pu_A_data2 \nFROM (SELECT
 CAST(NULL AS TEXT) AS data2, A.linkA_id AS linkA_id,
 A.name AS name, A.id AS id, \'A\' AS atype \nFROM A
 UNION ALL SELECT B.data2 AS data2, B.linkA_id AS
 linkA_id, B.name AS name, B.id AS id, \'B\' AS atype
 \nFROM B) AS pu_A \nWHERE pu_A.id = %(pu_A_id)s ORDER
 BY pu_A.id \n LIMIT 1' {'pu_A_id': 1L}

  all tests pass with rev 2267 of that branch.  try that
  rev specifically, since i want to take whats there and do
  another pass. im trying to get it so that the entire
  science of parent table, child table, polymorphic
  selectables, primary join - polymorphic joins -
  determine direction/lazy clause/eager clause/synchronize
  FKs is super-well-nailed down.

  _test-pg-punion-mixedcasename.py
 3KDownload

  sa_gentestbase.py
 2KDownload
  
_test-pg-punion-mixedcasename.py
   4KDownload
  
sa_gentestbase.py
   4KDownload

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



sa_gentestbase.py
Description: application/python


tt.py
Description: application/python


[sqlalchemy] lazyload issue with new object creation

2007-01-30 Thread Dennis

I decided to set a group of columns to be deferred.

I have a situation in my code where I set the properties of an object 
in a loop.  After deferring the column group, the new object created 
can no longer set properties dynamically if I set the primary key 
columns first.

Example:

m=MyObject()
m.primary_key_col=1
m.__setattr__(name,val)
  File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line 
42, in __set__
  File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line 
232, in set
  File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line 
205, in get
  File build/bdist.linux-i686/egg/sqlalchemy/orm/strategies.py, line 
104, in lazyload
TypeError: unsubscriptable object

If I however wait until after the attributes are set to assign the 
primary key columns, things work.

m=MyObject()
m.__setattr__(name,val)
m.primary_key_col=1

Perhaps the lazyload code doesn't have another mechanism besides the 
primary key to know if the properties need loaded or not.  If it does, 
there might be a simple workaround to avoid the nuance above.

Thanks All
-Dennis


--~--~-~--~~~---~--~~
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: #446: Two deletions cascading to the same object can result in an error

2007-01-30 Thread Ian Kelly

  Finally, note that I'm _not_ asking for sqlalchemy to maintain the
  collections for me.  All I'm asking is for the cascade code not to
  attempt to delete objects that have already been deleted and flushed,
  or at least to safely handle the exception it raises when it does.

 OK, what behavior are you looking for  ?  it raises an exception right
 now.  whats unsafe about it ?

Well, it interrupts the cascading and leaves session.deleted in an
inconsistent state where not all of the object's dependents may be
included.  I was under the assumption that this meant those dependents
wouldn't be deleted, which would be a nightmare for trying to handle
the exception.  But it seems I was mistaken about that -- the flush
finds and deletes the remaining dependents anyway.  I could argue that
leaving session.deleted in an inconsistent state is still a bad thing,
but it's not nearly as severe as I had thought.

--~--~-~--~~~---~--~~
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: lazyload issue with new object creation

2007-01-30 Thread Michael Bayer

i know what that is, its fixed in rev 2281.

On Jan 30, 2007, at 2:27 PM, Dennis wrote:


 I decided to set a group of columns to be deferred.

 I have a situation in my code where I set the properties of an object
 in a loop.  After deferring the column group, the new object created
 can no longer set properties dynamically if I set the primary key
 columns first.

 Example:

 m=MyObject()
 m.primary_key_col=1
 m.__setattr__(name,val)
   File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line
 42, in __set__
   File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line
 232, in set
   File build/bdist.linux-i686/egg/sqlalchemy/orm/attributes.py, line
 205, in get
   File build/bdist.linux-i686/egg/sqlalchemy/orm/strategies.py, line
 104, in lazyload
 TypeError: unsubscriptable object

 If I however wait until after the attributes are set to assign the
 primary key columns, things work.

 m=MyObject()
 m.__setattr__(name,val)
 m.primary_key_col=1

 Perhaps the lazyload code doesn't have another mechanism besides the
 primary key to know if the properties need loaded or not.  If it does,
 there might be a simple workaround to avoid the nuance above.

 Thanks All
 -Dennis


 


--~--~-~--~~~---~--~~
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: #446: Two deletions cascading to the same object can result in an error

2007-01-30 Thread Ian

On Jan 30, 12:51 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jan 30, 2:35 pm, Ian Kelly [EMAIL PROTECTED] wrote:

Finally, note that I'm _not_ asking for sqlalchemy to maintain the
collections for me.  All I'm asking is for the cascade code not to
attempt to delete objects that have already been deleted and flushed,
or at least to safely handle the exception it raises when it does.

   OK, what behavior are you looking for  ?  it raises an exception right
   now.  whats unsafe about it ?

  Well, it interrupts the cascading and leaves session.deleted in an
  inconsistent state where not all of the object's dependents may be
  included.

 if that were true, thats a bug.  can you illustrate this ?  the
 deleted collection on the unit of work is never altered in any way
 until a flush() completes successfully.   in theory, the state of your
 program after an unsuccessful flush should be identical to that of
 before the flush.  this is one advantage to SA's we dont change your
 structures approach - not only is it a huge beast to manage the
 altering of structures, but we'd have to be able to roll the whole
 thing back too.

This happens as a result of a failed session.delete() operation.  The 
flush itself appears to be fine.  If you still want an example, I can 
whip one up.


--~--~-~--~~~---~--~~
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: #446: Two deletions cascading to the same object can result in an error

2007-01-30 Thread Michael Bayer


On Jan 30, 2007, at 5:26 PM, Ian wrote:
 the changed state on your objects is stored in an attribute on the
 object itself called _state (and actually, its not the changes as
 much as what was loaded from the database).  you can freely move
 instances from one session to the next (using either save_or_update()
 or merge()) and the changes will be maintained.

 Okay, that doesn't sound so bad.  It looks like I would still have to
 track deletions myself, but that shouldn't be too much extra work.

if you use cascades to maintain your deletes, i.e. you delete an  
instance by using the delete-orphan cascade and removal from its  
parent collection, that can also be moved across sessions.  I just  
clarified the description of the detached state in the docs on the  
site.



--~--~-~--~~~---~--~~
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: Tool to check whether DB matches model

2007-01-30 Thread Paul Johnston

Hi,

Well, I have used this a little more now and it is exactly what I need, 
although it took a bit of persuasion to get it working. I have updated 
the info on the Wiki at 
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/ModelUpdate

Michael - is this something you'd consider having as a plugin? It would 
be helpful for me, and I expect TurboGears would expose the 
functionality through the tg-admin command. If you're in favor in 
principle I am willing to put some work in to make it more usable.

Paul


Paul Johnston wrote:

Hi,

SQLObject's status command tells you if the database schema matches your 
model. Well, at least if the same tables and columns exist, I don't 
think it looks at types.

I have now found the script again...
http://www.sqlalchemy.org/trac/attachment/wiki/UsageRecipes/ModelUpdate/model_update.py

Paul
  



--~--~-~--~~~---~--~~
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] SQL Views ?

2007-01-30 Thread Guy Hulbert

Will there eventually be a 'View' in the SQLAlchemy API, like 'Table'.

I have been trying to find an example but 'view' tends to hit MVC
references in google searches.
-- 
--gh



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

2007-01-30 Thread Thomas Hunger

Hello,

I was wondering if there is a special reason to wrap the db api 
exceptions like e.g. IntegrityError into an SQLError.

The code could execute self._autorollback() and just rise the 
exception again. 

This would make much nicer exception handling (at least for me) in 
situations like 

...
session.flush()
except IntegrityError, integrity_error:
# handle error

instread of

session.flush()
except SQLError, e:
if (e.orig.pgcode == 23505): # handle 1
if (e.orig.pgcode == x): # etc


Tom

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

2007-01-30 Thread Michael Bayer

since the various DBAPI error classes are implemented within each  
DBAPI module (i.e. psycopg2.IntegrityError,  
pysqlite2.dbapi2.IntegrityError, etc), it makes it impossible to  
write DBAPI-neutral code if you want to catch those errors directly.

also things like the error code and such we'd eventually like to have  
available off of SQLError but most DBAPIs dont seem to implement  
these (and i see below youve located some more of those endlessly- 
undocumented PG datamembers)


On Jan 30, 2007, at 6:15 PM, Thomas Hunger wrote:


 Hello,

 I was wondering if there is a special reason to wrap the db api
 exceptions like e.g. IntegrityError into an SQLError.

 The code could execute self._autorollback() and just rise the
 exception again.

 This would make much nicer exception handling (at least for me) in
 situations like

 ...
 session.flush()
 except IntegrityError, integrity_error:
 # handle error

 instread of

 session.flush()
 except SQLError, e:
 if (e.orig.pgcode == 23505): # handle 1
 if (e.orig.pgcode == x): # etc


 Tom

 


--~--~-~--~~~---~--~~
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: SQL Views ?

2007-01-30 Thread Michael Bayer

you can probably get away with it by just creating a Table with the  
view name and view columns as Columns inside the Table.  reflection  
is generally not available, someone would have to make the effort to  
implement that for all the database modules.

On Jan 30, 2007, at 5:50 PM, Guy Hulbert wrote:


 Will there eventually be a 'View' in the SQLAlchemy API, like 'Table'.

 I have been trying to find an example but 'view' tends to hit MVC
 references in google searches.
 -- 
 --gh



 


--~--~-~--~~~---~--~~
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: SQL Views ?

2007-01-30 Thread Guy Hulbert

On Tue, 2007-30-01 at 18:57 -0500, Michael Bayer wrote:
 you can probably get away with it by just creating a Table with the  
 view name and view columns as Columns inside the Table.  reflection 

Yes.  I found this on one of the mailing lists.

I wanted something on which I could do:
v = View( ... )
v.create()
but I can do it via SQL for now.

  
 is generally not available, someone would have to make the effort to  
 implement that for all the database modules.

Ahh ... I see.

Ok.  tqvm

 
 On Jan 30, 2007, at 5:50 PM, Guy Hulbert wrote:
 
 
  Will there eventually be a 'View' in the SQLAlchemy API, like 'Table'.
 
  I have been trying to find an example but 'view' tends to hit MVC
  references in google searches.
  -- 
  --gh

-- 
--gh



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