Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Nov 2, 2009
  1. Bump version to 3.6.0

    authored
Commits on Oct 29, 2009
  1. Make the MSSQL shared adapter correctly parse the column schema infor…

    authored
    …mation for tables in the non-default database schema
  2. Use save_changes instead of save when updating existing associated ob…

    authored
    …jects in the nested_attributes plugin
    
    This should be significantly faster for the case where you are
    displaying a complex form to the user, and they make no changes to
    the existing associated records when they submit it.
    
    This shouldn't have a negative effect on production code, unless
    save_changes doesn't work correctly for the associated objects.
    It may break test code that checks for specific SQL or columns in
    the update statement.
  3. Allow Model#save_changes to accept an option hash that is passed to s…

    authored
    …ave, so you can save changes without validating
Commits on Oct 28, 2009
  1. Make nested_attributes plugin add newly created objects to cached ass…

    authored
    …ociation array immediately
    
    The reasoning behind this is that if this isn't done, the current
    object has no way to access the nested attribute records until
    after the save.
    
    The general use case for nested_attributes is a web form that
    handles dependent records.  Without any access to the nested
    records, it is very difficult to handle validation failures
    and display nice error messages to the user if dependent records
    are not valid.
    
    This approach adds the newly created records to the cached array,
    so if validation fails, you can just iterate over the cached array,
    and it will have both previously existing and new records in it.
    
    This change does not affect many_to_one associations, since they
    don't have a cached association array, and setting the object
    in the cached association would probably cause issues.
    
    This also doesn't affect updating existing records, since those
    are already in the array.
  2. Allow easier overriding of default options used in the validation_hel…

    authored
    …pers plugin
    
    This breaks backwards compatibility if you were relying on the
    change made on October 20 to set the default validation error
    messages.  This generalizes support for overriding any of the
    default options.  As before, you can override it on a global level:
    
      Sequel::Plugins::ValidationHelpers::DEFAULT_OPTIONS[:format].
        merge!(:message=>"incorrect format", :allow_missing=>true)
    
    You can also override it on a per class basis via:
    
      class Album < Sequel::Model
        plugin :validation_helpers
        DEFAULT_VALIDATION_OPTIONS = {
          :format=>{:message=>"incorrect format", :allow_missing=>true}}
    
        private
    
        def default_validation_helpers_options(type)
          super.merge(DEFAULT_VALIDATION_OPTIONS[type] || {})
        end
      end
    
    This removes the MESSAGE_PROCS constant from the ValidationHelpers
    module, and removes the private instance method
    default_validation_error_message_proc.  It changes the API for
    validation_error_message and adds the
    default_validation_helpers_options and
    validatable_attributes_for_type private instance methods.
    
    I chose not to change the validatable_attributes API, even though
    it could be simplified now, because while the method is private,
    I expect there may be consumers other than the default validations.
Commits on Oct 27, 2009
  1. Make add_ association method not add the associated object to the cac…

    authored
    …hed array if it's already there
    
    This makes the most sense for one_to_many associations, since those cannot
    be associated more than once.  For many_to_many associations, I think it
    is a better default, as it's a rare case that you want duplicate items
    in the association.  If you do want duplicate items for a many_to_many
    association and you want it to work well with caching, please bring it
    up on the Sequel mailing list and we'll work it out.
    
    Note that this exact thing was done for reciprocal associations, so
    Sequel is more consistent with this change.
  2. Update CHANGELOG

    authored
  3. @michaeldiamond
Commits on Oct 26, 2009
  1. Add Model#modified! for explicitly marking an object as modified, so …

    authored
    …save_changes/update will run callbacks even if no columns have been modified
    
    This allows you to explicitly mark an existing record as modified
    without overriding modified?.  Marking a column as modified
    makes save_changes (and therefore update) call save even if
    no columns have been modified.  This is necessary if you
    have hooks that should be run regardless of whether the object's
    columns have been modified.
    
    See the included change to the nested_attributes plugin for
    an example use case.
  2. Add support for a :fields option in the nested attributes plugin, and…

    authored
    … only allow updating of the fields specified
    
    I'm a big believer in using set_only for all mass assignment,
    specifying explicitly the fields allowed in that mass assignment
    call.  This patch allows you to do that when using the
    nested_attributes, by specifying a :fields option which should
    be an array of symbols, which changes the internals to use
    set_only with the fields specified, instead of set.
    
    This fixes the spec for the previous commit, which only passed by
    accident.  It also reorganizes some of the private
    nested_attributes methods.
Commits on Oct 25, 2009
  1. Don't allow modifying keys related to the association when updating e…

    authored
    …xisting associated objects in the nested_attributes plugin
    
    This fixes a possible security issue in the nested attributes plugin,
    allowing you to modify an associated object's fields related to the
    association, which could allow you to disassociate it from the
    current record or associate it to a different record.
    
    This security issue is only likely to be present in one_to_many
    assocations, but it can happen for other associations if you use
    non default primary key fields in the association.  Here's an
    example of code that exploits the vulnerability:
    
      Artist.one_to_many :albums
      Artist.plugin :nested_attributes
      Artist.nested_attributes :albums
      artist = Artist.create
      artist2 = Artist.create
      album = Album.create
      artist.albums_attributes = [{:id=>album.id, :artist_id=>artist2.id}]
      artist.save
  2. Add associated_object_keys method to AssociationReflection objects, s…

    authored
    …pecifying the key(s) in the associated model table related to the association
  3. Merge commit 'michaeldiamond/master'

    authored
    Conflicts:
    	lib/sequel/dataset/sql.rb
Commits on Oct 24, 2009
  1. Fix marshalling of model objects so that they load correctly, but you…

    authored
    … need to call marshallable! first
    
    The previous fix of not raising an error when marshalling the model
    instance's dataset didn't work as it broke loading.  Instead of
    writing custom _dump and _load methods, add a marshallable! instance
    method that just sets the model instance's dataset to nil.  Leave the
    changes to Model::Errors, since they aren't a bad way to handle
    things.
    
    Make the specs test loading the marshalled data, so we can make sure
    things work.
  2. Merge commit 'eppo/master'

    authored
Commits on Oct 23, 2009
  1. Don't modify array with a string and placeholders passed to Dataset#f…

    authored
    …ilter or related methods
    
    Thanks to sferik for pointing this out.  Previously:
    
      options = ["name like ?", "%dog%"]
      Player.where(options)
      options # => ["%dog%"]
  2. @EppO

    fixed spec for caching plugin (memcached support)

    EppO authored
    all tests pass
  3. @michaeldiamond
  4. @michaeldiamond
  5. @michaeldiamond
  6. @michaeldiamond
Commits on Oct 22, 2009
  1. merged caching_memcached and caching plugins in one file according to…

    Florent authored
    … Jeremy
    
    starting to write a spec supporting memcached (last test FAILED, I don't know why yet)
  2. documentation update to hook_class_methods

    Daniel Bretoi authored
  3. @EppO
Commits on Oct 21, 2009
Something went wrong with that request. Please try again.