Skip to content

Commit aabe5b9

Browse files
authored
Fix #1327 OAuth module: SQLAlchemy v2 compatibility (#1335)
1 parent 8dc50a8 commit aabe5b9

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def run(self):
337337
# used only under slack_sdk/*_store
338338
"boto3<=2",
339339
# InstallationStore/OAuthStateStore
340-
"SQLAlchemy>=1,<2",
340+
"SQLAlchemy>=1,<3",
341341
# Socket Mode
342342
# websockets 9 is not compatible with Python 3.10
343343
"websockets>=10,<11" if sys.version_info.minor > 6 else "websockets>=9.1,<10",

slack_sdk/oauth/installation_store/sqlalchemy/__init__.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def save(self, installation: Installation):
140140

141141
i_column = self.installations.c
142142
installations_rows = conn.execute(
143-
sqlalchemy.select([i_column.id])
143+
sqlalchemy.select(i_column.id)
144144
.where(
145145
and_(
146146
i_column.client_id == self.client_id,
@@ -152,7 +152,7 @@ def save(self, installation: Installation):
152152
.limit(1)
153153
)
154154
installations_row_id: Optional[str] = None
155-
for row in installations_rows:
155+
for row in installations_rows.mappings():
156156
installations_row_id = row["id"]
157157
if installations_row_id is None:
158158
conn.execute(self.installations.insert(), i)
@@ -171,7 +171,7 @@ def save_bot(self, bot: Bot):
171171

172172
b_column = self.bots.c
173173
bots_rows = conn.execute(
174-
sqlalchemy.select([b_column.id])
174+
sqlalchemy.select(b_column.id)
175175
.where(
176176
and_(
177177
b_column.client_id == self.client_id,
@@ -183,7 +183,7 @@ def save_bot(self, bot: Bot):
183183
.limit(1)
184184
)
185185
bots_row_id: Optional[str] = None
186-
for row in bots_rows:
186+
for row in bots_rows.mappings():
187187
bots_row_id = row["id"]
188188
if bots_row_id is None:
189189
conn.execute(self.bots.insert(), b)
@@ -217,7 +217,7 @@ def find_bot(
217217

218218
with self.engine.connect() as conn:
219219
result: object = conn.execute(query)
220-
for row in result: # type: ignore
220+
for row in result.mappings(): # type: ignore
221221
return Bot(
222222
app_id=row["app_id"],
223223
enterprise_id=row["enterprise_id"],
@@ -261,7 +261,7 @@ def find_installation(
261261
installation: Optional[Installation] = None
262262
with self.engine.connect() as conn:
263263
result: object = conn.execute(query)
264-
for row in result: # type: ignore
264+
for row in result.mappings(): # type: ignore
265265
installation = Installation(
266266
app_id=row["app_id"],
267267
enterprise_id=row["enterprise_id"],
@@ -302,7 +302,7 @@ def find_installation(
302302
query = self.installations.select().where(where_clause).order_by(desc(c.installed_at)).limit(1)
303303
with self.engine.connect() as conn:
304304
result: object = conn.execute(query)
305-
for row in result: # type: ignore
305+
for row in result.mappings(): # type: ignore
306306
installation.bot_token = row["bot_token"]
307307
installation.bot_id = row["bot_id"]
308308
installation.bot_user_id = row["bot_user_id"]

slack_sdk/oauth/state_store/sqlalchemy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def consume(self, state: str) -> bool:
6464
c = self.oauth_states.c
6565
query = self.oauth_states.select().where(and_(c.state == state, c.expire_at > datetime.utcnow()))
6666
result = conn.execute(query)
67-
for row in result:
67+
for row in result.mappings():
6868
self.logger.debug(f"consume's query result: {row}")
6969
conn.execute(self.oauth_states.delete().where(c.id == row["id"]))
7070
return True

0 commit comments

Comments
 (0)