Fixed generating table with all fields selected

I need to fix this table generation code, but it's good enough for now.