Default timestamp value missing - func.now() not supported
enhancement
**Is your feature request related to a problem? Please describe.**
I use the sqlalchemy lib to support anyDB in my solution. So far sqlite and postgres support all used features.
Today I tested my code against a SAP HANA Cloud instance (created yesterday) and got the error "(hdbcli.dbapi.ProgrammingError) (257, 'sql syntax error: incorrect syntax near "now": line 13 col 30 (at pos 316)')".
The create table statement for the column was:
CREATE TABLE some_table (
uuid CHAR(32) NOT NULL,
...
created_at DATETIME DEFAULT now(),
...
PRIMARY KEY (uuid)
)
The syntax "now()" as default value is not supported?
**Describe the solution you'd like**
From the python perspective the column is defined as:
from sqlalchemy import Column, ...
from sqlalchemy.sql import func
Column(DateTime(timezone=True), server_default=func.now())
I think func.now() can be implemented for the SAP HANA dialect and set the accepted statement?
**Describe alternatives you've considered**
At the moment I will remove the default values from the model and set the now() value by my code. This is not the best solution...
**Additional context**
Not at the moment. Code examples should be enough? If not, call me.
Thanks for supporting us!
Best regards
Joerg
关闭于 2024-07-11 2 条评论