On Nov 4, 6:26 pm, Sunny Hirai <[EMAIL PROTECTED]> wrote: > Thanks for the offer to help Jeremy. > > Okay, I've got it working in Sequel 2.6 but it is a little > inconsistent in the way I got it to work. Notably, I need to use > String#lit when calling Database#create_table, Database#drop_table or > Database#table_exists? on the Sequel::Database object but I need to > use Symbol#identifier when creating a dataset from a Database object.
There were a lot of improvements in 2.7 that may help, I would recommend trying that. > My working sample code looks like this: > > @raw_table_name = 'double__underscores' > > db = Sequel.connect( 'mysql://root:[EMAIL PROTECTED]/test' ) > db.drop_table @raw_table_name.lit if db.table_exists? > ( @raw_table_name.lit ) > db.create_table @raw_table_name.lit do > primary_key :id > column :name, :varchar > end > dataset = db[ @raw_table_name.to_sym.identifier ] > dataset.insert( :name => 'alpha' ) > dataset.insert( :name => 'bravo' ) > dataset.insert( :name => 'charlie' ) > dataset.all > > Note that I need to convert the @raw_table_name to a Symbol and then > to an identifier when creating the dataset from @db. > > Ultimately, I can work around it now that I know how it works but I'm > wondering if this was by design or just an accident. It would make > code cleaner to not have to do transformations after generating the > table name and instead just generate a single #lit or #identifier > object. Using identifier should work, as that is what it is designed to do. Places where it is not working are probably bugs. If you give me examples, I will try to fix them. It's better to improve the framework than fight it or work around it. If you want to work on patches yourself, know that it's not hard to get patches accepted in Sequel. If they look good, come with specs, and don't introduce regressions, I generally apply them (sometimes with modifications). Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
