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 @@ -715,16 +715,18 @@ def ensure_adaptor_properties(
715
715
) -> None :
716
716
"""Create adaptor properties (if not exists) or update its timestamp."""
717
717
try :
718
+ adaptor_properties = AdaptorProperties (hash = hash , config = config , form = form )
719
+ session .add (adaptor_properties )
720
+ session .commit ()
721
+ except sa .exc .IntegrityError : # hash already present
722
+ session .rollback ()
718
723
statement = (
719
724
AdaptorProperties .__table__ .update ()
720
- .returning (AdaptorProperties .hash )
721
725
.where (AdaptorProperties .__table__ .c .hash == hash )
722
726
.values (timestamp = datetime .datetime .now ())
723
727
)
724
- session .execute (statement ).one ()
725
- except sqlalchemy .orm .exc .NoResultFound :
726
- adaptor_properties = AdaptorProperties (hash = hash , config = config , form = form )
727
- session .add (adaptor_properties )
728
+ session .execute (statement )
729
+ session .commit ()
728
730
729
731
730
732
def add_event (
You can’t perform that action at this time.
0 commit comments