On Tuesday, March 13, 2018 at 7:26:28 AM UTC-7, Eleanor McHugh wrote:
> I'm getting back into Sequel after a break of several years and am running 
> into problems creating Sequel::Model subclasses which use set_schema. Every 
> time I try this pattern I'm getting runtime errors of the form:
>  `prepare': Amalgalite::SQLite3::Error: Failure to prepare statement 
>> SELECT * FROM `services` LIMIT 1 : [SQLITE_ERROR 1] : no such table: 
>> services (Sequel::DatabaseError)
> where my code is of the form
> require 'sequel'
>> DB = Sequel.connect database: 'database.db', adapter: 'amalgalite', mode: 
>> 'w+'
>> class Service < Sequel::Model
>> set_schema do
>> primary_key :id
>> String :address, unique: true, null: false
>> end
>> end
> This pattern worked perfectly in the last major project I did with Sequel 
> and I'm baffled as to what I'm doing wrong. The only substantive difference 
> is that for that project I used a MySQL backend rather than Amalgalite. On 
> the off-chance this is an adapter bug I've also tried with the standard 
> SQLite adapter.
> One thing I noticed reading through the RDoc for Sequel::Model is the 
> @@lazy_schema_loading variable and I've tried setting this via its accessor 
> but that raises a NoMethodError.
> Any insights into what I'm doing wrong will be gratefully received.

I'm not sure what version of Sequel you are running.  In Sequel 5, 
set_schema does not exist.  Sequel does not use class variables at all, not 
in core nor in any plugins or extensions.

You probably want to change the code to:

require 'sequel'
DB = Sequel.connect database: 'database.db', adapter: 'amalgalite', mode: 
DB.create_table?(:services) do
  primary_key :id
  String :address, unique: true, null: false
class Service < Sequel::Model

Maybe that will help.


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.

Reply via email to