File tree 1 file changed +7
-5
lines changed 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -734,16 +734,18 @@ def ensure_adaptor_properties(
734
734
) -> None :
735
735
"""Create adaptor properties (if not exists) or update its timestamp."""
736
736
try :
737
+ adaptor_properties = AdaptorProperties (hash = hash , config = config , form = form )
738
+ session .add (adaptor_properties )
739
+ session .commit ()
740
+ except sa .exc .IntegrityError : # hash already present
741
+ session .rollback ()
737
742
statement = (
738
743
AdaptorProperties .__table__ .update ()
739
- .returning (AdaptorProperties .hash )
740
744
.where (AdaptorProperties .__table__ .c .hash == hash )
741
745
.values (timestamp = datetime .datetime .now ())
742
746
)
743
- session .execute (statement ).one ()
744
- except sqlalchemy .orm .exc .NoResultFound :
745
- adaptor_properties = AdaptorProperties (hash = hash , config = config , form = form )
746
- session .add (adaptor_properties )
747
+ session .execute (statement )
748
+ session .commit ()
747
749
748
750
749
751
def add_event (
You can’t perform that action at this time.
0 commit comments