Ejemplo n.º 1
0
 def typeDef(self, name):
     schema = Schema()
     if self.lex.matchKeyword('int'):
         self.lex.eatKeyword('int')
         if self.checkPrimaryKey():
             schema.setPrimaryKey(name)
         schema.addField(name, {'type':'int','length': 0 })
     else:
         self.lex.eatKeyword('varchar')
         self.lex.eatDelim('(')
         num = self.lex.eatNum()
         if num > self.maxVarcharLen or num <= 0:
             raise RuntimeError('Invalid varchar length.')
         self.lex.eatDelim(')')
         if self.checkPrimaryKey():
             schema.setPrimaryKey(name)
         schema.addField(name, {'type':'char', 'length': num})
     
     return schema