crate / crate/sqlalchemy-cratedb
SQLAlchemy: Investigate different ways to set default values for columns
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- Avg merge
- 6d 12h
- Merged PRs (30d)
- 3
Description
### Introduction
[Setting eager defaults for SQLAlchemy ORM models] has a sweet summary about different ways to set default values for columns within SQLAlchemy schema definitions.
> SQLAlchemy allows for a whole host of different defaults, but briefly summarized, these are broadly what are accepted:
>
> - Constant values. Strings, booleans, containers, or any value object
> - SQL expressions. That are executed during flush (e.g. sqlalchemy.func.now())
> - Python callables. These can be of two kinds: simple argument-less functions, or ones that are context sensitive, meaning they accept an execution context, which allows access to other columns’ values and various other bits.
The complete reference documentation is available at [SQLAlchemy: Column INSERT/UPDATE defaults].
### References
- crate/crate-python#448
- crate/sqlalchemy-cratedb#106
- crate/crate-python#464
### Thoughts
We may want to check if all variants are supported by the CrateDB SQLAlchemy dialect implementation, and if all variants are documented properly.
[Setting eager defaults for SQLAlchemy ORM models]: https://variable-scope.com/posts/setting-eager-defaults-for-sqlalchemy-orm-models
[SQLAlchemy: Column INSERT/UPDATE defaults]: https://docs.sqlalchemy.org/en/14/core/defaults.html
/cc @hammerhead
Contributor guide
Assessment
This issue has not been assessed yet.