Hello everyone.
I'm really new to Sequel and am writing a script that accesses one of
our existing (old) MySQL databases (server running 4.1.12). I've got
ruby 1.8.7 (patchlevel 302) and the sequel gem (version 3.15.0)
installed on my dev machine from which I'm accessing my server.
The problem I'm having is getting the boolean_readers plugin to work.
I don't know if it is just because I'm so new to Sequel and don't know
the proper method or if there is some other problem.
I have a table in my database named "tblEmployees" with a field names
"Active" that is a TINYINT(1) field (signed). I'd like to be able to
read this field using: x.Active? and access the numeric value with
x.Active. From my reading thus far, it appears that the solution is to
turn "convert_tinyint_to_bool" off (done) and enable the
"boolean_readers" plugin on this model. Disabling tinyint to boolean
conversion works great but I don't get any "?" attribute reader
methods for my tinyint field:
$ irb (some output omitted for brevity)
> require 'rubygems'
> require 'sequel'
> DB = Sequel.connect("mysql2://user:p...@server/db")
> Sequel::MySQL.convert_tinyint_to_bool = false
> Sequel::Model.plugin :boolean_readers
=> nil
> class Employee < Sequel::Model(:tblEmployees)
> set_primary_key :ID
> end
=> :ID
> me = Employee[1]
=> (tons o stuff)
> me.Active
=> -1 (yes, our DB originally created for MS Access stores true as -1)
> me.Active?
NoMethodError: undefined method `Active?' for #<Employee:
0x7f92530279d8>
from (irb):10
from :0
I also tried the variation of applying the plugin directly to the
Employee class:
> Employee.plugin :boolean_readers
=> (bunch o stuff)
> me.Active?
NoMethodError ...
Anyhow, I'm liking Sequel over my old ActiveRecord (version 2) but I'd
like to get this to working if possible.
Thanks for any help!
--
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.