crate / sqlalchemy-cratedb

SQLAlchemy dialect for CrateDB.
https://cratedb.com/docs/sqlalchemy-cratedb/
Apache License 2.0
3 stars 2 forks source link

SQLAlchemy: Investigate different ways to set default values for columns #87

Open amotl opened 1 year ago

amotl commented 1 year ago

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

Thoughts

We may want to check if all variants are supported by the CrateDB SQLAlchemy dialect implementation, and if all variants are documented properly.

/cc @hammerhead