The :on_update and :on_delete entries for foreign_key can now take strings, which are used literally

This simplifies the logic so that instead of using a case
case statement, the argument is always converted to a string and
processed.  The only behavior changes are for callers that didn't
use one of the symbols previously supported, which resulted in
NO ACTION being used.  The previous behavior is likely to swallow
errors that should be caught, so it should be changed.

Since they are no longer needed, this removes the Database constants
CASCADE, NO_ACTION, SET_DEFAULTS, SET_NULL, and RESTRICT.  That
breaks backwards compatibility too, but nobody should be relying
on those constants.

While here, add a separate method for on_update_clause, simply
because having both :on_delete and :on_update use on_delete_clause
looks wrong.
Model#set_fields and #update_fields now respect :missing=>:skip and :missing=>:raise options for handling missing values

These new options allow set_fields and update_fields to handle more
cases.  :skip is probably more useful of the two options, since it
allows the methods to handle situations previously handled by
set_only and update_only, with a much simpler implementation.

To ease use with web frameworks that use hashes with strings, if
a symbol is given and doesn't exist in the hash, check for the
string version and use that if present.
Add Dataset#to_hash_groups and #select_hash_groups for getting a hash with arrays of matching values

I've needed something like this in multiple projects, and I suspect
it's a reasonably common need that people just use a manual loop
for currently.  This allows you to easily categorize a dataset by a
given column(s), with the value of that column(s) as the hash keys,
and an array of all matching values as the hash values.
Add Database#foreign_key_list for getting foreign key metadata for a given table on SQLite, MySQL, and PostgreSQL

This is the first step in allowing the schema_dumper extension
to dump foreign key constraints when dumping tables.  By default,
only require that the absolute basics, which are the referencing
columns, the referenced table, and the referenced columns.  On
adapters that make the information available, try to get the
constraint name, on delete/update actions, and deferrable
setting.  On SQLite, the referenced columns are not given if
they are the same as the primary key, so make that part of the
API.  This doesn't matter in real life, because when recreating
the constraint, if you provide nil for the referenced columns,
it assumes the primary key.

While adding this, I found that the previous code did not copy
composite foreign key constraints, so fix the code so it does.
Also, I discovered why jdbc/sqlite raises exceptions for
certain PRAGMA calls, it does so when no rows are returned, so
parse the error message string and handle that both for
foreign_key_list and indexes.
Dump foreign key constraints by default when using the schema dumper extension

Using the recently committed foreign key parsing support, make the
schema dumper dump foreign keys by default.  This is not just as
simple as using foreign_key calls.  When you dump foreign keys, you
need to make sure that you dump the tables in topological order,
such that referenced tables come before referencing tables.  You
also need to handle circular dependencies, where table A references
table B and table B references table A.

This patch does both.  It handles circular dependencies by breaking
the easiest dependency by skipping its foreign keys, and then
adding the skipped foreign key constraints manually at the end of
the migration.  However, such migrations can probably not be migrated
down.

Because you often don't want to set up the foreign key constraints
until after migrating data (similar to indexes), add a
dump_foreign_key_migration method for dumping just the foreign
key constraints as a separate migration.  Unfortunately, such a
method cannot be migrated down.

while here, make sure that the dumped down migrations do things
in reverse order of the up migrations.  This wasn't important before,
but is definitely important now that foreign key constraints are
supported.

Currently, foreign keys are not dumped if you are skipping the
dumping of indexes, because foreign keys pointing to non-primary
keys generally are required to be pointing to columns covered by
a unique index (or constraint).  You can override this if
necessary, but anyone dumping indexes separately should probably
dump the foreign key constraints separately too.
Copy foreign key constraints when using bin/sequel -C
Use bigint type instead of integer for Bignum generic type on SQLite

I originally chose to use integer for Bignum on SQLite way back in
2009, but the reasons for doing so are no longer clear to me, and
the description of why it was done no longer makes sense.

The current adapters for sqlite handle this fine except for swift,
and that's due to an issue with dbic++ that I've already filed an
issue for.
Minor identity_map plugin reformatting for readability
Refactor caching plugin

This refactor should ease implementation of some future planned
features.  It adds Model.cache_get_pk and .cache_delete_pk methods
for manipulating the cache directly.  It also makes Model.cache_key
public and moves the error handling into that, greatly simplifying
Model#cache_key.
Refactor model associated object lookup

Break _load_associated_objects into a couple methods for more
focused overriding.  Use one of these methods in the identity_map
plugin, and refactor that so it caches more static information.
Make Model[] and Model[nil] return nil without a database lookup

Previously, these used to send database queries, but it's
impossible for any records to match, so don't do that anymore.
This fixes a bug in the caching extension when Model[nil] was
used.

It's now expected that primary_key_lookup is not called with
a nil value.
Add another identity_map spec, and fix method signature
Add many_to_one_pk_lookup plugin, for using a simple primary key lookup for many_to_one associations (great with caching)

This can be a major speed boost to models that have many_to_one
associations to associated models that use caching, because it
will generally use a cached lookup first.
Add Model#freeze implementation to get a working frozen model object

Before, calling #freeze on a model instance broke a whole bunch
of things, since model instances cache a bunch of things as instance
variables.  This attempts to make it so #freeze gives you a working
read-only object.

Note that this only handles the base and associations plugins.
There are probably plugins that ship with Sequel that are broken
on frozen objects.  Those will be handled on an as-needed basis.
Better subclass handling in {hook,validation}_class_methods plugins

This changes them to set their variables before calling super
instead of after.  Calling them after can break things if another
plugin attempts to create subclass instances inside of inherited.
Add static_cache plugin, for staticly caching all model instances, useful for model tables that don't change

This plugin provides a major speedup for models whose underlying
dataset is static.  It's designed to work well with the the
recently committed many_to_one_pk_lookup plugin.
Add select_remove extension which adds Dataset#select_remove for removing columns/expressions from a dataset selection

I don't think this will be used often enough to go into core
Sequel, and it also has some corner cases that can't be handled
correctly.  However, some people have been asking for it, and it's
not the simplest thing to get correct by hand even for the cases
it does handle correctly, so I think shipping this extension with
Sequel makes sense.
Support for ruby <1.8.7 and PostgreSQL <8.2 is now deprecated and will be removed after 3.34.0 is released
Double speed of Model[pk] for models with simple datasets (most models)

The last time I optimized this, I got a similar speedup by using
static SQL instead of having the dataset generate it.  However,
after doing some profiling, it turns out most of the overhead then
became in the cloning of the dataset due to the use of with_sql
and first.  Skip the dataset cloning by using fetch_rows with
Model.call.

While here, refactor the static SQL handling so that it only
requires a String#dup and Dataset#literal_append call, which
adds an additional small speedup.

With these two changes, I'm getting about 2.1x the previous
performance for model lookups for an in memory SQLite database.

Because Model#simple_pk= and Model#simple_table= now exist as
private methods, they should be used instead of setting the
instance variables directly.
Remove some unnecessary proc activations