Feature: disable individual timestamps - #23
Open
circulon wants to merge 6 commits into
Open
Conversation
Allows the ‘date_created_at’ or ‘date_updated_at’ columns to be disabled individually per model. Throws an AttributeError if timestamps (__timestamps__ = True) and both the ‘date_xxx_at’ attribuses are not set
fix altercolumn was adding length even if not set also fixed premapped defaults ignored on altered columns eg “current”, now
use @classmethod instead of @staticmethod for stubs added docstrings to stubs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently when using automatic timestamps it an all or nothing scenario on the Model.
this means that if you want a single timestamp eg
craeted_atyou must add the column to the migration and the model.The use case is that some tables like log history only need a craeted attribute and this simplifies things considerably
This PR addresses the following:
In Migrations
.timestamps(created=False)or.timestamps(updated=False)Falsean Exception is thrown.timestamps(created="created_on", updated="updated_on")I the Model
date_created_at = Falseordate_updated_at = False__timestamps__ = Trueand both thedate_xxx_atattributes are empty then an AttributeError is thrown notinfying the userdate_created_at = "created_on"ordate_updated_at = "updated_on"then aligns with the migrationAdditional:
premapped_defaultsif they were used generating possibly invalid sqlThis also addresses the postgres alter timestamp issue in #19