Show More
@@ -1374,10 +1374,15 b' class Repository(Base, BaseModel):' | |||||
1374 | @classmethod |
|
1374 | @classmethod | |
1375 | def get_by_repo_name(cls, repo_name): |
|
1375 | def get_by_repo_name(cls, repo_name): | |
1376 | session = Session() |
|
1376 | session = Session() | |
|
1377 | exist_in_session = [] | |||
1377 | for (item_cls, pkey), instance in session.identity_map.items(): |
|
1378 | for (item_cls, pkey), instance in session.identity_map.items(): | |
1378 | if cls == item_cls and instance.repo_name == repo_name: |
|
1379 | if cls == item_cls and instance.repo_name == repo_name: | |
1379 |
|
|
1380 | exist_in_session.append(instance) | |
1380 |
|
1381 | if exist_in_session: | ||
|
1382 | if len(exist_in_session) > 1: | |||
|
1383 | raise Exception('2 same name repos in session') | |||
|
1384 | return exist_in_session[0] | |||
|
1385 | ||||
1381 | q = session.query(cls).filter(cls.repo_name == repo_name) |
|
1386 | q = session.query(cls).filter(cls.repo_name == repo_name) | |
1382 | return q.scalar() |
|
1387 | return q.scalar() | |
1383 |
|
1388 |
General Comments 0
You need to be logged in to leave comments.
Login now