code: def field_default(colx, table_name, tables_dict):
    "takes sqparse2.ColX, Table"
    if colx.coltp.type.lower() == 'serial':
      x = sqparse2.parse('select coalesce(max(%s),-1)+1 from %s' % (colx.name, table_name))
      return sqex.run_select(x, tables_dict, Table)[0]
    elif colx.not_null: raise NotImplementedError('todo: not_null error')
    else: return toliteral(colx.defaultf field_default(colx, table_name, tables_dict):
    "takes sqparse2.ColX, Table"
    if colx.coltp.type.lower() == 'serial':
      x = sqparse2.parse('select coalesce(max(%s),-1)+1 from %s' % (colx.name, table_name))
      return sqex.run_select(x, tables_dict, Table)[0]
    elif colx.not_null: raise NotImplementedError('todo: not_null error')
    else: return toliteral(colx.default)
docs: takes sqparse2.ColX, Table