Key value schema join construction error

illegal sql was generated when the ruby object name is different from the table name.
The issue is now fixed and a test was added.