I'm working over latest version and i appreciate a lot all news... There is a lot of pretty think i'm implementing in our lib..
now some question: --------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------- - strings and columns can also be sent to the *args of instances() where those exact result columns will be part of the result tuples. What does it means? i've tryed in many way...but i cannot find any way for do it. --------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------- Only way i found for retrieve some column from generative methods is to use the select constructor at the end of my generated qry. ret = ret.select(select(columns)) but in this manner i found some problem, for example in a simple table ( codice, descrizione) with a primary key In [18]: t = TipoFigura() In [19]: t.c._data Out[19]: {'codice': Column('codice',PGChar(length=1),primary_key=True,nullable=False), 'descrizione': Column('descrizione',PGText(length=None),nullable=False)} In [20]: t.select( select([t.c.codice]) ) 2007-04-02 17:34:38,310 sqlalchemy.engine.base.Engine.0x..54 INFO SELECT tipo_figura.codice AS tipo_figura_codice FROM tipo_figura 2007-04-02 17:34:38,311 sqlalchemy.engine.base.Engine.0x..54 INFO {} In [21]: t.select( select([t.c.descrizione]) ) 2007-04-02 17:35:06,311 sqlalchemy.engine.base.Engine.0x..54 INFO _SELECT tipo_figura.descrizione AS tipo_figura_descrizione FROM tipo_figura_ 2007-04-02 17:35:06,312 sqlalchemy.engine.base.Engine.0x..54 INFO {} --------------------------------------------------------------------------- sqlalchemy.exceptions.NoSuchColumnError Traceback (most recent call last) /home/xxx/<ipython console> /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/ext/assignmapper.py in do(self, *args, **kwargs) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/query.py in select(self, arg, **kwargs) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/query.py in select_statement(self, statement, **params) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/query.py in _select_statement(self, statement, params, **kwargs) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/query.py in execute(self, clauseelement, params, *args, **kwargs) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/query.py in instances(self, cursor, *mappers_or_columns, **kwargs) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py in _instance(self, context, row, result, skip_polymorphic) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py in identity_key_from_row(self, row) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/engine/base.py in __getitem__(self, key) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/engine/base.py in _get_col(self, row, key) /home/xxx/build/bdist.linux-i686/egg/sqlalchemy/engine/base.py in _convert_key(self, key) NoSuchColumnError: "Could not locate column in row for column 'tipo_figura.codice'" see that this query is exactly what i expect: _SELECT tipo_figura.descrizione AS tipo_figura_descrizione FROM tipo_figura_ --------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------- What i try to do with new features is to unify all search fuction in all mapper to a complete and exaustive function, for example: def search_m( self, select_clause=None, limit=None, offset=None, order_by=[], use_labels=False, columns=[], **kw ): """ This is the simplest search function, over one table and only 2 search column. """ # WHERE-CLAUSE by_where_clause = {} # For generative methods where_clause = [] # classical where Clause for k,v in kw.items(): if k in ('codice',\ ): by_where_clause[ k ] = v elif k == 'descrizione': where_clause.append( self.c.descrizione.op('ilike')('%'+v+'%') ) #else: # raise ValueError, "XXX %s:%s"%(k, v) ret = session.query( TipoFigura ) if by_where_clause: ret = ret.filter_by( **by_where_clause ) if where_clause: ret = ret.filter( and_( *where_clause ) ) if limit: ret = ret.limit( limit ) if offset: ret = ret.offset( offset ) if order_by: ret = ret.order_by( order_by ) if columns: ret = ret.select(select(columns)) return ret i've done all for returnig a "<class 'sqlalchemy.orm.query.Query'>" but with the last .select(select(columns)) it return a list and this is different. how can i use this features and returning the same orm.query obj? thank all Glauco -- +------------------------------------------------------------+ Glauco Uri - Programmatore glauco(at)allevatori.com Sfera Carta Software® [EMAIL PROTECTED] Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054 +------------------------------------------------------------+ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---