- changed status to resolved
Possible column name collision
Issue #133
resolved
It looks like sqlalchemy gets confused by columns named "something" and "<table_name>_something".
Traceback
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/objectstore.py", line 244, in commit
get_session().commit(*obj)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/objectstore.py", line 157, in commit
self._commit_uow()
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/objectstore.py", line 140, in _commit_uow
self.uow.commit(*obj)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/unitofwork.py", line 236, in commit
commit_context.execute(echo=echo_commit)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/unitofwork.py", line 353, in execute
head.execute(self)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/unitofwork.py", line 507, in execute
self.mapper.save_obj(self.tosave_objects(), trans)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/mapping/mapper.py", line 666, in save_obj
c = statement.execute(params)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/sql.py", line 436, in execute
return c.execute(*multiparams, **params)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/sql.py", line 330, in execute
return self.engine.execute_compiled(self, params)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/engine.py", line 645, in execute_compiled
proxy(str(compiled), parameters)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/engine.py", line 640, in proxy self.execute(statement, parameters, connection=connection, cursor=cursor, return_raw=True)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/engine.py", line 689, in execute
self._executemany(cursor, statement, parameters)
File "/home/jonas/src/sqlalchemy/lib/sqlalchemy/engine.py", line 715, in _executemany
c.executemany(statement, parameters)
pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 1 supplied.
>
Test Case
from sqlalchemy import *
foo = Table('foo',
Column('id', Integer, primary_key=True),
Column('foo_id', Integer))
class Foo(object):
pass
assign_mapper(Foo, foo)
global_connect('sqlite://', echo=True)
foo.create()
f = Foo(foo_id=2)
objectstore.commit()
f.foo_id=3
objectstore.commit()
If I rename the column to "foo_id2" everything works as expected. I'm able to reproduce this with both version 0.1.4 and trunk@1212.
Comments (1)
-
repo owner - Log in to comment
yeah thats an unfortunate one, since its looking more like column labels should just be more aggressively unique in the first place (i.e.
#97)anyway I checked in the obvious fix which is to add "check for column named the same as the label" to the criterion for creating a randomized label, changeset:1213 , thanks for the catch.