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