Database\Table: fixed saving cache for toArray() calls. [closes #1332]

Tests needed. However, it's impossible to do them before implementing #1081.