Show More
@@ -1374,9 +1374,14 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) | |
|
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] | |||
1380 |
|
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() |
General Comments 0
You need to be logged in to leave comments.
Login now