Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amotl opened this issue Dec 9, 2022 · 0 comments
Open

Comments

@amotl
Copy link
Member

amotl commented Dec 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant