I have it defined inside class Sequel::Model and it works sometimes,
and sometimes it doesn’t work. And for the models it doesn’t work with
it gives the same error for Klass.dataset.last as Klass.last.

On Sep 14, 7:05 pm, Jeremy Evans <[email protected]> wrote:
> On Sep 14, 3:17 pm, Tal <[email protected]> wrote:
>
> > def_dataset_method :last do
> >   order(:id.desc).first
> > end
>
> > For some reason when i try to call this i get an error saying no order
> > specified. Any idea why this is the case?
>
> I can't recreate:
>
> $ sequel -E sqlite:/
> Your database is stored in DB...
> irb(main):001:0> DB.create_table(:as){primary_key :id}
> I, [2009-09-14T16:03:10.008509 #3212]  INFO -- : CREATE TABLE `as`
> (`id` integer PRIMARY KEY AUTOINCREMENT)
> => []
> irb(main):002:0> class A < Sequel::Model
> irb(main):003:1> def_dataset_method :last do
> irb(main):004:2*   order(:id.desc).first
> irb(main):005:2> end
> irb(main):006:1> end
> I, [2009-09-14T16:03:23.945987 #3212]  INFO -- : PRAGMA table_info
> ('as')
> => [:last]
> irb(main):007:0> A.last
> I, [2009-09-14T16:03:25.981776 #3212]  INFO -- : SELECT * FROM `as`
> ORDER BY `id` DESC LIMIT 1
> => nil
> irb(main):008:0> A.dataset.last
> I, [2009-09-14T16:03:41.405903 #3212]  INFO -- : SELECT * FROM `as`
> ORDER BY `id` DESC LIMIT 1
> => nil
>
> If you could post/pastie your code, I might be able to see what is
> going wrong.
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to