Permalink
Commits on Oct 12, 2008
  1. Bump version to 2.6.0

    jeremyevans committed Oct 12, 2008
Commits on Oct 8, 2008
  1. Make the sqlite adapter respect the Sequel.datetime_class setting, fo…

    jeremyevans committed Oct 8, 2008
    …r timestamp and datetime types
  2. changed the behaviour of Schema::Generator::unique so that it doesn't…

    jarredholman committed with jeremyevans Sep 29, 2008
    … explicitly create an index.
  3. Default to using the simple language if no language is specified for …

    jeremyevans committed Oct 8, 2008
    …a full text index on PostgreSQL
  4. Don't blindly qualify columns when eager graphing

    jeremyevans committed Oct 8, 2008
    Qualifying all entries in the :order option when eager_graphing is
    not correct behavior.  For example, it's legimate to order by a
    function, which shouldn't be qualified.  Also, already qualified
    symbols should not be qualified again.  Change the qualifying to
    only qualify unqualified symbols and SQL::Identifiers, either of
    which may be wrapped in an SQL::OrderedExpression.  Do not qualify
    anything else.
Commits on Sep 28, 2008
Commits on Sep 27, 2008
  1. Modified Sequel::Database#typecast_value to raise Sequel::Error::Inva…

    Michal Bugno committed Sep 27, 2008
    …lid value
    
    if the typecasted value is invalid. This is needed because when typecasting a
    model column this exception is rescued and handled appropriately.
Commits on Sep 26, 2008
  1. Added raise_on_typecast_failure switch. If set to false, it prevents …

    Michal Bugno committed Sep 26, 2008
    …from
    
    raising an error when trying to typecast nil to column which cannot be NULL.
    Defaults to true.
  2. Add schema.rdoc file, which provides an brief description of the vari…

    jeremyevans committed Sep 26, 2008
    …ous parts of Sequel related to schema modification
Commits on Sep 25, 2008
Commits on Sep 24, 2008
  1. Make eager_graph respect associations' :order options (use :order_eag…

    jeremyevans committed Sep 24, 2008
    …er_graph=>false to disable)
    
    This changes eager_graph so that it will add the columns specified in
    each graphed association's :order option to the list of ordered
    columns.  It qualifies the column with the table alias used for that
    join.
    
    This shouldn't cause problems unless:
    
    1) You have an already qualified column in the :order option.
    
    2) You have a column in the :order option that wasn't in the primary
       table (maybe because you were using the :eager_graph association
       option to include the table whose column you were using).
    
    While remote, those problems can happen, and you can turn off the
    including of the associations :order option by setting the
    association's :order_eager_graph option to false.
    
    This commit also fixes a bug in eager_graph when you were loading
    an association with the same name as the base table in the FROM
    clause.
Commits on Sep 23, 2008
Commits on Sep 20, 2008
  1. Cache negative lookup when eagerly loading many_to_one associations w…

    jeremyevans committed Sep 20, 2008
    …here no objects have an associated object
Commits on Sep 19, 2008
  1. Allow string keys to be used when using Dataset#multi_insert

    jeremyevans committed Sep 19, 2008
    Add Dataset#identifier_list private method taking an array and
    returning a string containing comma separated identifiers.
Commits on Sep 18, 2008
  1. Fix join_table when doing the first join for a dataset where the firs…

    jeremyevans committed Sep 18, 2008
    …t source is a dataset when using unqualified columns
Commits on Sep 17, 2008
  1. Fix a few corner cases in eager_graph

    jeremyevans committed Sep 17, 2008
    This commit fixes two separate problems with eager graph. The first
    is that cascading *_to_many associations could cause an exception to
    be raised, because eager_graph_make_associations_unique wasn't
    recursing properly.
    
    The second is that *_to_many associations that were cascaded after
    a many_to_one association weren't recursed into to eliminate
    duplicates caused by cartesian products.
    
    Thanks a lot to jarredh on IRC for bringing the second bug to my
    attention, which led me to fix the first bug (even before I fixed the
    second).
Commits on Sep 15, 2008
  1. Support transactions on MSSQL

    jeremyevans committed Sep 15, 2008
    This commit supports transactions on MSSQL, which requires an
    explicit TRANSACTION keyword to work.  It does this by adding private
    Database methods (begin|rollback|commit)_transaction_sql, and
    overridding them in the MSSQL shared adapter.  The default
    transaction method uses these methods, and most of the other adapters
    that override the transaction method also use these methods (the
    PostgreSQL adapter being an exception).
  2. Use string literals in AS clauses on SQLite

    jeremyevans committed Sep 15, 2008
    This commit adds a private Dataset method as_sql, and coverts the
    various parts of Dataset that use the AS clause to use this method.
    By default, as_sql uses an identifier for the alias, but the SQLite
    adapter overrides it to use a string literal.
    
    This commit also changes the remaining case where the AS keyword was
    left out, when aliasing tables with a hash.  Now, the AS keyword is
    used in that case.
    
    This caused one part of a spec to be removed, the case of
    @dataset.from(:a => :c[:d]).sql => "SELECT * FROM a c(d)". I'm not
    sure that that is valid SQL anyway.
Commits on Sep 14, 2008
Commits on Sep 11, 2008
Commits on Sep 10, 2008
Commits on Sep 9, 2008
  1. Refactor schema parsing, include primary key on PostgreSQL and MySQL

    jeremyevans committed Sep 8, 2008
    This commit refactors the schema parsing.  It eliminates the shared
    INFORMATION_SCHEMA based parsing that worked OK on PostgreSQL and
    very slowly on MySQL.  The Database#schema public method has been
    kept, but the other shared private methods were removed, with the
    exception of schema_column_type for mapping database types to ruby
    types.  MySQL, PostgreSQL, and SQLite schema parsing all include
    the :primary_key entry that shows whether the column is (part of)
    the primary key.
    
    PostgreSQL now uses the pg_* system catalogs directly, instead of
    the information_schema.  MySQL uses the DESCRIBE syntax to get a
    table description.  SQLite was cleaned up slightly, but still uses
    the table_info pragma.
    
    The shared Database#schema method now falls back to getting the
    schema separately for each table if it can't get the schema for
    all tables at once, assuming it knows how to get the schema for
    a single table and it knows how to get a list of tables.
    
    PostgreSQL now supports specifying a qualified table name (including
    schema) in the call to Database#schema.  Before, the schema had to
    be specified explicity using the :schema option, which means it
    didn't work correctly with models.  It still defaults to the public
    schema if no schema is specified (either explicitly or implicitly).
    This means that DB.schema(:s__t) now gives column information for
    table t in schema s.
    
    The :numeric_precision and :max_chars entries are no longer included
    in the hashes returned by schema.  You should be able to get the same
    or similar information using the :db_type entry, which now includes
    specified lengths (e.g. varchar(255)).
    
    Since primary keys can now be parsed from the schema, use the schema
    information to set primary keys for schema models.
    
    In addition, this commit makes schema changing methods such as
    drop_table and alter_table remove the cached schema entry.  It also
    has a small fix to drop_view to allow dropping multiple views at
    once, so it works just like drop_table.  Additionally, it quotes
    the view names.
    
    The schema hash keys are now always supposed to be symbols.
    
    This commit also changes some specs to remove the use of set_schema,
    and it adds integration tests to test schema parsing of primary keys,
    NULL/NOT NULL, and defaults.
    
    This commit makes MySQL Database#tables work on JDBC as well as using
    the native adapter, by using the SHOW TABLES syntax.
Commits on Sep 8, 2008
Commits on Sep 3, 2008
  1. Bump version to 2.5.0

    jeremyevans committed Sep 3, 2008
Commits on Sep 2, 2008
Commits on Aug 28, 2008
  1. Add Dataset #set_defaults and #set_overrides, used for scoping the va…

    jeremyevans committed Aug 28, 2008
    …lues used in insert/update statements
    
    Sequel has long been known for its chainable filters.  Before this
    commit, it was not possible to chain the values used in insert or
    update statements.  This commit adds two methods, with slightly
    different features, to accomplish this.
    
    set_defaults is used to set the default values used in insert or
    update statements, which can be overriden by the values passed to
    insert or update:
    
      DB[:t].set_defaults(:x=>1).insert_sql
      # => INSERT INTO t (x) VALUES (1)
      DB[:t].set_defaults(:x=>1).insert_sql(:x=>2)
      # => INSERT INTO t (x) VALUES (2)
      DB[:t].set_defaults(:x=>1).insert_sql(:y=>2)
      # => INSERT INTO t (x, y) VALUES (1, 2)
    
    set_overrides is used to set default values that override the values
    given to insert or update statements:
    
      DB[:t].set_overrides(:x=>1).insert_sql(:x=>2)
      # => INSERT INTO t (x) VALUES (1)
    
    In addition, chaining calls to set_default and set_overrides operate
    slightly differently:
    
      DB[:t].set_defaults(:x=>1).set_defaults(:x=>2).insert_sql
      # => INSERT INTO t (x) VALUES (2)
      DB[:t].set_overrides(:x=>1).set_overrides(:x=>2).insert_sql
      # => INSERT INTO t (x) VALUES (1)
    
    As show above, with set_default, the last call takes precedence,
    whereas with set_overrides, the first call takes precedence.
    
    Note that set_defaults and set_overrides only are used when insert or
    update is called with a hash.
    
    Dataset#insert had to go through some significant refactoring for this
    to work.  All the specs still pass, so hopefully nothing broke because
    of it.
  2. Allow Models to use the RETURNING clause when inserting records on Po…

    jeremyevans committed Aug 28, 2008
    …stgreSQL
    
    This commit makes model.save! check for an insert_select method on
    the dataset.  If it exists, it calls that method and uses the result
    as the values, instead of inserting and then reloading the values
    from the database. This should be faster as well as less error prone.
    
    It changes a recent commit to the PostgreSQL adapter so that
    insert_sql does not use the RETURNING clause by default. You need to
    call the insert_returning_sql method if you want the RETURNING
    clause.  That is what Dataset#insert now does on PostgreSQL servers
    8.2 and higher.  This caused some issues with prepared statements,
    but this commit takes care of that as well.
    
    This commit also contains a small speedup to Dataset#single_value,
    as well as a missing spec for Database#raise_error.
Commits on Aug 27, 2008
  1. Raise Sequel::DatabaseError instead of generic Sequel::Error for data…

    jeremyevans committed Aug 27, 2008
    …base errors, don't swallow tracebacks
    
    This commit adds a new exception class, Sequel::DatabaseError.  This
    exception class should be used for all errors that come from the
    database, such as invalid syntax in a query or database access rights
    violation.
    
    This commit adds a couple private Database methods, raise_error and
    transaction_error.  raise_error converts the exception to a
    DatabaseError, keeping the previous exception message (prepended
    with the previous exception class) as well as the traceback.  If
    an optional :classes option is passed, it only converts the exception
    if it is one of those classes.  transaction_error calls raise_error
    with the :classes options set to the array of passed classes, unless
    the error is an Error::Rollback.  These DRY up some code in the
    adapters.
    
    This commit also removes the convert_pgerror method for the postgres
    adapter, since it is no longer necessary.
    
    This is a backwards incompatible change for SQLite users, since the
    SQLite adapter previously raised Error::InvalidStatement instead of
    just Error.