Here is snippit of code that is trying to select qualifying rows from a
Movies table that has a Title column using bind parameters:
Sequel.connect({ adapter: :sqlite, database: './tests/data/test.db' }) do |
db|
ds = db.from(:Movies)
bind_parms = {}
bind_parms[:Title] = "Africa"
bind_parms[:Title2] = "Titantic"
ds = ds.where(Title: :$Title) # matches when it is the only the value
ds = ds.or(Sequel.like(:Title, :$Title2)) # matches when there is a value
after this one
ds2 = ds.clone # to preserve the currently selected columns
ds2.select { count.function.* } # change the selected columns to count(*)
p ds2.call(:first, bind_parms) # prints the first Movie row found but I
want a count of qualifying rows
p ds.call(:select, bind_parms) # prints all qualifying Movie rows as
expected
Before returning the qualifying rows, I need to get a count of the
qualifying rows, hence the call to db2.select(...). This does not work, it
returns the first qualifying row.
Any suggestions on how to get .count to work with bind parameters?
Thanks,
Michael
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/deca00b1-3909-4cb7-9c93-d2166e7ed8efn%40googlegroups.com.