File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -140,9 +140,18 @@ def get_or_create_db_entry(
140140 conditions = [
141141 getattr (table , key ) == value for key , value in lookup_kwargs .items ()
142142 ]
143- entry = (
144- session .execute (select (table ).where (and_ (* conditions ))).scalars ().first ()
145- )
143+ # Use 'exec()' for SQLModel sessions
144+ if isinstance (session , SQLModelSession ):
145+ entry = session .exec (select (table ).where (and_ (* conditions ))).first ()
146+ # Use 'execute()' for SQLAlchemy sessions
147+ elif isinstance (session , SQLAlchemySession ):
148+ entry = (
149+ session .execute (select (table ).where (and_ (* conditions )))
150+ .scalars ()
151+ .first ()
152+ )
153+ else :
154+ raise TypeError ("Unexpected Session type" )
146155 if entry :
147156 return entry
148157
You can’t perform that action at this time.
0 commit comments