[sqlalchemy] Re: Parameters not handled correctly with adodbapi

2007-02-15 Thread Arnar Birgisson

Thanks Rick,

The SA table definitions were using Unicode so I changed those to
String. I also make sure that the parameter in question is being sent
as a str object and not unicode. Same result in both cases, SQL Server
is only receiving the first character and the type is still detected
as nvarchar(1).

Any other ideas?

Arnar

On 2/14/07, Rick Morrison [EMAIL PROTECTED] wrote:
 The problem is most likely in the table definition which defines the
 dataset column as a Unicode type. A recent patch for adodb makes that an
 NVARCHAR field, vs. a simple VARCHAR for pymssql. Try defining the table
 with varchar or char datatype.




 On 2/14/07, Arnar Birgisson [EMAIL PROTECTED] wrote:
 
 
  Hi there,
 
  I have the following query in SA. It works using pymssql on Linux.
 
  criteria = and_(
  tables.salestable.c.dataset==self.xaldataset,
 
 tables.salestable.c.dataset==tables.projtable.c.dataset ,
 
 tables.salestable.c.proj==tables.projtable.c.proj,
  tables.salestable.c.projclosed==0,
  #tables.salestable.c.salesoffersent!=2,
  #tables.salestable.c.salesofferinvoice!=2,
   tables.salestable.c.projeststatus!=4,
  tables.salestable.c.projeststatus!=6,
  #tables.salestable.c.projeststatus!=7,
  *critlist
  )
 
  query = select([
  tables.salestable.c.dataset ,
  tables.salestable.c.salesnumber,
  tables.salestable.c.salesname,
  tables.salestable.c.ordertaker,
  tables.salestable.c.deliverydate,
  tables.salestable.c.projname ,
  tables.salestable.c.createdate,
  tables.salestable.c.rownumber,
  tables.projtable.c.proj,
  tables.projtable.c.opmprojno,
  tables.projtable.c.framstjori
  ], criteria)
 
  Here, self.xaldataset is ODD and critlist is [].
 
  When run on windows with adodbapi - this is the echoed query:
 
  2007-02-14 11:55:28,030
 sqlalchemy.engine.base.Engine.0x..30 INFO
  SELECT TOP 25 subq.dataset, subq.salesnumber, subq.salesname,
  subq.ordertaker, subq.deliverydate, subq.projname, subq.createdate,
  subq.rownumber, subq.proj, subq.opmprojno, subq.framstjori
  FROM (SELECT salestable.dataset AS dataset, salestable.salesnumber AS
  salesnumber, salestable.salesname AS salesname, salestable.ordertaker
  AS ordertaker, salestable.deliverydate AS deliverydate,
  salestable.projname AS projname, salestable.
  createdate AS createdate, salestable.rownumber AS rownumber,
  projtable.proj AS proj, projtable.opmprojno AS opmprojno,
  projtable.framstjori AS framstjori
  FROM salestable, projtable
  WHERE salestable.dataset = ? AND salestable.dataset =
  projtable.dataset AND salestable.proj = projtable.proj AND
  salestable.projclosed = ? AND salestable.projeststatus != ? AND
  salestable.projeststatus != ?) AS subq ORDER BY deliverydate
 
  2007-02-14 11:55:28,030
 sqlalchemy.engine.base.Engine.0x..30 INFO
  ['ODD', 0, 4, 6]
 
  Note the first parameter being 'ODD'.
 
  Now, the query wasn't returning the expected results so I looked at
  the query that was being sent in sql profiler:
 
  exec sp_executesql N'SELECT TOP 25 subq.dataset, subq.salesnumber,
  subq.salesname, subq.ordertaker, subq.deliverydate, subq.projname,
  subq.createdate, subq.rownumber ,
  subq.proj, subq.opmprojno, subq.framstjori
  FROM (SELECT salestable.dataset AS dataset, salestable.salesnumber AS
  salesnumber, salestable.salesname AS salesname, salestable.ordertaker
  AS ordertaker,
  salestable.deliverydate AS deliverydate, salestable.projname AS
  projname, salestable.createdate AS createdate, salestable.rownumber AS
  rownumber, projtable.proj AS proj,
  projtable.opmprojno AS opmprojno, projtable.framstjori AS framstjori
  FROM salestable, projtable
  WHERE salestable.dataset = @P1 AND salestable.dataset =
  projtable.dataset AND salestable.proj = projtable.proj AND
  salestable.projclosed = @P2 AND salestable.projeststatus
  != @P3 AND salestable.projeststatus != @P4) AS subq ORDER BY
  deliverydate',N'@P1 nvarchar(1),@P2 int,@P3 int,@P4 int',N'O',0,4,6
 
  Here you can see that the first parameter is givent the type
  nvarchar(1) and the value N'O'. I assume this is b/c somewhere the
  parameter is handled as a list - and being a string messes things up.
  Maybe because I'm using unicode strings?
 
  Could this be a SA bug or should I rather look into adodbapi?
 
  Arnar
 
   
 


--~--~-~--~~~---~--~~
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: Help get Wikipedia entry through review

2007-02-15 Thread Paul Johnston
Hi,

Well, more than improving the quality of the article, we need to make a case
for it being notable. The main criteria for this is:

Software is notable if it has been the subject of multiple non-trivial
published works whose source is independent of the software's author(s).

So, can we pick out two such examples? Off the top of my head, perhaps the
Rapid Web Application with TurboGears is one (need to check). Can someone
think of a second? Any magazine articles mentioned SA? Online magazines
would be ok, but notes in personal blogs probably won't cut it.

Paul


On 2/14/07, Hamish Lawson [EMAIL PROTECTED] wrote:


 I recently created a basic Wikipedia entry for SQLAlchemy:

 http://en.wikipedia.org/wiki/SQLAlchemy

 However it has been marked as being non-notable:

 An editor has expressed a concern that the subject of the article
 does not satisfy the notability guideline or one of the following
 guidelines for inclusion on Wikipedia ... If you are familiar with the
 subject matter, please expand the article to establish its notability,
 citing reliable sources. If notability cannot be established, the
 article is more likely to be considered for deletion, per
 Wikipedia:Guide to deletion.

 Is someone able to make the necessary modifications to get the article
 through review?

 Hamish


 


--~--~-~--~~~---~--~~
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: Help get Wikipedia entry through review

2007-02-15 Thread lele


On Thu, 15 Feb 2007 10:59:31 +, Paul Johnston [EMAIL PROTECTED] wrote:

 Can someone think of a second? 



Mailman?



ciao, lele.


--~--~-~--~~~---~--~~
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: Help get Wikipedia entry through review

2007-02-15 Thread Marco Mariani

Paul Johnston wrote:
 Hi,

 Well, more than improving the quality of the article, we need to make
 a case for it being notable. The main criteria for this is:

 Software is notable if it has been the subject of multiple
 non-trivial published works whose source is independent of the
 software's author(s).

 So, can we pick out two such examples? Off the top of my head, perhaps
 the Rapid Web Application with TurboGears is one (need to check).
 Can someone think of a second?

On O'Reilly Safari I can only find a pair of pages in Core Python
Programming (2nd ed.) and the TG book.

Books take time to publish... I'm sure this year we will see more

Academic papers anyone?


--~--~-~--~~~---~--~~
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: Help get Wikipedia entry through review

2007-02-15 Thread Paul Johnston
Ok, I have put a justification of notability on the talk page and contacted
the person who added the tag.

--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread svilen

can i make the mapper.someproperty.get_join() to return aliased 
version somehow? maybe copy the mapper?

 taking a look, i think what you should do is use an alias of the
 table_Employee in your queries.  since the engineer mapper is using
 joined table inheritance, the default table_Employee is already
 going to be involved in the query, so your external join condition
 needs to be off a distinct alias of it to prevent mixups.


--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread svilen
and, how u make the (3) or (4) work? 
aliasing the table.column in the comparison does not help.. it should 
be aliased somehow inside the join also.. 

Here a simpler case, without the inheritance. 
3 and 4 do not work here too - one does exception, other return 
nothing.

maybe express the query in another way? how?

ciao
svil

 taking a look, i think what you should do is use an alias of the
 table_Employee in your queries.  since the engineer mapper is using
 joined table inheritance, the default table_Employee is already
 going to be involved in the query, so your external join condition
 needs to be off a distinct alias of it to prevent mixups.

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



query-self-ref.py
Description: application/python


[sqlalchemy] sqlalchemy and securtiy

2007-02-15 Thread dischdennis

Hi there,

I am currently writing my thesis and using sqlalchemy as mapper. I did
not find anything security related in the docu.
Maybe can you give me some examples how sql alchemy supports security?
For example I think it prevents SQLInjection.

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: sqlalchemy and securtiy

2007-02-15 Thread Paul Johnston
Hi,

An ORM does not have many security responsibilities - most of these are
either in the application on top, or the underlying database. You rightly
point out that sqlalchemy does effectively prevent SQL injection - by using
bind parameters internally.

Paul


On 2/15/07, dischdennis [EMAIL PROTECTED] wrote:


 Hi there,

 I am currently writing my thesis and using sqlalchemy as mapper. I did
 not find anything security related in the docu.
 Maybe can you give me some examples how sql alchemy supports security?
 For example I think it prevents SQLInjection.

 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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread Michael Bayer

havent pored through any of these, but keep in mind you dont need to
use the query building feature at all.  you can send your own full-
blown SQL if you have a better idea of what query should be used for a
particular case (using either query.instances() or by sending a full
select() construct to query.select()).

On Feb 15, 9:41 am, svilen [EMAIL PROTECTED] wrote:
 and, how u make the (3) or (4) work?
 aliasing the table.column in the comparison does not help.. it should
 be aliased somehow inside the join also..

 Here a simpler case, without the inheritance.
 3 and 4 do not work here too - one does exception, other return
 nothing.

 maybe express the query in another way? how?

 ciao
 svil

  taking a look, i think what you should do is use an alias of the
  table_Employee in your queries.  since the engineer mapper is using
  joined table inheritance, the default table_Employee is already
  going to be involved in the query, so your external join condition
  needs to be off a distinct alias of it to prevent mixups.



  query-self-ref.py
 2KDownload


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

2007-02-15 Thread Michael Bayer

pretty much.  we use bind parameters for everything literal.  also we
dont spit out the DB passwords in error messages.  not sure if you
turn on connection pool logging if some of the DBAPIs put the
passwords in the __repr__ for their connection objects, thats
something that could be tested.

On Feb 15, 10:03 am, Paul Johnston [EMAIL PROTECTED] wrote:
 Hi,

 An ORM does not have many security responsibilities - most of these are
 either in the application on top, or the underlying database. You rightly
 point out that sqlalchemy does effectively prevent SQL injection - by using
 bind parameters internally.

 Paul

 On 2/15/07, dischdennis [EMAIL PROTECTED] wrote:



  Hi there,

  I am currently writing my thesis and using sqlalchemy as mapper. I did
  not find anything security related in the docu.
  Maybe can you give me some examples how sql alchemy supports security?
  For example I think it prevents SQLInjection.

  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: Help get Wikipedia entry through review

2007-02-15 Thread Michael Bayer

yah we're in the mailman trunk :).  also in use on some production
websites like Foxmarks.

On Feb 15, 7:06 am, Paul Johnston [EMAIL PROTECTED] wrote:
 Ok, I have put a justification of notability on the talk page and contacted
 the person who added the tag.


--~--~-~--~~~---~--~~
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: Adding a BLOB column to my Oracle database breaks my app

2007-02-15 Thread shday

This fixed the problem. I guess the 4k limit on the BLOB size will
still force me to store my files outside the database for now. I need
to store mostly Word and Excel files... which tend to be a tad longer
than 4k, even when they're empty!

Steve

On Feb 15, 10:17 am, Michael Bayer [EMAIL PROTECTED] wrote:
 im guessing its a value of None that I forgot to check for.  try rev.
 2321.  also you will definitely need to use the trunk for BLOBs in
 oracle since the PrefetchingResultProxy fix is only in the trunk.

 On Feb 14, 2:02 pm, shday [EMAIL PROTECTED] wrote:

  I've been using an Oracle database and reflection (i.e.,
  autoload=True). I recently added a BLOB column to the database. I
  never did any modification to the Python application code yet. The
  application was made using Turbogears and it just serves two forms,
  one for inserting records and one for updating . I am still able to
  update records, but when I do an insert I get the error below. I tried
  the latest oracle.py (r2303) and get the same thing (I couldn't do an
  svn checkout of everything because of our companies firewall).

  Page handler: bound method Root.insertrequest of
  srt.controllers.Root object at 0x0180EDB0
  Traceback (most recent call last):
File c:\python24\lib\site-packages\CherryPy-2.2.1-py2.4.egg\cherrypy
  \_cphttptools.py, line 105, in _run
  self.main()
File c:\python24\lib\site-packages\CherryPy-2.2.1-py2.4.egg\cherrypy
  \_cphttptools.py, line 254, in main
  body = page_handler(*virtual_path, **self.params)
File string, line 3, in insertrequest
File c:\python24\lib\site-packages\turbogears-1.0.1-py2.4.egg
  \turbogears\controllers.py, line 334, in expose
  output = database.run_with_transaction(
File string, line 5, in run_with_transaction
File c:\python24\lib\site-packages\turbogears-1.0.1-py2.4.egg
  \turbogears\database.py, line 347, in sa_rwt
  retval = dispatch_exception(e,args,kw)
File c:\python24\lib\site-packages\turbogears-1.0.1-py2.4.egg
  \turbogears\database.py, line 345, in sa_rwt
  transaction.commit()
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\session.py, line 54, in commit
  self.session.flush()
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\session.py, line 220, in flush
  self.uow.flush(self, objects)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 194, in flush
  flush_context.execute()
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 333, in execute
  head.execute(self)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 470, in execute
  UOWExecutor().execute(trans, self)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 793, in execute
  self.execute_save_steps(trans, task)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 815, in execute_save_steps
  self.execute_childtasks(trans, task, False)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 841, in execute_childtasks
  self.execute(trans, child, isdelete)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 793, in execute
  self.execute_save_steps(trans, task)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 810, in execute_save_steps
  self.save_objects(trans, task)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 798, in save_objects
  task._save_objects(trans)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\unitofwork.py, line 461, in _save_objects
  self.mapper.save_obj(self.polymorphic_tosave_objects, trans)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\orm\mapper.py, line 998, in save_obj
  c = connection.execute(statement, params)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\engine\base.py, line 258, in execute
  return Connection.executors[type(object).__mro__[-2]](self,
  object, *multiparams, **params)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\engine\base.py, line 282, in execute_clauseelement
  return self.execute_compiled(elem.compile(engine=self.__engine,
  parameters=param), *multiparams, **params)
File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\engine\base.py, line 297, in execute_compiled
  context.pre_exec(self.__engine, proxy, compiled, parameters)
File C:\Python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
  \sqlalchemy\databases\oracle.py, line 152, in pre_exec
  

[sqlalchemy] Re: query on table-inheritance, self-referencing mappers

2007-02-15 Thread Michael Bayer


On Feb 15, 2007, at 10:41 AM, svilen wrote:

 heh, i don't have a vague idea what it should be.

because you dont want to learn SQL.   but if youre really trying to  
write a one-person system on the scale of complexity of SAP, which  
usually have...i dunno, several hundred developers for many years ?   
i think youre gonna have to.

 i see at web that what i'm describing is called self-join.
 So basicaly, self-referential/self-joining queries cannot be done in
 SA?

did I say that ?

 worse, it can be more than 2 level, e.g.
 give those persons which persons.friend.friend.friend.name == 'pipi'

the only query that SA explicitly says no to is a self-referential  
eager load.   the rest, it will try and see how far it gets.   all  
ORMs require you to hand-code queries for criterions that are too  
complicated.


 On Feb 15, 9:41 am, svilen [EMAIL PROTECTED] wrote:
 and, how u make the (3) or (4) work?
 aliasing the table.column in the comparison does not help.. it
 should be aliased somehow inside the join also..

 Here a simpler case, without the inheritance.
 3 and 4 do not work here too - one does exception, other return
 nothing.

 maybe express the query in another way? how?

 ciao
 svil

 taking a look, i think what you should do is use an alias of
 the table_Employee in your queries.  since the engineer mapper
 is using joined table inheritance, the default table_Employee
 is already going to be involved in the query, so your external
 join condition needs to be off a distinct alias of it to
 prevent mixups.

  query-self-ref.py
 2KDownload



 


--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread svilen

  heh, i don't have a vague idea what it should be.

 because you dont want to learn SQL.   but if youre really trying to
 write a one-person system on the scale of complexity of SAP, which
 usually have...i dunno, several hundred developers for many years ?
 i think youre gonna have to.
learning SQL and learning how to use SQL are diff.things. Many ppl 
know python but few actualy _know_ it. i don't want to _know_ sql - 
e.g. the way u do.

  i see at web that what i'm describing is called self-join.
  So basicaly, self-referential/self-joining queries cannot be done
  in SA?

 the only query that SA explicitly says no to is a
 self-referential eager load.   the rest, it will try and see how
 far it gets.   all ORMs require you to hand-code queries for
 criterions that are too complicated.

i think i managed to construct a proper thing, changing 
PropertyLoader.get_join(), and made my own join_via():

PropertyLoader.get_join():
.
#add these before the secondaryjoin is and-ed:
if parent is self.mapper:
self_select_table = self.mapper.select_table.alias()
primaryjoin.accept_visitor( sql_util.ClauseAdapter(
self_select_table, equivalents=parent_equivalents,
exclude=self.foreignkey,  #noidea is it exclude or 
include or what
))


join_via(): tracking/returning also the last used sub_clause/mapper

and then (from the last_sub_clause) somehow reaching the target 
aliased column and use its table as base of the comparison:
...
 via_names = hierarchname[1:-1]
 last_attr = hierarchname[-1]
 clause, lastmapper, lastsubclause = join_via( via_names, mapper0)
 lastcol = lastmapper.prop[ last_attr]
 lastrefofclause = lastsubclause.right
 if isinstance( lastrefofclause.table, sql.Alias):
lastcol = lastcol._make_proxy( lastrefofclause.table )
 return clause, lastcol
 ## and now eventualy and_ the clause and lastcol
. 

The last-referred-aliased-table picking above is flaky, cannot make 
anything better for now - unless interface of get_join() is also 
changed to return that explicitly..

Any idea to incorporate such/similar functionality in SA? Probably 
with more stuff going on around polymorph-unions, secondary-joins  
etc.

  On Feb 15, 9:41 am, svilen [EMAIL PROTECTED] wrote:
  and, how u make the (3) or (4) work?
  aliasing the table.column in the comparison does not help.. it
  should be aliased somehow inside the join also..
 
  Here a simpler case, without the inheritance.
  3 and 4 do not work here too - one does exception, other return
  nothing.
 
  maybe express the query in another way? how?
 
  ciao
  svil
 
  taking a look, i think what you should do is use an alias of
  the table_Employee in your queries.  since the engineer mapper
  is using joined table inheritance, the default table_Employee
  is already going to be involved in the query, so your external
  join condition needs to be off a distinct alias of it to
  prevent mixups.
 

--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread svilen

no, wrong, there's more to it; each level's parent.table should be the 
previous level's aliased table...

 i think i managed to construct a proper thing, changing
 PropertyLoader.get_join(), and made my own join_via():

--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread svilen

Here, no need to touch Property.get_join(), only a new join_via():

def join_via( keys, mapper):
clause = None
c = None
self_select_table = None
for key in keys:
prop = mapper.props[key]
try:
c = prop.get_join() #SA rev2285
except TypeError:
c = prop.get_join( mapper)  #SA rev=2285
if prop.mapper is mapper:
column_equivalents =
  mapper._get_inherited_column_equivalents()
parent_select_table = self_select_table
self_select_table = prop.target.alias()

c.accept_visitor( sqlalchemy.sql_util.ClauseAdapter(
self_select_table, 
include=prop.remote_side,
equivalents= column_equivalents
))
if parent_select_table:
c.accept_visitor( sqlalchemy.sql_util.ClauseAdapter(
parent_select_table, 
include=prop.foreignkey,
equivalents= column_equivalents
))

if clause is None:
clause = c
else:
clause = c
mapper = prop.mapper
return clause, mapper, lasttable

### now and_() the condition_column._makeproxy( lasttable) and above 
clause. hmm that should be another ClauseAdapter...

 no, wrong, there's more to it; each level's parent.table should be
 the previous level's aliased table...

  i think i managed to construct a proper thing, changing
  PropertyLoader.get_join(), and made my own join_via():


--~--~-~--~~~---~--~~
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] MS-SQL - default schema for engine does not generate useable SQL for SELECT

2007-02-15 Thread metaperl

Ok, the following lines of SA/Python:

#  the constructor sets
# sa.engine.dialect.set_default_schema_name('DataTables')
# full code below
sa = data.config.db.sqlalchemy(schema=DataTables, echo=True)

# leaving off schema='DataTables' generates invalid SQL
ke_contracts = Table('KEContracts', sa.metadata, autoload=True)

result = ke_contracts.select(ke_contracts.c.refnum == r).execute()

will yield Invalid object name 'KEContracts'


but adding schema=DataTables like so:

ke_contracts = Table('KEContracts', sa.metadata, autoload=True,
schema=DataTables)

==
class sqlalchemy:

def __init__(self, ip=224.55.182.2, db=DATA,
schema=DataTables, echo=True):
conn_url = mssql://xx:[EMAIL PROTECTED]:1433/%s % (ip, db)
print conn_url, conn_url
self.engine = create_engine(conn_url)

self.engine.dialect.set_default_schema_name(schema)

self.engine.echo=echo
self.metadata = BoundMetaData(self.engine)
results in a successful select...


to me this implies that setting the default schema name on the engine
does not make the proper schema qualifications on the SQL...

it boils down to the FROM part being

FROM DataTables.KEContracts

instead of

From KEContracts

and one working and the other yielding invalid object name.


--~--~-~--~~~---~--~~
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: Adding a BLOB column to my Oracle database breaks my app

2007-02-15 Thread shday

With rev. 2321 of oracle.py I'm getting the error below  when I do the
following:

sr =
session.query(StudyRequest).selectfirst(study_request_table.c.study_request_id
== request_id)

With 3.4 I don't get and error.

Note that I'm only using oracle.py from the trunk, everything else is
3.4

Traceback (most recent call last):
  File console, line 1, in ?
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\orm\
query.py, line 214, in selectfirst
ret = self.select_whereclause(*args, **params)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\orm\
query.py, line 252, in select_whereclause
return self._select_statement(statement, params=params)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\orm\
query.py, line 378, in _select_statement
return self.execute(statement, params=params, **kwargs)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\orm\
query.py, line 308, in execute
result = self.session.execute(self.mapper, clauseelement,
params=params)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\orm\
session.py, line 133, in execute
return self.connection(mapper,
close_with_result=True).execute(clause, param
s, **kwargs)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\engi
ne\base.py, line 258, in execute
return Connection.executors[type(object).__mro__[-2]](self,
object, *multipa
rams, **params)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\engi
ne\base.py, line 282, in execute_clauseelement
return self.execute_compiled(elem.compile(engine=self.__engine,
parameters=p
aram), *multiparams, **params)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\sql.
py, line 511, in compile
compiler.compile()
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\sql.
py, line 392, in compile
self.statement.accept_visitor(self)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\sql.
py, line 1607, in accept_visitor
self.order_by_clause.accept_visitor(visitor)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\sql.
py, line 915, in accept_visitor
c.accept_visitor(visitor)
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\sql.
py, line 1259, in accept_visitor
visitor.visit_column(self)
  File C:\Python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\data
bases\oracle.py, line 378, in visit_column
  File c:\python24\lib\site-packages\sqlalchemy-0.3.4-py2.4.egg
\sqlalchemy\ansi
sql.py, line 218, in visit_column
n = self.dialect.oid_column_name()
TypeError: oid_column_name() takes exactly 2 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: MS-SQL - default schema for engine does not generate useable SQL for SELECT

2007-02-15 Thread Rick Morrison
Are you using svn trunk? There were some updates to schema support in MSSQL
recently.

Rick


On 2/15/07, metaperl [EMAIL PROTECTED] wrote:


 Ok, the following lines of SA/Python:

 #  the constructor sets
 # sa.engine.dialect.set_default_schema_name('DataTables')
 # full code below
 sa = data.config.db.sqlalchemy(schema=DataTables, echo=True)

 # leaving off schema='DataTables' generates invalid SQL
 ke_contracts = Table('KEContracts', sa.metadata, autoload=True)

 result = ke_contracts.select(ke_contracts.c.refnum == r).execute()

 will yield Invalid object name 'KEContracts'


 but adding schema=DataTables like so:

 ke_contracts = Table('KEContracts', sa.metadata, autoload=True,
 schema=DataTables)

 ==
 class sqlalchemy:

 def __init__(self, ip=224.55.182.2, db=DATA,
 schema=DataTables, echo=True):
 conn_url = mssql://xx:[EMAIL PROTECTED]:1433/%s % (ip, db)
 print conn_url, conn_url
 self.engine = create_engine(conn_url)

 self.engine.dialect.set_default_schema_name(schema)

 self.engine.echo=echo
 self.metadata = BoundMetaData(self.engine)
 results in a successful select...


 to me this implies that setting the default schema name on the engine
 does not make the proper schema qualifications on the SQL...

 it boils down to the FROM part being

 FROM DataTables.KEContracts

 instead of

 From KEContracts

 and one working and the other yielding invalid object name.


 


--~--~-~--~~~---~--~~
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: MS-SQL - default schema for engine does not generate useable SQL for SELECT

2007-02-15 Thread Paul Johnston

Hi,

That looks like a bug to me. As Rick suggested, first try with the 
latest svn version. If it's still broken (I expect it will be), create a 
minimal test case and file a bug on the tracker.

You've got an obvious workaround of specifying the schema on your 
tables. Actually, I'm not quite sure why MSSQL has created a db-specific 
idea of a default schema - this just seems to be inviting trouble.

Paul


metaperl wrote:

to me this implies that setting the default schema name on the engine
does not make the proper schema qualifications on the SQL...
  



--~--~-~--~~~---~--~~
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] MS-SQL column of bit datatype... what to provide?

2007-02-15 Thread metaperl

In my MS SQL 2005 database schema, the field RRates is a bit field.
I have tried to supply False, both as a string and a Python boolean
and neither seems to create an acceptable SQL insert statement.

dat = dict(
RRates= 0, # 0, 0, False, False all dont work
)


ke_contracts.insert().execute(dat)


--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread sdobrev

final, ok for indirect recursion too .

##
import sqlalchemy

def join_via( keys, mapper):
'''Query.join_via, input root mapper, return last mapper/table;
alias and link properly recursive /self-referential joins
'''
clause = None
c = None
self_table = None
self_colequivalents = None
xmappers = [mapper]#mapper === parent
for key in keys:
prop = mapper.props[key]
c = prop.get_join( mapper)  #SA rev=2285

parent_table = self_table
self_table = prop.target
parent_colequivalents = self_colequivalents
self_colequivalents =
  prop.mapper._get_inherited_column_equivalents()

print key,prop.primaryjoin,prop.foreignkey,prop.remote_side

if prop.mapper in xmappers:
self_table = self_table.alias()
print '', self_table.name
c.accept_visitor( sqlalchemy.sql_util.ClauseAdapter(
self_table, include=prop.remote_side,
equivalents= self_colequivalents
))
xmappers.append( prop.mapper)
if mapper in xmappers:
if parent_table:
c.accept_visitor( sqlalchemy.sql_util.ClauseAdapter(
parent_table, include=prop.foreignkey,
equivalents= parent_colequivalents
))
print '', c

if clause is None:
clause = c
else:
clause = c

mapper = prop.mapper

return clause, mapper, self_table

##
Anyone interested in the resulting expression-translator?
It is independent from the sawrap-per, although will be used inside.
e.g. convert plain python-func/method
def myfilter( person): 
  return ( (person.friend.address.owner.friend.age  20) 
   person.name.startswith('a') )
into SA-query...

--~--~-~--~~~---~--~~
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: PostGreSQL Referential Integrity with composed primary key

2007-02-15 Thread dischdennis

Sorry, I placed the testcase here:

http://groups.google.de/group/sqlalchemy/web/testcase_dischdennis_Postgre.py

I could not find a way to upload it with the message directly.

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: MS-SQL column of bit datatype... what to provide?

2007-02-15 Thread Rick Morrison
Bit == Boolean for MS-SQL, so use True/False.

I have tested bit fields with pymssql inserts/updates/deletes and they work
fine. If you're using adodbapi, perhaps someone else on the list can try a
quick test, as I don't have a working adodbapi setup right now.

Rick


On 2/15/07, metaperl [EMAIL PROTECTED] wrote:


 In my MS SQL 2005 database schema, the field RRates is a bit field.
 I have tried to supply False, both as a string and a Python boolean
 and neither seems to create an acceptable SQL insert statement.

 dat = dict(
 RRates= 0, # 0, 0, False, False all dont work
 )


 ke_contracts.insert().execute(dat)


 


--~--~-~--~~~---~--~~
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: Adding a BLOB column to my Oracle database breaks my app

2007-02-15 Thread Michael Bayer


On Feb 15, 2007, at 12:21 PM, shday wrote:


 With rev. 2321 of oracle.py I'm getting the error below  when I do the
 following:

 sr =
 session.query(StudyRequest).selectfirst 
 (study_request_table.c.study_request_id
 == request_id)

 With 3.4 I don't get and error.

 Note that I'm only using oracle.py from the trunk, everything else is
 3.4

indeed... do you need me to tell you that that method signature has  
changed since 0.3.4 ?  :)

(it has)





--~--~-~--~~~---~--~~
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: PostGreSQL Referential Integrity with composed primary key

2007-02-15 Thread Gary Bernhardt
The pr_PurchaseRequisition_has_CELLS_budget_has_CELLS_costCenter table is
the one that's causing your problem.  It has a foreign key to
CELLS_budget_has_CELLS_costCenter.CELLS_budget_ID (and another to
CELLS_costCenter_ID on the same table).  Neither of those
two columns are unique.  If you add unique=True to both of their
definitions, SA will succeed in creating the tables.
 It will fail later, though -
you apparently insert rows where those columns really aren't unique.

On 2/15/07, dischdennis [EMAIL PROTECTED] wrote:


 Sorry, I placed the testcase here:


 http://groups.google.de/group/sqlalchemy/web/testcase_dischdennis_Postgre.py

 I could not find a way to upload it with the message directly.

 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] MS-SQL - generated UPDATE sql yields The multi-part identifier KEContracts.refnum could not be bound.

2007-02-15 Thread metaperl

It's that MS-SQL weenie metaperl back at ya with another problem with
the latest svn SA:

The multi-part identifier KEContracts.refnum could not be bound.

Bottom line is that there WHERE part of the SQL looks like this:
WHERE [KEContracts].refnum = %(KEContracts_refnum)s

and it is a fact that we need to either remove the [KEContracts]. from
in front of the refnum declaration, or add .[dataTables]. between
[KEContracts] and [refnum] to fix.




Here is my source code:

#!/usr/bin/env python

from pyparsing import *
import pprint, sys
import data.config.db
from sqlalchemy import *

sa = data.config.db.sqlalchemy(schema=DataTables, echo=False)


ke_contracts = Table('KEContracts', sa.metadata, autoload=True,
schema=DataTables)

f = open('UK_Agg.txt')



for i, line in enumerate(f.read().split('|||')):
print line #, i
rec = delimitedList(QuotedString('',escQuote='',
multiline=True)).parseString(line)

refnum= rec[0]
print \trefnum, refnum

result = ke_contracts.select(ke_contracts.c.refnum ==
refnum).execute()

dat = dict(
ParentRefnum  = rec[1],  # ParentRefNum  - int
Licensee  = rec[2],  # Licensee
Licensor  = rec[3],  # Licensor
ContractDate  = rec[4],  # ContractDate  - datetime
#ContractTerms = rec[5],  # ContractTerms
ContractCategory = rec[30], # ContractCategory
PartIndex = rec[6],  # PartIndex - int
#RRates= 0, # RRates  - not in datafile
GeoRestrict   = rec[8],  # GeoRestrict
Industry  = rec[30], # Industry
Exclusive = rec[10], # Exclusive
UserID= rec[20], # UserID - int
Status= rec[9],  # Status - smallint
CreateDate= rec[11], # CreateDate  - datetime
RecordDate= rec[13], # RecordDate  - datetime
AgreementType = rec[12], # AgreementType
)

if result.fetchone() is None:
print \t\tINSERT
#pprint.pprint(dat)
dat[refnum]= refnum
ke_contracts.insert().execute(dat)
else:
print \t\tUPDATE
ke_contracts.update(ke_contracts.c.refnum==refnum).execute(**dat)
sys.exit()


class sqlalchemy:

def __init__(self, ip=4.19.18.7 db=DATA, schema=DataTables,
echo=True):
conn_url = mssql://perl2:[EMAIL PROTECTED]:1433/%s % (ip, db)
print conn_url, conn_url
self.engine = create_engine(conn_url)

self.engine.dialect.set_default_schema_name(schema)

self.engine.echo=echo
self.metadata = BoundMetaData(self.engine)


--~--~-~--~~~---~--~~
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: PostGreSQL Referential Integrity with composed primary key

2007-02-15 Thread Gary Bernhardt
On 2/15/07, dischdennis [EMAIL PROTECTED] wrote:


 Thats the problem.
 I know that it is possible to add unique = True for each column. But
 then it is not possible to assign combinations of budget / cost
 centers like (1,1)(1,2)(1,3)...etc...
 So I would like to define both primary keys, the complete primary key
 together as unique. Thats what I tried with the UniqueConstraint. But
 it checks only for the contraint itself. I would have to reference on
 the complete primary key not only on the single column. but how to do
 this with sqlalchemy?


You can define multi-column foreign keys with ForeignKeyConstraint.
Search for it at
http://www.sqlalchemy.org/docs/metadata.myt.

So there is no solution to get it running with this requirement in
 postgresql ? (except defining a new ID but I cannot change the schema)


 On 15 Feb., 21:03, Gary Bernhardt [EMAIL PROTECTED] wrote:
  The pr_PurchaseRequisition_has_CELLS_budget_has_CELLS_costCenter table
 is
  the one that's causing your problem.  It has a foreign key to
  CELLS_budget_has_CELLS_costCenter.CELLS_budget_ID (and another to
  CELLS_costCenter_ID on the same table).  Neither of those
  two columns are unique.  If you add unique=True to both of their
  definitions, SA will succeed in creating the tables.
   It will fail later, though -
  you apparently insert rows where those columns really aren't unique.
 
  On 2/15/07, dischdennis [EMAIL PROTECTED] wrote:
 
 
 
   Sorry, I placed the testcase here:
 
  http://groups.google.de/group/sqlalchemy/web/testcase_dischdennis_Pos.
 ..
 
   I could not find a way to upload it with the message directly.
 
   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: Announcing Elixir!

2007-02-15 Thread Jonathan LaCour

Jonathan Ellis wrote:

 Is there a what's new and improved in Elixir document anywhere?

Well, its pretty much entirely new and improved over TurboEntity and
ActiveMapper, in that it provides a totally different way of doing
things.  The extensive documentation and examples on the website will
probably give a reasonable idea of how Elixir is different from both
ActiveMapper and TurboEntity.

--
Jonathan LaCour
http://cleverdevil.org




--~--~-~--~~~---~--~~
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: query on table-inheritance, self-referencing mappers

2007-02-15 Thread Michael Bayer

yeah...this is totally fine for you to use, but i dont want to change  
SA to this, particularly becuase it forces a change to the return  
signature of join_via...it makes an arbitrary alias, and returns  
three objects back to you which now you have to use in the criterion,  
trust me nobody's going to bother trying to deal with that.  better  
to have people just construct exactly the criterion they want  
explicitly (using their own manually-constructed alias) and feed it  
in.  join_via/join_to/etc. are just shortcuts for common cases  
(therefore, probably not very useful for your purposes).

On Feb 15, 2007, at 1:54 PM, [EMAIL PROTECTED] wrote:


 final, ok for indirect recursion too .

 ##
 import sqlalchemy

 def join_via( keys, mapper):
 '''Query.join_via, input root mapper, return last mapper/table;
 alias and link properly recursive /self-referential joins
 '''
 clause = None
 c = None
 self_table = None
 self_colequivalents = None
 xmappers = [mapper]#mapper === parent
 for key in keys:
 prop = mapper.props[key]
 c = prop.get_join( mapper)  #SA rev=2285

 parent_table = self_table
 self_table = prop.target
 parent_colequivalents = self_colequivalents
 self_colequivalents =
   prop.mapper._get_inherited_column_equivalents()

 print key,prop.primaryjoin,prop.foreignkey,prop.remote_side

 if prop.mapper in xmappers:
 self_table = self_table.alias()
 print '', self_table.name
 c.accept_visitor( sqlalchemy.sql_util.ClauseAdapter(
 self_table, include=prop.remote_side,
 equivalents= self_colequivalents
 ))
 xmappers.append( prop.mapper)
 if mapper in xmappers:
 if parent_table:
 c.accept_visitor( sqlalchemy.sql_util.ClauseAdapter(
 parent_table, include=prop.foreignkey,
 equivalents= parent_colequivalents
 ))
 print '', c

 if clause is None:
 clause = c
 else:
 clause = c

 mapper = prop.mapper

 return clause, mapper, self_table

 ##
 Anyone interested in the resulting expression-translator?
 It is independent from the sawrap-per, although will be used inside.
 e.g. convert plain python-func/method
 def myfilter( person):
   return ( (person.friend.address.owner.friend.age  20)
person.name.startswith('a') )
 into SA-query...

 


--~--~-~--~~~---~--~~
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: Announcing Elixir!

2007-02-15 Thread Michael Bayer

i hear if you mix Elixir in your SQLSoup it explodes.


On Feb 15, 2007, at 3:28 PM, Jonathan LaCour wrote:


 Jonathan Ellis wrote:

 Is there a what's new and improved in Elixir document anywhere?

 Well, its pretty much entirely new and improved over TurboEntity and
 ActiveMapper, in that it provides a totally different way of doing
 things.  The extensive documentation and examples on the website will
 probably give a reasonable idea of how Elixir is different from both
 ActiveMapper and TurboEntity.

 --
 Jonathan LaCour
 http://cleverdevil.org




 


--~--~-~--~~~---~--~~
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: Announcing Elixir!

2007-02-15 Thread Jonathan Ellis

For instance, I remember reading somewhere that AM wasn't very good at
playing well with the rest of SA when AM wasn't enough, so I never
bothered looking at AM very hard.  I don't see anything on the elixir
site about this issue, but maybe I am looking in the wrong place.

On 2/15/07, Jonathan LaCour [EMAIL PROTECTED] wrote:

 Jonathan Ellis wrote:

  Is there a what's new and improved in Elixir document anywhere?

 Well, its pretty much entirely new and improved over TurboEntity and
 ActiveMapper, in that it provides a totally different way of doing
 things.  The extensive documentation and examples on the website will
 probably give a reasonable idea of how Elixir is different from both
 ActiveMapper and TurboEntity.

 --
 Jonathan LaCour
 http://cleverdevil.org




 


--~--~-~--~~~---~--~~
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: Announcing Elixir!

2007-02-15 Thread Jonathan LaCour

Jonathan Ellis wrote:

 For instance, I remember reading somewhere that AM wasn't very good
 at playing well with the rest of SA when AM wasn't enough, so I never
 bothered looking at AM very hard.  I don't see anything on the elixir
 site about this issue, but maybe I am looking in the wrong place.

I know for sure that Elixir plays a bit better with the rest of SA than
ActiveMapper ever did, but there might still be problems.  The key
thing is that there are three of us helping maintain Elixir now, and
any issues that people find dealing with mixing Elixir and traditional
SQLAlchemy techniques are bugs that should be fixed!

With ActiveMapper, the approach that I took had some issues and
overcoming them required more time than I had to give.  With Elixir,
having a team of people committed to helping out makes all the
difference in the world.

--
Jonathan LaCour
http://cleverdevil.org

--~--~-~--~~~---~--~~
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: Announcing Elixir!

2007-02-15 Thread Karl Guertin

On 2/15/07, Jonathan Ellis [EMAIL PROTECTED] wrote:
 For instance, I remember reading somewhere that AM wasn't very good at
 playing well with the rest of SA when AM wasn't enough, so I never
 bothered looking at AM very hard.  I don't see anything on the elixir
 site about this issue, but maybe I am looking in the wrong place.

That would be my FUD. I only had it happen in a particular 0.2 release
(forget which). Everybody else who has used the two together seems to
have never had a problem and I know I haven't had any problems mixing
the TurboGears identity (AM) with non-AM classes in SA 0.3. I doubt
it'd be listed in the Elixir docs because it hasn't been a widespread
problem. I'm just noisy.

P.S. I hear if you mix Elixir and SQLSoup you get magic DSL jellybeans.

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