On Nov 22, 2013, at 4:50 AM, Jose Soares <[email protected]> wrote:

> Hi all,
> 
> I have a query generated by sqlalchemy like this:
> 
> SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento,
> fattura_master.sezionale || '/' || CAST(fattura_master.anno AS VARCHAR(None 
> CHAR)) || '/' || CAST(fattura_master.numero AS VARCHAR(None CHAR)) AS pk FROM 
> fattura_master;
> 
> which generate the following error:
> 
> DatabaseError: (DatabaseError) ORA-00910: specified length too long for its 
> datatype
> 
> I can't understand the syntax: VARCHAR(None CHAR). I suppose the error is 
> generated by it. Isn't it?

seems like even in master it’s still doing that so this is a new issue 
http://www.sqlalchemy.org/trac/ticket/2870.

give it a length for now.

cast(x, String(100))





> 
> It workd fine in PostgreSQL:
> 
> Take a look:
> ---------
> using PostgreSQL:
> 
> In [1]: qry = session.query(Master.c.tipo_documento, 
> (Master.c.sezionale+'|'+sa.cast(Master.c.anno,sa.String)+'|'+sa.cast(Master.c.numero,sa.String)).label('pk'))
> 
> In [2]: print qry
> SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento, 
> fattura_master.sezionale || %(sezionale_1)s || CAST(fattura_master.anno AS 
> VARCHAR) || %(param_1)s || CAST(fattura_master.numero AS VARCHAR) AS pk
> FROM fattura_master
> 
> In [3]: qry.count()
> /home/jose/buildout/eggs/SQLAlchemy-0.6.8-py2.6.egg/sqlalchemy/engine/default.py:518:
>  SAWarning: Unicode type received non-unicode bind param value.
>  param[key.encode(encoding)] = processors[key](compiled_params[key])
> 
> SELECT count(1) AS count_1
> FROM (SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento, 
> fattura_master.sezionale || %(sezionale_1)s || CAST(fattura_master.anno AS 
> VARCHAR) || %(param_1)s || CAST(fattura_master.numero AS VARCHAR) AS pk
> FROM fattura_master) AS anon_1
> 
> {'sezionale_1': '|', 'param_1': '|'}
> Out[4]: 63195L
> 
> ----------------------------------------------
> using Oracle:
> 
> In [1]: qry = session.query(Master.c.tipo_documento, 
> (Master.c.sezionale+'|'+sa.cast(Master.c.anno,sa.String)+'|'+sa.cast(Master.c.numero,sa.String)).label('pk'))
> 
> In [2]: print qry
> SELECT fattura_master.tipo_documento AS fattura_master_tipo_documento, 
> fattura_master.sezionale || :sezionale_1 || CAST(fattura_master.anno AS 
> VARCHAR(None CHAR)) || :param_1 || CAST(fattura_master.numero AS VARCHAR(None 
> CHAR)) AS pk
> FROM fattura_master
> 
> In [3]: qry.count()
> DatabaseError: (DatabaseError) ORA-00910: specified length too long for its 
> datatype
> 'SELECT count(1) AS count_1 \nFROM (SELECT fattura_master.tipo_documento AS 
> fattura_master_tipo_documento, fattura_master.sezionale || :sezionale_1 || 
> CAST(fattura_master.anno AS VARCHAR(None CHAR)) || :param_1 || 
> CAST(fattura_master.numero AS VARCHAR(None CHAR)) AS pk \nFROM 
> fattura_master) anon_1' {'sezionale_1': '|', 'param_1': '|'}
> 
> j
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to