I have been using the AR JDBC Teradata adapter to load data into previously existing tables in my database. In some cases, these tables do not have a standard Auto-Incremented "ID" column. For example, we could have a "Posts" table that has a "post_id" primary key that is set manually by my script.
This adapter had been mostly working for me in these cases, but I found that I was hitting an Exception when loading data that contained a string that had more than three periods in it.
I dug into the code, and found what looks to be a bug - on line 140 of lib/arjdbc/teradata/adapter.rb, we are calling last_insert_id and passing it the complete SQL statement. This looks to be incorrect, as the last_insert_id method actually expects a table name. I found that using the _table_name_from_insert(sql) method resolved this and made my spec now properly pass.
After making this change I ran all of the existing specs and they all continue to pass.
Create a new test case wherein we have a table with no auto-increment…
…ed primary key. Fix bug in adapter code that looks up PK based on the SQL when it should be passing the table name
Thanks for merging this in! Will you be releasing an updated gem to rubygems at some point with this?