Hello, I guess this is my first message in this group, so I'd like to thank 
you for this amazing gem!

I've first used it some years ago in a minor project and was pretty happy 
with it. ActiveRecord wasn't built in top of Arel by that time, so it was 
waaaay better than AR.

But about 4 years ago, I've got a better job offer and since then I've been 
mostly working with Grails, Groovy and Java. It happened that I've found a 
critical bug in Grails that is not fixed yet so I decided to proxy the 
problematic requests to an isolated Rails application.

But after struggling with some queries in ActiveRecord, I decided to give 
Sequel a try in a more serious Rails application. Here is my request that 
got ignored in the Rails core mailing list:

https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/XxmaSvOkgO4

So years later I'm still pretty happy to be working with Sequel again. I've 
even wrote a new gem yesterday and wrote an article on how to start with 
Sequel in a Rails application:

https://github.com/rosenfeld/sequel-devise
http://rosenfeld.herokuapp.com/en/articles/2012-04-18-getting-started-with-sequel-in-rails

I'll try to update my article later to include instructions for setting up 
transactional examples in RSpec.

So, I'm converting some classes from ActiveRecord to Sequel and the only 
issue I've found so far is the lack of "dirty" columns support, like in AR.

For example, take a look at this AR model excerpt:

  after_update :remove_options_if_changed_type_was_options
private
  def remove_options_if_changed_type_was_options
    options.clear if type_changed? && type_was == 'options'
  end

I've even asked for a type_was? method in a Rails pull request at that time:

https://github.com/rails/rails/pull/5763

So, I tried this to get a similar result in Sequel:

private
  def after_update
    super
    options_dataset.delete if type_was_options?
  end

  def data_type_was_options?
    changed_columns.include?(:type) && type != 'options'
  end

Yes, I know about the warnings in the documentation:

"This isn't completely accurate, as it could contain columns whose values 
have not changed."

Although not ideal, that is ok. But the issue is that my spec won't pass. 
When I try to print "changed_columns" it is empty. Maybe this information 
is reset after a save.

I've read somewhere in this group that such feature wasn't requested 
before, so I'm requesting it now :P

Could I ask you to include an official "dirty" plugin for Sequel::Model? 
One that would even work in after-hooks? And that would be completely 
accurate whatever it means?

Thank you in advance and also thank you very much for the great gem Sequel 
already is!

Keep up with the good work!

Cheers,
Rodrigo.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/U2-u0tVhWZcJ.
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