98
98
any other kind of SQL expression other than a :class:`.Column`,
99
99
the attribute will refer to the :attr:`.MapperProperty.info` dictionary
100
100
associated directly with the :class:`.ColumnProperty`, assuming the SQL
101
expression itself does not have it's own ``.info`` attribute
101
expression itself does not have its own ``.info`` attribute
102
102
(which should be the case, unless a user-defined SQL construct
103
103
has defined one).
532
532
def get_history(self, state, dict_, passive=PASSIVE_OFF):
533
533
raise NotImplementedError()
535
def get_all_pending(self, state, dict_):
535
def get_all_pending(self, state, dict_, passive=PASSIVE_NO_INITIALIZE):
536
536
"""Return a list of tuples of (state, obj)
537
537
for all objects in this attribute's current state
568
568
# if history present, don't load
570
570
if key not in state.committed_state or \
571
state.committed_state[key] is NEVER_SET:
571
state.committed_state[key] is NEVER_SET:
572
572
if not passive & CALLABLES_OK:
573
573
return PASSIVE_NO_RESULT
738
738
return History.from_object_attribute(self, state, current)
740
def get_all_pending(self, state, dict_):
740
def get_all_pending(self, state, dict_, passive=PASSIVE_NO_INITIALIZE):
741
741
if self.key in dict_:
742
742
current = dict_[self.key]
743
if current is not None:
744
ret = [(instance_state(current), current)]
748
if self.key in state.committed_state:
749
original = state.committed_state[self.key]
750
if original not in (NEVER_SET, PASSIVE_NO_RESULT, None) and \
743
elif passive & CALLABLES_OK:
744
current = self.get(state, dict_, passive=passive)
748
# can't use __hash__(), can't use __eq__() here
749
if current is not None and \
750
current is not PASSIVE_NO_RESULT and \
751
current is not NEVER_SET:
752
ret = [(instance_state(current), current)]
756
if self.key in state.committed_state:
757
original = state.committed_state[self.key]
758
if original is not None and \
759
original is not PASSIVE_NO_RESULT and \
760
original is not NEVER_SET and \
751
761
original is not current:
753
ret.append((instance_state(original), original))
763
ret.append((instance_state(original), original))
758
766
def set(self, state, dict_, value, initiator,
759
767
passive=PASSIVE_OFF, check_old=None, pop=False):
763
771
if self.dispatch._active_history:
764
772
old = self.get(state, dict_, passive=PASSIVE_ONLY_PERSISTENT | NO_AUTOFLUSH)
774
# would like to call with PASSIVE_NO_FETCH ^ INIT_OK. However,
775
# we have a long-standing behavior that a "get()" on never set
776
# should implicitly set the value to None. Leaving INIT_OK
777
# set here means we are consistent whether or not we did a get
779
# see test_use_object_set_None vs. test_use_object_get_first_set_None
780
# in test_attributes.py
766
781
old = self.get(state, dict_, passive=PASSIVE_NO_FETCH)
768
783
if check_old is not None and \
793
809
def fire_replace_event(self, state, dict_, value, previous, initiator):
794
810
if self.trackparent:
795
811
if (previous is not value and
796
previous is not None and
797
previous is not PASSIVE_NO_RESULT):
812
previous not in (None, PASSIVE_NO_RESULT, NEVER_SET)):
798
813
self.sethasparent(instance_state(previous), state, False)
800
815
for fn in self.dispatch.set:
853
868
return History.from_collection(self, state, current)
855
def get_all_pending(self, state, dict_):
870
def get_all_pending(self, state, dict_, passive=PASSIVE_NO_INITIALIZE):
871
# NOTE: passive is ignored here at the moment
856
873
if self.key not in dict_:
1080
1097
def emit_backref_from_scalar_set_event(state, child, oldchild, initiator):
1081
1098
if oldchild is child:
1083
if oldchild is not None and oldchild is not PASSIVE_NO_RESULT:
1100
if oldchild is not None and \
1101
oldchild is not PASSIVE_NO_RESULT and \
1102
oldchild is not NEVER_SET:
1084
1103
# With lazy=None, there's no guarantee that the full collection is
1085
1104
# present when updating via a backref.
1086
1105
old_state, old_dict = instance_state(oldchild),\