This repository was archived by the owner on Sep 12, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
docker_registry/lib/index Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,10 @@ class Repository (Base):
32
32
33
33
id = sqlalchemy .Column (sqlalchemy .Integer , primary_key = True )
34
34
name = sqlalchemy .Column (
35
- sqlalchemy .String , nullable = False , unique = True )
36
- description = sqlalchemy .Column (sqlalchemy .String )
35
+ sqlalchemy .String (length = 30 + 1 + 64 ), # namespace / respository
36
+ nullable = False , unique = True )
37
+ description = sqlalchemy .Column (
38
+ sqlalchemy .String (length = 100 ))
37
39
38
40
def __repr__ (self ):
39
41
return "<{0}(name='{1}', description='{2}')>" .format (
@@ -61,10 +63,10 @@ def __init__(self, database=None):
61
63
62
64
def _setup_database (self ):
63
65
session = self ._session ()
64
- try :
66
+ if self . _engine . has_table ( table_name = Version . __tablename__ ) :
65
67
version = session .query (
66
68
sqlalchemy .sql .functions .max (Version .id )).first ()[0 ]
67
- except sqlalchemy . exc . OperationalError :
69
+ else :
68
70
version = None
69
71
if version :
70
72
if version != self .version :
Original file line number Diff line number Diff line change @@ -28,8 +28,9 @@ class TestSQLAlchemyIndex(unittest.TestCase):
28
28
def setUp (self ):
29
29
self .index = db .SQLAlchemyIndex (database = "sqlite://" )
30
30
31
+ @mock .patch ('sqlalchemy.engine.Engine.has_table' , return_value = True )
31
32
@mock .patch ('sqlalchemy.orm.query.Query.first' )
32
- def test_setup_database (self , first ):
33
+ def test_setup_database (self , first , has_table ):
33
34
first = mock .Mock ( # noqa
34
35
side_effect = db .sqlalchemy .exc .OperationalError )
35
36
self .assertRaises (
You can’t perform that action at this time.
0 commit comments