It's still a little hard to say, what's going on

Added in required attribute and duplicate attribute error checks,
pending reconstruction of the sql.requiredAttr() function