You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has been bugging me for a while, but I only decided to look into this today.
I'm trying to insert a row into a table where the PK is a date. In my original schema, I had not defined autoincrement=False against this PK.
As a result, in get_lastrowid() in base.py, the first check autoincrement_pk_columns includes the PK column, so the return None is not executed at this stage. So, the function then goes on to find the column_identity column from exa_all_columns, which comes back Null.
As a result, the int(...) call is calling Null, and the exception is thrown.
The quick fix is to add a check of result[0] is None, and if so either throw a warning or error so that it's clear what the issue is, or ignore it and return None.
session.commit()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/session.py", line 921, in commit
self.transaction.commit()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/session.py", line 461, in commit
self._prepare_impl()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
self.session.flush()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/session.py", line 2192, in flush
self._flush(objects)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/session.py", line 2312, in _flush
transaction.rollback(_capture_exception=True)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/util/compat.py", line 187, in reraise
raise value
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/session.py", line 2276, in _flush
flush_context.execute()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/unitofwork.py", line 389, in execute
rec.execute(self)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/unitofwork.py", line 548, in execute
uow
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
mapper, table, insert)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/persistence.py", line 799, in _emit_insert_statements
execute(statement, multiparams)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", line 945, in execute
return meth(self, multiparams, params)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", line 1202, in _execute_context
result = context._setup_crud_result_proxy()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/default.py", line 896, in _setup_crud_result_proxy
self._setup_ins_pk_from_lastrowid()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/default.py", line 932, in _setup_ins_pk_from_lastrowid
lastrowid = self.get_lastrowid()
File "/usr/local/lib/python3.4/dist-packages/sqlalchemy_exasol/base.py", line 327, in get_lastrowid
return int(result[0]) - 1
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
The text was updated successfully, but these errors were encountered:
Thank you for digging out the details and root cause of your issue.
From what you write, throwing an exception sounds like a meaningful way to let the developer know what is going on (e.g. missing PK column).
Would you like to provide a pull request that fixes this issue for inclusion in next release?
Hi
This has been bugging me for a while, but I only decided to look into this today.
I'm trying to insert a row into a table where the PK is a date. In my original schema, I had not defined autoincrement=False against this PK.
As a result, in get_lastrowid() in base.py, the first check autoincrement_pk_columns includes the PK column, so the return None is not executed at this stage. So, the function then goes on to find the column_identity column from exa_all_columns, which comes back Null.
As a result, the int(...) call is calling Null, and the exception is thrown.
The quick fix is to add a check of result[0] is None, and if so either throw a warning or error so that it's clear what the issue is, or ignore it and return None.
The text was updated successfully, but these errors were encountered: