On Monday, April 9, 2018 at 2:43:13 PM UTC-7, Matthew Curtice wrote: > > I can't tell if this is a bug, or if I'm missing a work-around somewhere.. > > I am using Sequel to interact with a Hive2 database. I have a jdbc driver > and have created an adapter that I've gotten to work with all the methods > I've tried so far. (The existing hive gem on rubygems is too old, and > unfortunately my company does not allow us to make pull requests to > contribute back to the community :( ) I am now trying to create a Model > for the table so that I can use FactoryBot to insert data. > > Sequel::Model.use_transactions = false > > class Table_1 < Sequel::Model($hive_db[:table_1]) > set_primary_key [:id] > end > > FactoryBot.define do > factory :table_1, class: Table_1 do > sequence(:id) {|id| id} > name 'John Smith' > end > end > > > > When I try to require the model, I get: > > > E, [2018-04-09T17:12:05.149000 #119768] ERROR -- : > Java::OrgApacheHiveServiceCli::HiveSQLException: Error while compiling > statement: FAILED: ParseException line 1:0 cannot recognize input near > 'BEGIN' '<EOF>' '<EOF>': BEGIN > E, [2018-04-09T17:12:05.164000 #119768] ERROR -- : > Java::OrgApacheHiveServiceCli::HiveSQLException: Error while compiling > statement: FAILED: ParseException line 1:0 cannot recognize input near > 'ROLLBACK' '<EOF>' '<EOF>': ROLLBACK > > From digging into the Sequel Code, it seems that the function get_db_schema > uses a couple of different methods to define the schema for the model, but > all of these methods use check_non_connection_error. > check_non_connection_error uses db.transaction(:savepoint=>:only){yield} even > though I set use_transactions to false. I tried to dig further into the > transaction methods, but could see no where else where it honors my request > to use transactions.. > > I believe that instead, check_non_connection_error should be using the > checked_transaction function? or is there another option I'm missing? > > If your database doesn't support transactions, you probably want to do:
def $hive_db.transaction(*) yield end The use_transactions model setting only affects transactions used when saving/deleting records. This is explained in the documentation for the setting. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to sequel-talk+unsubscr...@googlegroups.com. To post to this group, send email to sequel-talk@googlegroups.com. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.