@@ -56,8 +56,9 @@ def __init__(self,dbConnection):
56
56
def creationFieldsStr ():
57
57
outStr = ''
58
58
for fieldName ,fieldValue in self ._entFields .items ():
59
- outStr = + '%s %s,' % (str (fieldName ),str (fieldValue ))
60
- return outStr
59
+ outStr += '%s %s,' % (str (fieldName ),str (fieldValue ))
60
+ return outStr [:- 1 ]
61
+
61
62
def addTableField (fieldName ,fieldType ):
62
63
sql = "ALTER TABLE pycadent ADD COLUMN %s %s " % (str (fieldName ),str (fieldType ))
63
64
self .makeUpdateInsert (sql )
@@ -71,16 +72,16 @@ def addTableField(fieldName,fieldType):
71
72
if _table is None :
72
73
_sqlCreation = """CREATE TABLE pycadent(
73
74
%s)""" % creationFieldsStr ()
75
+ self .__revisionIndex = 0
76
+ self .makeUpdateInsert (_sqlCreation )
74
77
else :
75
78
rows = self .makeSelect ("pragma table_info('pycadent')" )
76
79
dbColumns = dict ([(row [1 ],row [2 ]) for row in rows ])
77
80
for classColumn in self ._entFields .keys ():
78
81
if not classColumn in dbColumns :
79
82
addTableField (classColumn ,self ._entFields [classColumn ])
80
-
81
-
82
- self .__revisionIndex = self .getRevisionIndex ()
83
-
83
+ self .__revisionIndex = self .getRevisionIndex ()
84
+
84
85
def getRevisionIndex (self ):
85
86
"""
86
87
get the revision index from the database
0 commit comments