I have a problem merging a polymorphic persistent object. Please read my description of the problem below. Sorry if it's a little complex.
I've got a polymorphic mapper defined as so: sqlalchemy.orm.mapper(Generic, generics_table, polymorphic_on=generics_table.c.type, polymorphic_identity='generic') sqlalchemy.orm.mapper(Specific, specifics_table, inherits=Generic, polymorphic_identity='specific') I query a Specific instance like this: specific = session.query(Generic).get(specific_key) The attributes stored in 'specifics_table' are not loaded from the DB until they are accessed (lazy-loaded). I serialize the Specific instance and send it to the client without lazy-loading the 'specifics_table' attributes. The client alters the Specific instance and sends it back to the server to save. The de-serialized Specific instance is of type Specific, but does not have any attributes from 'specifics_table' (since they were never loaded from the DB). I use merge to save the altered Specific instance that came from the client: merged_obj = session.merge(specific) session.commit() In versions prior to 0.5.0 this data flow worked fine. After upgrading to 0.5.0 I get an exception with the following trace. It looks like SA is trying to update the sub-class, but there aren't any attributes to update, since all sub-class specific attributes are missing from the object, so it is generating bad SQL. Is this a bug, or do I need to change something to be compatible with 0.5.0? Error: ProgrammingError - - Description: (ProgrammingError) syntax error at or near "WHERE" at character 34 'UPDATE specifics_table SET WHERE specifics_table.generic_id = %(specifics_table_generic_id)s' {'specifics_table_generic_id': 2} - - Traceback: File "app.py", ...app trace cut for brevity... session.flush() - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/session.py", line 1349, in flush self._flush(objects) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/session.py", line 1419, in _flush flush_context.execute() - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/unitofwork.py", line 260, in execute UOWExecutor().execute(self, tasks) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/unitofwork.py", line 723, in execute self.execute_save_steps(trans, task) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/unitofwork.py", line 738, in execute_save_steps self.save_objects(trans, task) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/unitofwork.py", line 729, in save_objects task.mapper._save_obj(task.polymorphic_tosave_objects, trans) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/orm/mapper.py", line 1358, in _save_obj c = connection.execute(statement.values(value_params), params) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/engine/base.py", line 824, in execute return Connection.executors[c](self, object, multiparams, params) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/engine/base.py", line 874, in _execute_clauseelement return self.__execute_context(context) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/engine/base.py", line 896, in __execute_context self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/engine/base.py", line 950, in _cursor_execute self._handle_dbapi_exception(e, statement, parameters, cursor, context) - File "/usr/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0-py2.5.egg/ sqlalchemy/engine/base.py", line 931, in _handle_dbapi_exception raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) Any help would be greatly appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---