Instance | Branch |
---|
- Assigning an object to a
belongs_to
association does not automatically save the object. It does not save the associated object either.
- When you assign an object to a
has_one
association, that object is automatically saved (in order to update its foreign key). - In addition, any object being replaced is also automatically saved, because its foreign key will change too
- If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
- If the parent object (the one declaring the
has_one
association) is unsaved (that is,new_record?
returns true) then the child objects are not saved. They will automatically when the parent object is saved.
This file contains 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
import logging | |
from airflow.models import DagBag | |
def callback_subdag_clear(context): | |
"""Clears a subdag's tasks on retry.""" | |
dag_id = "{}.{}".format( | |
context['dag'].dag_id, | |
context['ti'].task_id, | |
) | |
execution_date = context['execution_date'] |