Hi,all
I am developing a Rails application supporting both Mysql and Oracle. I have to use Native SQL statements some place. While we know the SQL grammar is quite different for Mysql and Oracle, so I have to get database adapter type programmatically in my codes to process different native SQL statements. I haven't found any document for this situation. After some research, I have found a way to do so like following:
if ActiveRecord::Base::connection.is_a? (ActiveRecord::ConnectionAdapters::OracleAdapter) {Process native Oracle SQL statements} else if ActiveRecord::Base::connection.is_a? (ActiveRecord::ConnectionAdapters::MysqlAdapter) {Process natvie Mysql SQL statements} end
After test, it works. But I am wondering if this is the best way to achieve my goal, or is there any other smarter way?
Thanks in advance!
Regards, Liming