Re: Not a Sequel error, but curious how you'd solve this

2020-09-24 Thread Jeremy Evans
On Thu, Sep 24, 2020 at 11:02 AM jaso...@gmail.com wrote: > Thank you Jeremy (as always!). We definitely have cases where a single > row is expected, but it may be worth it to enforce anyway. I'm also > thinking of having adding a `first!` method that will work without an > `order`. > Dataset

Re: Not a Sequel error, but curious how you'd solve this

2020-09-24 Thread jaso...@gmail.com
Thank you Jeremy (as always!). We definitely have cases where a single row is expected, but it may be worth it to enforce anyway. I'm also thinking of having adding a `first!` method that will work without an `order`. On Thursday, September 24, 2020 at 11:47:30 AM UTC-4 Jeremy Evans wrote: >

Re: Not a Sequel error, but curious how you'd solve this

2020-09-24 Thread Jeremy Evans
On Thu, Sep 24, 2020 at 8:31 AM jaso...@gmail.com wrote: > > We ran into some code today that did a a `first` without an `order`. I > can think of no situation where you don't include an order if you include > first (unless you are absolutely sure there's only one row, for example > reloading a

Re: Passing block to one_to_many

2020-09-24 Thread Jeremy Evans
On Thu, Sep 24, 2020 at 3:19 AM aryk@gmail.com wrote: > I have to following block and getting some strange behavior... > > class ChatRoomUser > one_to_many :messages, > key: :chat_room_id, > primary_key: :chat_room_id, > class: "ChatRoomMessage", > graph_block: (proc do |j,

Not a Sequel error, but curious how you'd solve this

2020-09-24 Thread jaso...@gmail.com
We ran into some code today that did a a `first` without an `order`. I can think of no situation where you don't include an order if you include first (unless you are absolutely sure there's only one row, for example reloading a row with eager data). I want to find a way to raise an error if

Re: Passing block to one_to_many

2020-09-24 Thread aryk....@gmail.com
Also, I'd like to add, that this fails as well: >> ChatRoom.last.chat_room_users.first.*refresh*.readable_messages On Thursday, September 24, 2020 at 1:19:19 PM UTC+3 aryk@gmail.com wrote: > I have to following block and getting some strange behavior... > > class ChatRoomUser > one_to_man

Passing block to one_to_many

2020-09-24 Thread aryk....@gmail.com
I have to following block and getting some strange behavior... class ChatRoomUser one_to_many :messages, key: :chat_room_id, primary_key: :chat_room_id, class: "ChatRoomMessage", graph_block: (proc do |j, s| {Sequel[j][:user_id] => Sequel[s][:user_id]} end) do |ds| *