feat(database): improve pg array conversion (fixes #2761)