there's this:

*>>> import sqlalchemy as sa**
**>>> sa.sql.null()**
**<sqlalchemy.sql.elements.Null object at 0x7f8a70065c50>**
**>>> sa.sql.false()**
**<sqlalchemy.sql.elements.False_ object at 0x7f8a6fb13050>**
**>>> sa.sql.true()**
**<sqlalchemy.sql.elements.True_ object at 0x7f8a70065c50>**
*
so, you can still use __eq__ and pep-8 will not complain, because there's no way to implement "is True" or "is None". then you'll have this:

*session.query(Rischio.c.codice).select_from(Rischio).filter(Rischio.c.peso_gruppo == sa.**sql.true()**)*

:)

On 03/30/2015 10:52 AM, Jose Soares wrote:
Hmm! in this case we must distinguish between the python syntax and the sqlalchemy syntax.:-(
j
On 30/03/2015 12:37, Simon King wrote:
On Mon, Mar 30, 2015 at 10:59 AM, Jose Soares
<jose.soa...@sferacarta.com> wrote:
Hi all,

While I changed some obsolete syntax as defined in
(https://www.python.org/dev/peps/pep-0008/)
like (is True instead of ==True) also False and None.
I realized that sqlalchemy do not support them
What can I do to avoid this behavior?


------------------------------------------------------

print
session.query(Rischio.c.codice).select_from(Rischio).filter(Rischio.c.peso_gruppo
== True)

SELECT caratteristica_rischio.codice AS caratteristica_rischio_codice
FROM caratteristica_rischio
WHERE caratteristica_rischio.peso_gruppo = true

print
session.query(Rischio.c.codice).select_from(Rischio).filter(Rischio.c.peso_gruppo
is True)
SELECT caratteristica_rischio.codice AS caratteristica_rischio_codice
FROM caratteristica_rischio
WHERE false

I don't think you can. SQLAlchemy expressions define an "__eq__"
method to enable "expression == value"-style constructs. There is no
equivalent hook in Python for the "is" operator, so there is no way
SQLAlchemy could use it.

Simon



--
Richard Gerd Kuesters
Pollux Automation
rich...@pollux.com.br <mailto:rich...@pollux.com.br> | www.pollux.com.br <http://www.pollux.com.br>
        

•Linhas de Montagem
•Inspeção e Testes
•Robótica       •Identificação e Rastreabilidade
•Software para Manufatura

--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to