def _get_fields(self, table_name, **kwargs):
ret = {}<EOL>query_str = '<STR_LIT>'.format(self._normalize_table_name(table_name))<EOL>fields = self._query(query_str, **kwargs)<EOL>query_str = '<STR_LIT>'.format(self._normalize_table_name(table_name))<EOL>fks = {f["<STR_LIT>"]: f for f in self._query(query_str, **kwargs)}<EOL>pg_types = {<EOL>"<STR_LIT>": int,<EOL>"<STR_LIT>": long,<EOL>"<STR_LIT>": float,<EOL>"<STR_LIT>": float,<EOL>"<STR_LIT>": float,<EOL>"<STR_LIT>": decimal.Decimal,<EOL>"<STR_LIT>": bool,<EOL>"<STR_LIT>": datetime.date,<EOL>"<STR_LIT>": datetime.datetime,<EOL>"<STR_LIT>": str,<EOL>"<STR_LIT>": str,<EOL>"<STR_LIT>": str,<EOL>"<STR_LIT>": bytearray,<EOL>}<EOL>for row in fields:<EOL><INDENT>field = {<EOL>"<STR_LIT:name>": row["<STR_LIT:name>"],<EOL>"<STR_LIT>": bool(row["<STR_LIT>"]) or bool(row["<STR_LIT>"]),<EOL>"<STR_LIT>": bool(row["<STR_LIT>"]),<EOL>}<EOL>for tname, ty in pg_types.items():<EOL><INDENT>if row["<STR_LIT:type>"].startswith(tname):<EOL><INDENT>field["<STR_LIT>"] = ty<EOL>break<EOL><DEDENT><DEDENT>if field["<STR_LIT>"] and field["<STR_LIT>"] is int:<EOL><INDENT>field["<STR_LIT>"] = long<EOL><DEDENT>if row["<STR_LIT:name>"] in fks:<EOL><INDENT>field["<STR_LIT>"] = fks[row["<STR_LIT:name>"]]["<STR_LIT>"]<EOL>field["<STR_LIT>"] = fks[row["<STR_LIT:name>"]]["<STR_LIT>"]<EOL><DEDENT>ret[field["<STR_LIT:name>"]] = field<EOL><DEDENT>return ret<EOL>
return all the fields for the given table