Commits on Aug 30, 2012
  1. fixing syntax error

    cohuman committed Nov 17, 2011
  2. Optimization for very specific use case of all UTC times in database …

    Andy Goodell committed with cohuman Nov 17, 2011
    …and app
  3. Optimization for very specific use case of all UTC times in database …

    Andy Goodell committed with cohuman Nov 17, 2011
    …and app
Commits on Aug 29, 2012
  1. Fix country typo

    jc00ke committed Aug 29, 2012
    Greece is in Europe. Turkey is a good option!
  2. Make defaults_setter plugin delay current date/time calculation until…

    jeremyevans committed Aug 29, 2012
    … instance creation time (Fixes #541)
Commits on Aug 26, 2012
  1. Fix assorted documentation typos.

    chanks committed Aug 26, 2012
Commits on Aug 22, 2012
  1. Fix potential thread-safety issues on PostgreSQL on non-GVL rubies

    jeremyevans committed Aug 22, 2012
    Similar to previous changes in the general library, this makes
    the shared postgres adapter require synchronization for the
    @primary_keys and @primary_key_sequences hashes for
    Database instances, since multiple threads could potentially
    attempt to update them concurrently.
  2. Handle Sequel::CURRENT_{DATE,TIMESTAMP} values in the defaults_setter…

    jeremyevans committed Aug 22, 2012
    … plugin
    Since Sequel started parsing current date/timestamp values from the
    database, the defaults setter has just used the values directly,
    which is probably not desired as they represent database concepts
    instead of concrete values.  Instead, convert the values into
    the current Date or Time/DateTime.
    While here, fix the defaults setter to actually set false default
  3. Make schema_dumper handle CURRENT_DATE/CURRENT_TIMESTAMP

    jeremyevans committed Aug 22, 2012
    Since we started using CURRENT_DATE/CURRENT_TIMESTAMP for
    :ruby_default, the schema_dumper has not been able to dump
    such values correctly.  To fix this, instead of only
    using the eval_inspect extension for a very specific case,
    include it generally, and just use eval_inspect to get the
    default value.
    In addition to the CURRENT_DATE/CURRENT_TIMESTAMP fix, this
    also preserves any fractional seconds in time/datetime default
    values when dumping.
  4. Make NegativeBooleanConstant inherit from Constant

    jeremyevans committed Aug 22, 2012
    Before, it inherited from BooleanConstant, which is wrong as it
    lead to Sequel::NULL == Sequel::NOTNULL.
  5. Don't include date part in Sequel::SQLTime eval_inspect output

    jeremyevans committed Aug 22, 2012
    This should be a no-op, but results in more readable output.
  6. Fix serial sequence query in Database#primary_key_sequence on Postgre…

    jeremyevans committed Aug 22, 2012
    …SQL (Fixes #538)
    The serial sequence query was previously broken, since it checked
    if the sequence name was equal to the table name, which is wrong.
    So in all cases previously, it fell back to using the custom
    sequence query.
    Modify the query to check that the table name matches.  While here,
    always quote the table name if the serial sequence query matches,
    since unlike the custom sequence query, the serial sequence query
    doesn't deal with literal strings.
Commits on Aug 17, 2012
  1. Add Database#copy_into when using postgres adapter with pg driver, fo…

    jeremyevans committed Aug 17, 2012
    …r very fast inserts into tables
    This uses PostgreSQL's COPY table FROM STDIN support to get really
    fast inserts when using data preformatted in CSV or PostgreSQL
    text format.  Support for COPY table TO STDOUT was added last
    year, but previous Sequel did not support that and you had to
    drop down to the connection level, which doesn't offer an
    API that is as nice.
Commits on Aug 16, 2012
  1. Skip combining alter table spec on jdbc/db2 and native db2

    jeremyevans committed Aug 16, 2012
    These adapters probably don't like the set_column_type calls,
    so add guards just like for the set_column_type specs.
  2. Combine multiple alter_table operations into a single query where pos…

    jeremyevans committed Aug 16, 2012
    …sible on MySQL and PostgreSQL
    ActiveRecord has been doing this since 3.1, though just for MySQL
    and not by default (it requires a separate :bulk=>true option).
    This change may be risky, as it can change the SQL used for old
    migrations, but hopefully it shouldn't cause problems.  This
    preprocesses the alter table operations array and if it detects
    operations that can't be combined (e.g. add/drop index operations
    or rename column operations on PostgreSQL), it uses separate
    queries for those.
    If this causes problems that can't be easily fixed, this will be
    turned off by default and only enabled via an option.  A simple
    way to skip this combining manually is to use separate alter_table
    blocks for each operation.
    To implement this, alter_table_op_sql is split off
    alter_table_sql, and returns just the fragment used.  Multiple
    fragments can be separated by commas in a single ALTER TABLE query.
    If the adapter does not support combining alter table operations,
    then no changes are necessary.  However, if it does enable support
    for combining operations, it must implement alter_table_op_sql to
    handle overrides for the operations, or mark such operations as
    not combinable.
    It's possible to support something similar on Microsoft SQL
    Server, but the syntax is different, and appears to be much
    more limited, only adding multiple columns/constraints at once or
    dropping multiple columns/constraints at once, but not mixing
    adds and drops.  I don't have current plans to adding a similar
    feature to Microsoft SQL Server.
    Also, this changes the code to assume that alter_table_sql_list
    returns an already flattened array.  Any custom adapters that
    override alter_table_sql_list should make sure that they return a
    flattened array.
  3. Handle sets of alter_table operations on mysql and mssql where later …

    jeremyevans committed Aug 16, 2012
    …operations depend on earlier ones
    Some alter_table operations on mysql and mssql require parsing the
    schema to get current metadata.  If you have multiple alter_table
    operations that modify the same column, this can cause problems,
    since all of the alter table queries are generated before being
    run on the database.  For example:
        rename_column(:bar, :baz)
        set_column_type(:baz, Integer)
    On both MySQL and MSSQL, this would fail, since when generating
    the set_column_type SQL, it would look for the baz column in the
    schema, but that won't exist since the rename_column SQL has
    not yet been run.
    To fix this, preprocess the array of operations and split it
    into multiple arrays.  Between the execution of SQL in each array,
    remove the cached schema, so that the next set of operations will
    have accurate schema information.
    The implementation of the methods is the same for both of these,
    except for one line (MSSQL doesn't need to parse the schema to
    set a new default).  I thought about abstracting this into a
    separate method, but I feel the implementations may diverge
    further in the future, so I'm not convinced it is worth it.
  4. Add constraint_validations extension and plugin

    jeremyevans committed Aug 1, 2012
    The extension allows you to create database constraints that mirror
    model validations when creating and altering tables.  It adds
    validation metadata to a separate table.  The plugin reads the
    metadata from that table, and uses it to automatically validate your
    models before saving.
    The advantage to doing so is that your validations are only specified
    in one place, but are enforced both at the model level and at the
    database level.  This is better for data integrity, since it
    enforces the validation for all rows in the database, so changes
    made by external programs or via the dataset layer are still
  5. Add new apply_alter_table_generator for easier overriding

    jeremyevans committed Aug 1, 2012
    This change allows the method to modify the generator's
    operations before using those operations to modify the
  6. Don't require a :type when dropping constraints on SQLite

    jeremyevans committed Aug 1, 2012
    Previously, if a type was not specified, an error was raised.
    However, other than primary key and foreign key constraints,
    there are unique and check constraints, which can both be
    handled similarly.
    This allows you to drop check constraints on SQLite, though
    it drops all check constraints instead of just the one listed.
  7. Raise an error if attempting to use a Regexp pattern match on a datab…

    jeremyevans committed Jul 25, 2012
    …ase that doesn't support it
    Before, Sequel used the PostgreSQL regexp format on most databases,
    which would probably result in the database raising an error.  This
    makes Sequel raise an exception while producing the SQL.
    This adds Dataset#supports_regexp? for checking for support.  With
    this change, integration tests can be added to check for correct
    behavior, since they can be conditional on the supports_regexp?
  8. Support an emulated trim function

    jeremyevans committed Jul 30, 2012
    This adds support for an emualted trim function.  The only database
    that appears to not support it by default is Microsoft SQL Server,
    so there it is emulated with ltrim and rtrim.
  9. Add Sequel.char_length for an emulated function returning the charact…

    jeremyevans committed Jul 23, 2012
    …er length
    I'm planning on using this feature for some upcoming work, plus
    I've always wanted to add something like this, but never could
    think of a good place to do so.  Now that the SQL::Builders
    module has been added, this seems like a good place.
    The basic reasoning here is that Sequel does a good job making
    database access database agnostic.  However, one area where
    Sequel didn't do a good job before is with database functions.
    While there are quite a few standard SQL functions (including
    char_length), not all databases support them.  This new emulated
    functions feature is a way to get an abstract function object
    that the adapters will literalize into the appopriate function
    call for that database.
    If this new support were around when the extract emulation was added,
    I would have definitely used this for extract.  However, I don't think
    changing the extract code to use an emulated function is worth it.
  10. Refactor SQL::Expression attribute handling

    jeremyevans committed Jul 23, 2012
    This makes it more like the rest of Sequel, copying data into
    the subclass in inherited instead of calling superclass at
Commits on Aug 15, 2012
  1. Allow overriding the convert_tinyint_to_bool setting on a per-Dataset…

    jeremyevans committed Aug 15, 2012
    … basis in the mysql and mysql2 adapters
    Unfortunately, because of the different APIs, the method used for
    the per-Dataset overrides differs between the mysql and mysql2
    adapters.  I was considering making the method name the same, but
    on the mysql adapter, the method needs to take a field argument,
    whereas on the mysql2 adapter, it doesn't, so the API would have
    been different in arity anyway.
    In the mysql adapter, you can override the cast_tinyint_integer?
      def ds.cast_tinyint_integer?(field)
        super && true
    This can force the casting to integer even if the
    convert_tinyint_to_bool setting is true.  Note that you cannot go
    the other way currently, you can't force a casting to boolean
    if the convert_tinyint_to_bool setting is false.  This is due to
    how the conversion procs are handled internally.
    The mysql adapter is flexible in that you can now cast tinyint(3)
    columns to boolean if you want, instead of just tinyint(1)
    In the mysql2 adapter, you can override the convert_tinyint_to_bool?
      def ds.convert_tinyint_to_bool?
    The mysql2 is flexible in that you can override both ways,
    converting to boolean if the default is integer, and integer if the
    default is boolean.
    If you aren't sure which adapter you will be using, you can always
    define both methods.
    While here, enable to tinyint to boolean specs on the mysql2
    adapter.  I guess it was an oversight that this wasn't already done.
  2. Make ValidationFailed and HookFailed exceptions have model method tha…

    jeremyevans committed Aug 15, 2012
    …t returns the related model
    Among other things, this makes it possible to use create and handle
    errors when raise_on_save_failure is true:
      rescue ValidationFailed => e
        model = e.model
        # ...
    Before, you had to do:
        model =>'bar')
    if you wanted to be able to reference the model if the saved failed.
    Since saves can fail for both validations and hooks, extend this
    feature to hooks as well.
    While here, cleanup the exception message for hooks to explicitly
    list which hook raised the error.
  3. Automatically wrap array arguments to most PGArrayOp methods in PGArrays

    jeremyevans committed Aug 15, 2012
    This makes it easier to use the methods.  For example, if you
    want to check if an array contains both 1 and 2:
    Before, you would have to do:
    Likewise, to check if an array contains either 1 or 2:
  4. Add set_column_not_null to alter table generator for marking a column…

    jeremyevans committed Aug 14, 2012
    … as not null
    I think this makes for a nicer API.  Something just feels wrong
    about "set_column_allow_null :column, false".