I do automated testing of a large system, I need to validate many tables at different databases. I'm thinking of using Active Record, but all the examples I've seen in research show that the tables to use are mapped first and used as model. Is there any way to use active record without mapping? if so which ones? I am currently using OCI8
If for a simple validation of this I map each table will be very time consuming, are the winnings really so high?
I'm not an expert in Active Records but I see what you're trying to do. After a quick search I don't find any mention of ways to make queries on "unmapped" tables in Active Records.
If you have the ability to pick your gems, I think that Sequel would be a good fit for your needs. You don't need to map anything to get started, because the database schema is parsed by Sequel itself.
Let's say if you have 3 tables stuff_1
, stuff_2
, and foo
you can simply access them and do some queries without declaring anything in your code, like that:
DB[:stuff_1].where(:is_cool => true, :group => "test").each do |stuff_1|
# stuff_1 is a hash containing the information of the row, indexed by the table column names
end
DB[:stuff_2].where(:is_archived => true).count
DB[:foo].all
Sequel calls that datasets, and this is very flexible. More information on datasets here: http://sequel.jeremyevans.net/rdoc/files/doc/dataset_basics_rdoc.html
Full Sequel documentation: http://sequel.jeremyevans.net/documentation.html