Attempt to fix dbjoin/CDD as repeatelement in joined group

http://fabrikar.com/forums/index.php?threads/problem-in-multi-select-dropdown-in-cascadingdropdwon-under-repeat-group.36065/

Did I really find a solution? This time for databasejoin only. 

Generally it seems to working fine. Except 2 bugs (not sure is it caused by my fix or by something else):

1) I can't delete the single repeat group when min repeats is not set. 
When I set min repeats to 0 then I can do it (group is deleted) but I receive also a message:
Unknown column 'Array' in 'where clause' SQL=DELETE FROM chb_test_2013_repeat_checkboxes_2013 WHERE parent_id = Array

2) Another, not very important bug - in new repeat group the same checkboxes are checked as in the first group. Unchecking them, checking needed boxes and saving it - all works. 

TODO - same solution for fileupload element