fix(gallery): fixed broken sql queries