Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Apr 2, 2010
  1. Bump version to 3.10.0

  2. Make one_to_one setter and *_to_many remove_all methods apply the ass…

    …ociation options
    Before, association options were ignored by these methods, which lead
    to some interesting behavior:
      Artist.one_to_many :good_albums, :class=>:Album,
      # Sets artist_id = nil for all of the artist's albums, not just the
      # good ones
    I think applying the filters is a better default for these methods.
    It's possible this will break some code, especially in the
    many_to_many case, but it's better to have a query that doesn't work
    than a query that makes modifications you didn't expect.
  3. Preserve nested attributes on validation failures for *_to_one associ…

    John Firebaugh authored
    a = => 'Al', :artist_attributes => {:name => 'Ar'})
    If the save fails either the Artist or Album validations, we want == 'Ar', so we can re-render the form and present
    the user's input for correction. Previously, a.artist returned nil.
Commits on Mar 30, 2010
  1. Add Sequel::BasicObject.remove_methods!, useful on 1.8 if libraries r…

    …equired after Sequel add methods to Object
    This also removes private methods from Sequel::BasicObject,
    previously only public and protected methods were removed.
    I first realized this is a problem when coming up with some example
    code using bin/sequel to help a user:
      DB[:a].filter{x > y}
    This actually raised an error, because YAML adds the private Kernel
    method y, and that wasn't removed.  Originally, I thought the reason
    was that YAML was required after Sequel, but it turns out that it
    was required before Sequel (since rubygems requires it), and the
    problem was that Sequel::BasicObject did not remove any private
    methods, which I consider to be a bug.
    Since it's possible to require libraries after Sequel which may
    add methods to Object that you want to remove,
    Sequel::BasicObject.remove_methods! exists to make sure that those
    methods will not override the method_missing handling in
    Sequel::BasicObject subclasses.
    On ruby 1.9, Sequel::BasicObject.remove_methods! exists for
    compatibility, but it's a noop.
Commits on Mar 29, 2010
  1. @jonasfagundes

    Changed the Database.connect to return the valued yielded by the block.

    jonasfagundes authored
    Previous to this patch I had to add this workaround to my project:
    def with_database
      vo = nil
      Sequel.connect(connection_string, connection_options) do |db|
        vo = yield(db)
  2. Add an rcte_tree plugin, which uses recursive common table expression…

    …s for loading trees stored as adjacency lists
    See the plugin module's RDoc for details.
  3. Make typecast_on_load plugin also typecast when refreshing the object…

    … (either explicitly or implicitly after creation)
Commits on Mar 28, 2010
  1. @ricardochimal

    do:mysql adapter treats tinyint(1) as boolean. The schema dumper will…

    ricardochimal authored
    … now just check if the schema type is :boolean when deciding if to dump a tinyint as an integer or boolean
Commits on Mar 26, 2010
  1. Fix transactions when connecting to Oracle via JDBC

    The native Oracle adapter uses methods on the connection.  I tried
    to modify the shared Oracle adapter to use SQL statements for
    transactions instead of relying on the underlying connection's
    methods, but my first try didn't work, and I don't have direct
    access to Oracle to test.
    This makes the Oracle JDBC subadapter use code very similar to the
    native Oracle adapter, using JDBC methods instead of the oci8
    methods.  Tested by Wei Hong, thanks!
    Note that while Oracle supports savepoints, neither the native
    Oracle adapter or the Oracle JDBC subadapter implements such
Commits on Mar 25, 2010
  1. Fix plugin loading when plugin module name is the same as an already …

    …defined top level constant
    This happened with the active_model plugin, which caused errors if
    ::ActiveModel was already defined, a common situation when using
    the Rails3 beta.
Commits on Mar 23, 2010
Commits on Mar 22, 2010
  1. Add an AS400 JDBC subadapter

    Dataset#insert probably won't return an autoincrementing primary key,
    but limit/offset support is emulated and should work.
  2. Make JDBC adapter recognize as400 connection strings and automaticall…

    …y load the Java class (need jt400.jar in classpath)
  3. @kronos
Commits on Mar 19, 2010
  1. Add the :eager_loader_key option to associations, useful for custom e…

    …ager loaders
    Advanced custom eager loaders may want to use a key for the eager
    loader that isn't the same as the common :key option.  This can
    be especially important in that if the eager loader key is empty,
    there is no attempt made to eager load the association (since there
    would be no matching records returned).
  2. Fix Dataset#limit on MSSQL 2000

    This was broken when support to allow limit to be a bound variable
    was added.  Now Sequel will use TOP(N) for MSSQL 2000, and TOP (N)
    for MSSQL 2005+.  Tested on MSSQL 2000 and MSSQL 2008.
Commits on Mar 18, 2010
  1. Raise an error if attempting to create a one_to_many association with…

    … a :one_to_one option
    Because backwards compatibility has been broken significantly for
    one_to_one associations, I feel it is best to have Sequel raise an
    error right away when attempting to define the association, rather
    that proceed and raise an error later (e.g. when eager loading).
    This also makes the code work if associate is called.  Since
    associate is a public method, users are allowed to call it directly,
    and that case should be handled.
    one_to_one associations no longer use the :one_to_one option, since
    we can just check the :type option instead.
    This should be the final one_to_one related commit for the time
  2. Fix eager loading of one_to_one associations

    The last commit broke eager loading of one_to_one associations.  Let
    this be a reminder that any custom one_to_one eager loaders need to
    be modified to support the new caching practice.
    While here, remove setting the :limit explicitly when defining the
    association.  Instead, rely on the _dataset method adding the limit.
    This commit restores the previous practice where if the :key option
    is nil, no limit is used.  This is designed for custom datasets that
    that use the :eager_graph option, which may eagerly load multiple
    subordinate associated records.
    Also, note that many_to_one associations should now always have a
    working :class option, as they can set now the reciprocals for
    one_to_one associations (and determining reciprocals requires looking
    at the associated class).  Previously, the many_to_one associations
    would work with a bad :class option in some cases.
  3. Cache one_to_one associations using an object instead of an array

    This is nearing the end of the one_to_one commits, but we still have
    a couple to go.  Because one_to_one associations were originally
    just one_to_many associations, they were cached as an array (with
    a single object in it).  This commit switches that to use the
    same type of caching at many_to_one associations, were nil is
    a cached negative lookup, and where a non-nil value is the cached
    While here, add a limit(1) to the many_to_one association (in two
    places, one of which will be removed soon).
    There is a slight breakage of backwards compatibility in regards
    to *_to_one associations with a nil :key option still addining a
    limit(1), but that will be fixed soon.
Commits on Mar 17, 2010
  1. Major spec additions for one_to_one associations

    One intentional spec breakage left in, for fixing soon.  While here,
    fix the one_to_one setter to work with a nil value.
  2. Make one_to_one a real association type

    Previously, one_to_one was a one_to_many association with some
    behavior changes.  This commit doesn't change much, but it does make
    one_to_one it's own association.  Calling one_to_many with the
    :one_to_one option will create a one_to_one association.
    Make the association methods use the same API as associate, to keep
    them consistent with each other.
    This shouldn't be a significant external change, other than
    one_to_one association type being :one_to_one instead of
    :one_to_many.  One significant internal change is that
    AssociationReflection#reciprocal_type is now allowed to return an
    array of symbols, in which case any of those association types can
    be a candidate to be a reciprocal.
  3. @knaveofdiamonds

    Fix issue with unusual/db-specific primary keys when calling DB.dump_…

    knaveofdiamonds authored committed
    …schema_migration(:same_db => true)
  4. Use before_set and after_set callbacks for many_to_one and one_to_one…

    … associations
    Before, the many_to_one association setter called before and after
    remove hooks for the currently associated object (sending a database
    query to get the currently associated record if necessary), and
    before and after add hooks for the current record.  This has been an
    issue in the past, and it's generally not necessary.  The new before
    and after set callbacks make the handling more like the how the
    before and after add and remove callbacks are handled by the add and
    remove methods.
    This changes the internals to set_associated_object to simplify it
    to use the new callbacks.  It also changes the one_to_one setter
    to split it into public and private parts, adding a
    set_one_to_one_associated_object method that is similar to
    set_associated_object but different enough to require a standalone
    The private one_to_one setter has been improved somewhat in regards
    to handling nil, but it's not good yet.  This will be fixed soon.
    Another fix for the one_to_one setter is that it now sets other
    associated records to nil before the current record, which could
    possibly be better on databases that don't delay foreign key
    constaint checking until the end of the transaction (or when
    transactions aren't being used).
Commits on Mar 16, 2010
  1. Add Model.one_to_one option for creating model associations

    This adds the one_to_one class method, which just adds a one_to_many
    association with the :one_to_one option.  It also has some behavior
    Instead of the :one_to_one option creating an add_ association
    method, it just creates the setter method, which doesn't call add_.
    Before the behavior was inconsistent in that it called the add_
    method but not the remove_ method for removing existing options
    (which is what the many_to_one setter does).  I'm going to be
    changing the many_to_one and one_to_one associations to not use
    add_ and remove_, but that's coming later.
    The association_dataset method for one_to_one associations is
    no longer private.
    Using the many_to_one setter when the reciprocal association is a
    one_to_one association with a different associated object already in
    the reciprocal cached association no longer causes an error.
    Instead of raising an error if multiple objects are returned by the
    dataset, it defaults to selecting only 1 item in the dataset. If for
    some reason the cached association has more than one record, it
    returns the last record.  The reason it uses the last record instead
    of the first record is to make it work correctly with the many_to_one
    setter reciprocal handling.
Commits on Mar 15, 2010
  1. Support singular association names when using :one_to_one.

    John Firebaugh authored
Something went wrong with that request. Please try again.