|
|
|
@ -11,7 +11,7 @@ from ub import config
|
|
|
|
|
import ub
|
|
|
|
|
|
|
|
|
|
session = None
|
|
|
|
|
cc_exceptions = ['datetime', 'int', 'comments', 'float', 'composite', 'series']
|
|
|
|
|
cc_exceptions = ['datetime', 'comments', 'float', 'composite', 'series']
|
|
|
|
|
cc_classes = None
|
|
|
|
|
engine = None
|
|
|
|
|
|
|
|
|
@ -335,11 +335,18 @@ def setup_db():
|
|
|
|
|
primary_key=True)
|
|
|
|
|
)
|
|
|
|
|
cc_ids.append([row.id, row.datatype])
|
|
|
|
|
import sys
|
|
|
|
|
print >>sys.stderr,row.datatype
|
|
|
|
|
if row.datatype == 'bool':
|
|
|
|
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
|
'book': Column(Integer, ForeignKey('books.id')),
|
|
|
|
|
'value': Column(Boolean)}
|
|
|
|
|
elif row.datatype == 'int':
|
|
|
|
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
|
'book': Column(Integer, ForeignKey('books.id')),
|
|
|
|
|
'value': Column(Integer)}
|
|
|
|
|
else:
|
|
|
|
|
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
|
|
|
|
|
'id': Column(Integer, primary_key=True),
|
|
|
|
@ -347,7 +354,7 @@ def setup_db():
|
|
|
|
|
cc_classes[row.id] = type('Custom_Column_' + str(row.id), (Base,), ccdict)
|
|
|
|
|
|
|
|
|
|
for cc_id in cc_ids:
|
|
|
|
|
if cc_id[1] == 'bool':
|
|
|
|
|
if (cc_id[1] == 'bool') or (cc_id[1] == 'int'):
|
|
|
|
|
setattr(Books, 'custom_column_' + str(cc_id[0]), relationship(cc_classes[cc_id[0]],
|
|
|
|
|
primaryjoin=(
|
|
|
|
|
Books.id == cc_classes[cc_id[0]].book),
|
|
|
|
|