py32 TypeError: unorderable types: str() < int()

368 views
Skip to first unread message

ddarko

unread,
Jul 20, 2011, 1:26:19 PM7/20/11
to sqlalchemy
declarative_base

tmp = session.query(Opt).all()
session.add(Opt(key='a', value='b'))
session.commit()
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/session.py", line 617, in commit
self.transaction.commit()
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/session.py", line 293, in commit
self._prepare_impl()
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/session.py", line 277, in _prepare_impl
self.session.flush()
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/session.py", line 1473, in flush
self._flush(objects)
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/session.py", line 1542, in _flush
flush_context.execute()
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/unitofwork.py", line 327, in execute
rec.execute(self)
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/unitofwork.py", line 471, in execute
uow
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/mapper.py", line 1870, in _save_obj
for state in _sort_states(states):
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1-
py3.2.egg/sqlalchemy/orm/mapper.py", line 2808, in _sort_states
return sorted(states, key=operator.attrgetter('sort_key'))
TypeError: unorderable types: str() < int()

Michael Bayer

unread,
Jul 20, 2011, 1:38:03 PM7/20/11
to sqlal...@googlegroups.com
Can I ask that you put a little more effort into providing context / mappings / specifics for this stack trace (see guidelines at http://www.sqlalchemy.org/support.html#mailinglist ) ? Clearly If I make a sample Opt() class with two fields and commit it, no such error occurs. There is some suggestion of inappropriate assignment of a string or int to an attribute which expects the opposite here.

> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>

ddarko

unread,
Jul 20, 2011, 1:46:37 PM7/20/11
to sqlalchemy
That is very strange. I am from a few hours struggling with this ...
stripped application on the first ...
There is nothing else.
Ordinary simple table. On it a select and an insert (with ORM, of
course).

Rest a while and try to prepare a complete test case. Unless I find a
solution on the way :]


On Jul 20, 7:38 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> Can I ask that you put a little more effort into providing context / mappings / specifics for this stack trace (see guidelines athttp://www.sqlalchemy.org/support.html#mailinglist) ?  Clearly If I make a sample Opt() class with two fields and commit it, no such error occurs.  There is some suggestion of inappropriate assignment of a string or int to an attribute which expects the opposite here.

ddarko

unread,
Jul 22, 2011, 9:19:35 AM7/22/11
to sqlalchemy
To reproduce the error is needed:
Python 3.2.0
SqlAlchemy 0.7.1
I use PostgreSQL 8.4 + psycopg2 2.4.2 but I think it does not matter.

Contents of the table in the database before running the script. This
is important.

test2=# SELECT * from fl_opts ;
key | value
-----+-------
b | 3
(1 row)

If the table is empty, everything works fine.
However, if in the course of one transaction are trying to make
modifications and add a record appears in an error described earlier.

Test script: http://pastebin.com/vNPGm0j1

Michael Bayer

unread,
Jul 22, 2011, 10:13:01 AM7/22/11
to sqlal...@googlegroups.com
thanks. this is ticket #2228, issue is only in Python 3 if you want to stay on 2 for now, patch is attached in the meantime before the ticket is fixed.

2228.patch

ddarko

unread,
Jul 22, 2011, 10:15:55 AM7/22/11
to sqlalchemy
THX

On Jul 22, 4:13 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> thanks.  this is ticket #2228, issue is only in Python 3 if you want to stay on 2 for now, patch is attached in the meantime before the ticket is fixed.
>
>  2228.patch
> 1KViewDownload
Reply all
Reply to author
Forward
0 new messages