sequel 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +51 -1
- data/README.rdoc +2 -2
- data/Rakefile +2 -2
- data/doc/advanced_associations.rdoc +6 -18
- data/doc/release_notes/1.0.txt +38 -0
- data/doc/release_notes/1.1.txt +143 -0
- data/doc/release_notes/1.3.txt +101 -0
- data/doc/release_notes/1.4.0.txt +53 -0
- data/doc/release_notes/1.5.0.txt +155 -0
- data/doc/release_notes/2.0.0.txt +298 -0
- data/doc/release_notes/2.1.0.txt +271 -0
- data/doc/release_notes/2.10.0.txt +328 -0
- data/doc/release_notes/2.11.0.txt +215 -0
- data/doc/release_notes/2.2.0.txt +253 -0
- data/doc/release_notes/2.3.0.txt +88 -0
- data/doc/release_notes/2.4.0.txt +106 -0
- data/doc/release_notes/2.5.0.txt +137 -0
- data/doc/release_notes/2.6.0.txt +157 -0
- data/doc/release_notes/2.7.0.txt +166 -0
- data/doc/release_notes/2.8.0.txt +171 -0
- data/doc/release_notes/2.9.0.txt +97 -0
- data/lib/sequel_core/adapters/ado.rb +3 -0
- data/lib/sequel_core/adapters/db2.rb +0 -11
- data/lib/sequel_core/adapters/dbi.rb +0 -11
- data/lib/sequel_core/adapters/do.rb +0 -12
- data/lib/sequel_core/adapters/firebird.rb +21 -16
- data/lib/sequel_core/adapters/informix.rb +1 -11
- data/lib/sequel_core/adapters/jdbc.rb +1 -13
- data/lib/sequel_core/adapters/jdbc/h2.rb +3 -11
- data/lib/sequel_core/adapters/jdbc/mysql.rb +0 -17
- data/lib/sequel_core/adapters/jdbc/postgresql.rb +3 -15
- data/lib/sequel_core/adapters/mysql.rb +31 -27
- data/lib/sequel_core/adapters/odbc.rb +34 -28
- data/lib/sequel_core/adapters/openbase.rb +0 -11
- data/lib/sequel_core/adapters/oracle.rb +11 -9
- data/lib/sequel_core/adapters/postgres.rb +14 -17
- data/lib/sequel_core/adapters/shared/mssql.rb +6 -15
- data/lib/sequel_core/adapters/shared/mysql.rb +29 -14
- data/lib/sequel_core/adapters/shared/oracle.rb +4 -0
- data/lib/sequel_core/adapters/shared/postgres.rb +30 -35
- data/lib/sequel_core/adapters/shared/progress.rb +4 -0
- data/lib/sequel_core/adapters/shared/sqlite.rb +73 -13
- data/lib/sequel_core/adapters/sqlite.rb +8 -18
- data/lib/sequel_core/adapters/utils/date_format.rb +21 -0
- data/lib/sequel_core/{dataset → adapters/utils}/stored_procedures.rb +0 -0
- data/lib/sequel_core/{dataset → adapters/utils}/unsupported.rb +0 -0
- data/lib/sequel_core/core_ext.rb +1 -1
- data/lib/sequel_core/core_sql.rb +9 -4
- data/lib/sequel_core/database.rb +63 -62
- data/lib/sequel_core/dataset.rb +9 -4
- data/lib/sequel_core/dataset/convenience.rb +10 -9
- data/lib/sequel_core/dataset/prepared_statements.rb +1 -1
- data/lib/sequel_core/dataset/sql.rb +130 -36
- data/lib/sequel_core/schema/sql.rb +2 -2
- data/lib/sequel_core/sql.rb +44 -51
- data/lib/sequel_core/version.rb +1 -1
- data/lib/sequel_model/associations.rb +25 -17
- data/lib/sequel_model/base.rb +35 -7
- data/lib/sequel_model/caching.rb +1 -6
- data/lib/sequel_model/record.rb +23 -5
- data/lib/sequel_model/validations.rb +20 -5
- data/spec/adapters/firebird_spec.rb +6 -1
- data/spec/adapters/mysql_spec.rb +12 -0
- data/spec/adapters/postgres_spec.rb +2 -2
- data/spec/adapters/sqlite_spec.rb +81 -2
- data/spec/integration/dataset_test.rb +2 -2
- data/spec/integration/type_test.rb +12 -2
- data/spec/sequel_core/core_sql_spec.rb +46 -12
- data/spec/sequel_core/database_spec.rb +24 -12
- data/spec/sequel_core/dataset_spec.rb +82 -32
- data/spec/sequel_core/schema_spec.rb +16 -0
- data/spec/sequel_model/associations_spec.rb +89 -0
- data/spec/sequel_model/base_spec.rb +66 -0
- data/spec/sequel_model/eager_loading_spec.rb +32 -0
- data/spec/sequel_model/record_spec.rb +9 -9
- data/spec/sequel_model/spec_helper.rb +3 -0
- data/spec/sequel_model/validations_spec.rb +63 -3
- metadata +41 -4
@@ -0,0 +1,88 @@
|
|
1
|
+
JRuby and Ruby 1.9 Officially Supported
|
2
|
+
---------------------------------------
|
3
|
+
|
4
|
+
Sequel now officially supports JRuby 1.1.3 and Ruby 1.9 (svn revision
|
5
|
+
18194 at least). Using JRuby with the JDBC adapter, PostgreSQL,
|
6
|
+
MySQL, and SQLite now enjoy almost full support, though not
|
7
|
+
everything works the same as using the native adapter. Depending on
|
8
|
+
what you are doing, it may make sense to use postgres-pr on JRuby
|
9
|
+
instead of PostgreSQL-JDBC.
|
10
|
+
|
11
|
+
To use the new JDBC support, the database connection string you give
|
12
|
+
Sequel is now passed directly to JDBC, here are a few examples:
|
13
|
+
|
14
|
+
Sequel.connect('jdbc:postgresql://host/database?user=*&password=*')
|
15
|
+
Sequel.connect('jdbc:mysql://host/database?user=*&password=*')
|
16
|
+
Sequel.connect('jdbc:sqlite::memory:')
|
17
|
+
Sequel.connect('jdbc:sqlite:relative/path.db')
|
18
|
+
Sequel.connect('jdbc:sqlite:/absolute/path.db')
|
19
|
+
|
20
|
+
Single Gem
|
21
|
+
----------
|
22
|
+
|
23
|
+
Sequel is now distributed as a single gem named sequel, by combining
|
24
|
+
the previous sequel_core and sequel gems. You can still just
|
25
|
+
"require 'sequel_core'" if you don't want the model functionality.
|
26
|
+
|
27
|
+
Database Adapter Improvements
|
28
|
+
-----------------------------
|
29
|
+
|
30
|
+
* Dataset#empty? now works using the MySQL adapter.
|
31
|
+
|
32
|
+
* The Oracle adapter now works with a nonstandard database port.
|
33
|
+
|
34
|
+
* The JDBC adapter should load JDBC drivers automatically for
|
35
|
+
PostgreSQL, MySQL, SQLite, Oracle, and MSSQL. For PostgreSQL,
|
36
|
+
MySQL, and SQLite, the jdbc-* gem can be used, for the others, you
|
37
|
+
must have the correct .jar in your CLASSPATH.
|
38
|
+
|
39
|
+
* The PostgreSQL adapter no longer raises an error when inserting
|
40
|
+
records into a table without a primary key.
|
41
|
+
|
42
|
+
* Database#disconnect now works for the ADO adapter.
|
43
|
+
|
44
|
+
* The ADO adapter no longer raises an error if the dataset contains
|
45
|
+
no records.
|
46
|
+
|
47
|
+
* The ODBC adapter no longer errors when converting ::ODBC::Time
|
48
|
+
values.
|
49
|
+
|
50
|
+
Backwards Incompatible Changes
|
51
|
+
------------------------------
|
52
|
+
|
53
|
+
* Sequel::Worker has been removed. There are no known users, and the
|
54
|
+
specs caused problems on JRuby.
|
55
|
+
|
56
|
+
* Assigning an empty string to a non-string, non-blob model attribute
|
57
|
+
converts it to nil by default. You can use
|
58
|
+
"Model.typecast_empty_string_to_nil = false" to get the old
|
59
|
+
behavior. This should make web development with Sequel
|
60
|
+
significantly easier, hopefully at no expense to other uses.
|
61
|
+
|
62
|
+
* Database.uri_to_options is now a private class method.
|
63
|
+
|
64
|
+
* Model.create_table! now acts the same as Database.create_table!,
|
65
|
+
dropping the table unconditionally and then creating it. This was
|
66
|
+
done for consistency. If you are using Model.create_table! in
|
67
|
+
production code, you should change it to
|
68
|
+
"Model.create_table unless Model.table_exists?", otherwise you risk
|
69
|
+
wiping out your production data. I recommended you use the
|
70
|
+
migration feature instead of Model.set_schema, as that handles
|
71
|
+
altering existing tables.
|
72
|
+
|
73
|
+
Other Notable Changes
|
74
|
+
---------------------
|
75
|
+
|
76
|
+
* Using validates_length_of more than once on the same attribute with
|
77
|
+
different options without a tag no longer causes the first use to
|
78
|
+
be ignored. This was a side effect of the validation tags added
|
79
|
+
in 2.2.0.
|
80
|
+
|
81
|
+
* Other than the adapters, Sequel now has 100% code coverage (line
|
82
|
+
coverage).
|
83
|
+
|
84
|
+
* Model#set* methods now return self.
|
85
|
+
|
86
|
+
* An integration test suite was added, testing Sequel against a live
|
87
|
+
database with nothing mocked, which helped greatly when testing the
|
88
|
+
new support for JDBC adapters.
|
@@ -0,0 +1,106 @@
|
|
1
|
+
Prepared Statements/Bound Variables
|
2
|
+
===================================
|
3
|
+
|
4
|
+
Sequel now supports prepared statements and bound variables. No
|
5
|
+
matter which database you are using, Sequel uses exactly the same API.
|
6
|
+
To specify placeholders, you use the :$placeholder syntax:
|
7
|
+
|
8
|
+
ds = DB[:items].filter(:name=>:$n)
|
9
|
+
|
10
|
+
To use a bound variable:
|
11
|
+
|
12
|
+
ds.call(:select, :n=>'Jim')
|
13
|
+
|
14
|
+
This will do the equivalent of selecting records that have the name
|
15
|
+
'Jim'. In addition to :select, you can use :first or :delete. There
|
16
|
+
is also support for bound variables when inserting or updating
|
17
|
+
records:
|
18
|
+
|
19
|
+
ds.call(:update, {:n=>'Jim', :new_n=>'Bob'}, :name=>:$new_n)
|
20
|
+
|
21
|
+
Which will update all records that have the name 'Jim' to have the
|
22
|
+
name 'Bob'.
|
23
|
+
|
24
|
+
Prepared statement support is very similar to bound variable support,
|
25
|
+
except that the statement is first prepared with a name:
|
26
|
+
|
27
|
+
ps = ds.prepare(:select, :select_by_name)
|
28
|
+
|
29
|
+
It is then called later with the bound arguments to use:
|
30
|
+
|
31
|
+
ps.call(:n=>'Jim')
|
32
|
+
DB.call(:select_by_name, :n=>'Jim') # same as above
|
33
|
+
|
34
|
+
For inserting or updating, the hash to use when inserting or updating
|
35
|
+
is given to prepare:
|
36
|
+
|
37
|
+
ps2 = ds.prepare(:update, :update_name, :name=>:$new_n)
|
38
|
+
ps2.call(:n=>'Jim', :new_n=>'Bob')
|
39
|
+
|
40
|
+
There is some level of native support for these features in the
|
41
|
+
PostgreSQL, MySQL, SQLite, and JDBC adapters. For other adapters,
|
42
|
+
support is emulated, but it shouldn't be too difficult to add native
|
43
|
+
support for them.
|
44
|
+
|
45
|
+
For more details see:
|
46
|
+
http://sequel.rubyforge.org/rdoc/files/doc/prepared_statements_rdoc.html
|
47
|
+
|
48
|
+
Read-Only Slave/Writable Master and Database Sharding
|
49
|
+
=====================================================
|
50
|
+
|
51
|
+
Sequel now has built in support for master/slave database
|
52
|
+
configurations, just by setting an option in Sequel.connect:
|
53
|
+
|
54
|
+
DB=Sequel.connect('postgres://master_server/database', \
|
55
|
+
:servers=>{:read_only=>{:host=>'slave_server'}})
|
56
|
+
|
57
|
+
That will use slave_server for SELECT queries and master_server for
|
58
|
+
other queries. It's fairly easy to use multiple slaves or even
|
59
|
+
multiple masters, examples are included in the link below.
|
60
|
+
|
61
|
+
Sharding support requires some code other than the database
|
62
|
+
configuration, but is still fairly simple. For example, to set up
|
63
|
+
a 16 shard configuration based on a hex character:
|
64
|
+
|
65
|
+
servers = {}
|
66
|
+
(('0'..'9').to_a + ('a'..'f').to_a).each do |hex|
|
67
|
+
servers[hex.to_sym] = {:host=>"hash_host_#{hex}"}
|
68
|
+
end
|
69
|
+
DB=Sequel.connect('postgres://hash_host/hashes', :servers=>servers)
|
70
|
+
|
71
|
+
To set which shard to use for a query, use the Dataset#server method:
|
72
|
+
|
73
|
+
DB[:hashes].server(:a).filter(:hash=>/31337/)
|
74
|
+
|
75
|
+
For more details see:
|
76
|
+
http://sequel.rubyforge.org/rdoc/files/doc/sharding_rdoc.html
|
77
|
+
|
78
|
+
Other Changes
|
79
|
+
=============
|
80
|
+
|
81
|
+
* The sequel.rubyforge.org website has a new design thanks to boof.
|
82
|
+
The online RDoc is now located at http://sequel.rubyforge.org/rdoc.
|
83
|
+
|
84
|
+
* Support was added for anonymous column names in the ADO adapter.
|
85
|
+
|
86
|
+
* Better MSSQL support in the ADO, ODBC, and JDBC adapters. The
|
87
|
+
odbc_mssql adapter has been removed. If you use MSSQL with ODBC,
|
88
|
+
please use the odbc adapter with a :db_type=>'mssql' option.
|
89
|
+
|
90
|
+
* The following Sequel::Error exception subclasses were removed:
|
91
|
+
InvalidExpression, InvalidFilter, InvalidJoinType, and WorkerStop.
|
92
|
+
|
93
|
+
* Documentation was added for the PostgreSQL, MySQL, SQLite, and
|
94
|
+
JDBC adapters.
|
95
|
+
|
96
|
+
* Various internal interfaces were refactored. For example, if you
|
97
|
+
use an adapter not included with Sequel, it probably won't work
|
98
|
+
until you update it to the new internal API.
|
99
|
+
|
100
|
+
* Many low level methods (such as Database#transaction), now take
|
101
|
+
an optional server argument to indicate which server to use.
|
102
|
+
|
103
|
+
* Model plugins that have a DatasetMethods module with non-public
|
104
|
+
methods no longer have Model methods created that call those
|
105
|
+
methods.
|
106
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
New Features
|
2
|
+
------------
|
3
|
+
|
4
|
+
* The values that are used to insert/update records can now be
|
5
|
+
scoped similar to how filter expressions can be scoped.
|
6
|
+
set_defaults is used to set defaults which can be overridden,
|
7
|
+
and set_overrides is used to set defaults which cannot be
|
8
|
+
overridden:
|
9
|
+
|
10
|
+
DB[:t].set_defaults(:x=>1).insert_sql
|
11
|
+
# => INSERT INTO t (x) VALUES (1)
|
12
|
+
DB[:t].set_defaults(:x=>1).insert_sql(:x=>2)
|
13
|
+
# => INSERT INTO t (x) VALUES (2)
|
14
|
+
DB[:t].set_defaults(:x=>1).insert_sql(:y=>2)
|
15
|
+
# => INSERT INTO t (x, y) VALUES (1, 2)
|
16
|
+
DB[:t].set_overrides(:x=>1).insert_sql(:x=>2)
|
17
|
+
# => INSERT INTO t (x) VALUES (1)
|
18
|
+
|
19
|
+
The difference between set_defaults and set_overrides is that
|
20
|
+
with set_defaults, the last value takes precedence, while with
|
21
|
+
set_overrides, the first value takes precedence.
|
22
|
+
|
23
|
+
* The schema generators now support creating and altering tables
|
24
|
+
with composite primary and/or foreign keys:
|
25
|
+
|
26
|
+
DB.create_table(:items) do
|
27
|
+
integer :id
|
28
|
+
text :name
|
29
|
+
primary_key [:id, :name]
|
30
|
+
foreign_key [:id, :name], :other_table, \
|
31
|
+
:key=>[:item_id, :item_name]
|
32
|
+
end
|
33
|
+
|
34
|
+
DB.alter_table(:items) do
|
35
|
+
add_primary_key [:id, :name]
|
36
|
+
add_foreign_key [:id, :name], :other_table, \
|
37
|
+
:key=>[:item_id, :item_name]
|
38
|
+
end
|
39
|
+
|
40
|
+
* The AlterTableGenerator now supports unique constraints:
|
41
|
+
|
42
|
+
DB.alter_table(:items) do
|
43
|
+
add_unique_constraint [:aaa, :bbb, :ccc], :name => :con3
|
44
|
+
end
|
45
|
+
|
46
|
+
* The schema generators now support ON UPDATE (previously, they only
|
47
|
+
supported ON DELETE):
|
48
|
+
|
49
|
+
DB.create_table(:items) do
|
50
|
+
foreign_key :project_id, :projects, :on_update => :cascade
|
51
|
+
end
|
52
|
+
|
53
|
+
* When connecting to a PostgreSQL server version 8.2 and higher,
|
54
|
+
Sequel now uses the INSERT ... RETURNING ... syntax, which should
|
55
|
+
speed up row inserts on PostgreSQL. In addition, Sequel Models
|
56
|
+
use RETURNING * to speed up model object creation.
|
57
|
+
|
58
|
+
* You can now validate multiple attributes at once. This is useful
|
59
|
+
if the combination of two or more attribute values is important,
|
60
|
+
such as checking the uniqueness of multiple columns.
|
61
|
+
validates_uniqueness_of now supports this directly:
|
62
|
+
|
63
|
+
validates_uniqueness_of [:column1, :column2]
|
64
|
+
|
65
|
+
This protects against the database having multiple rows with the
|
66
|
+
same values for both :column1 and :column2. This is different
|
67
|
+
from:
|
68
|
+
|
69
|
+
validates_uniqueness_of :column1, :column2
|
70
|
+
|
71
|
+
Which checks that the value of column1 is unique in the table, and
|
72
|
+
that the value of column2 is unique in the table (which is much
|
73
|
+
more restrictive).
|
74
|
+
|
75
|
+
Other Improvements
|
76
|
+
------------------
|
77
|
+
|
78
|
+
* Dataset methods insert_sql, delete_sql, and update_sql respect the
|
79
|
+
:sql option, allowing you to do things such as:
|
80
|
+
|
81
|
+
ds = DB['INSERT INTO t (time) VALUES (CURRENT_TIMESTAMP)']
|
82
|
+
ds.insert
|
83
|
+
ds.insert
|
84
|
+
|
85
|
+
* The database adapters (at least MySQL, PostgreSQL, SQLite, and
|
86
|
+
JDBC) generally raise Sequel::DatabaseError for database problems,
|
87
|
+
making it easier to tell what is a true database error versus an
|
88
|
+
error raised by Sequel itself.
|
89
|
+
|
90
|
+
* Sequel uses the async features of ruby-pg so that the entire
|
91
|
+
interpreter is not blocked while waiting for the results of
|
92
|
+
queries.
|
93
|
+
|
94
|
+
* Sequel now supports the 2008.08.17 version of ruby-pg.
|
95
|
+
|
96
|
+
* MSSQL support has been improved when using the ODBC and ADO
|
97
|
+
adapters.
|
98
|
+
|
99
|
+
* Index names are quoted and creating or dropping indexes.
|
100
|
+
|
101
|
+
* Automatically generated column accessor methods no longer override
|
102
|
+
instance methods specified by plugins.
|
103
|
+
|
104
|
+
* Inserting a row with an already specified primary key inside a
|
105
|
+
transaction now works correctly when using PostgreSQL.
|
106
|
+
|
107
|
+
* before_save and before_update hooks now work as expected when using
|
108
|
+
save_changes.
|
109
|
+
|
110
|
+
* count and paginate now work correctly on graphed datasets.
|
111
|
+
|
112
|
+
Backwards Compatibility
|
113
|
+
-----------------------
|
114
|
+
|
115
|
+
* The SQLite adapter now raises Sequel::DatabaseError instead of
|
116
|
+
Sequel::Error::InvalidStatement whenever an SQLite3::Exception is
|
117
|
+
raised by the SQLite3 driver.
|
118
|
+
|
119
|
+
* Date and DateTime conversions now convert 2 digit years. To revert
|
120
|
+
to the previous behavior:
|
121
|
+
|
122
|
+
Sequel.convert_two_digit_years = false
|
123
|
+
|
124
|
+
Note that Ruby 1.8 and 1.9 handle Date parsing differently, so
|
125
|
+
there is no backwards compatibility change for Ruby 1.9. However,
|
126
|
+
this also means that the MM/DD/YY date syntax commonly used in the
|
127
|
+
United States is not always parsed correctly on Ruby 1.9, greatly
|
128
|
+
limiting the use of 2 digit year conversion.
|
129
|
+
|
130
|
+
* You can no longer abuse the SQL function syntax for specifying
|
131
|
+
database types. For example, you must change:
|
132
|
+
|
133
|
+
:type=>:varchar[255]
|
134
|
+
|
135
|
+
to:
|
136
|
+
|
137
|
+
:type=>:varchar, :size=>255
|
@@ -0,0 +1,157 @@
|
|
1
|
+
New Features
|
2
|
+
------------
|
3
|
+
|
4
|
+
* Schema parsing was refactored, resulting in a huge speedup when
|
5
|
+
using MySQL. MySQL now uses the DESCRIBE statement instead of the
|
6
|
+
INFORMATION_SCHEMA. PostgreSQL now uses the pg_* system catalogs
|
7
|
+
instead of the INFORMATION schema.
|
8
|
+
|
9
|
+
* The schema information now includes the :primary_key field. Models
|
10
|
+
now use this field to automatically determine the primary key for
|
11
|
+
a table, so it no longer needs to be specified explicitly. Models
|
12
|
+
even handle the composite primary key case.
|
13
|
+
|
14
|
+
* The raise_on_typecast_failure switch was added, with it being true
|
15
|
+
by default (so no change in behavior). This allows the user to
|
16
|
+
silently ignore errors when typecasting fails, at the global, class,
|
17
|
+
and instance levels.
|
18
|
+
|
19
|
+
Sequel::Model.raise_on_typecast_failure = false # Global
|
20
|
+
Artist.raise_on_typecast_failure = true # Class
|
21
|
+
artist = Artist.new
|
22
|
+
artist.raise_on_typecast_failure = false # Instance
|
23
|
+
|
24
|
+
Album.raise_on_typecast_failure = true
|
25
|
+
Album.new(:numtracks=>'a') # => raises Sequel::Error::InvalidValue
|
26
|
+
Album.raise_on_typecast_failure = false
|
27
|
+
Album.new(:numtracks=>'a') # => #<Album @values={:numtracks=>"a"}>
|
28
|
+
|
29
|
+
* Associations' orders are now respected when eager loading via
|
30
|
+
eager_graph. Sequel will qualify the columns in the order with
|
31
|
+
the alias being used, so you can have overlapping columns when
|
32
|
+
eager loading multiple associations.
|
33
|
+
|
34
|
+
Artist.one_to_many :albums, :order=>:name
|
35
|
+
Album.one_to_many :tracks, :order=>:number
|
36
|
+
Artist.order(:artists__name).eager_graph(:albums=>:tracks).sql
|
37
|
+
# => ... ORDER BY artists.name, albums.name, tracks.number
|
38
|
+
|
39
|
+
* The support for CASE expressions has been enhanced by allowing the
|
40
|
+
use of an optional expression:
|
41
|
+
|
42
|
+
{1=>2}.case(0, :x)
|
43
|
+
# => CASE x WHEN 1 THEN 2 ELSE 0 END
|
44
|
+
[[:a, 1], [:b, 2], [:c, 3]].case(4, :y)
|
45
|
+
# => CASE y WHEN a THEN 1 WHEN b THEN 2 WHEN c THEN 3 ELSE 4 END
|
46
|
+
|
47
|
+
Previously, to get something equivalent to this, you had to do:
|
48
|
+
|
49
|
+
{{:x=>1}=>2}.case(0)
|
50
|
+
# => CASE WHEN (x = 1) THEN 2 ELSE 0 END
|
51
|
+
[[{:y=>:a}, 1], [{:y=>:b}, 2], [{:y=>:c}, 3]].case(4)
|
52
|
+
# => CASE WHEN (y = a) THEN 1 WHEN (y = b) THEN 2 WHEN (y = c)
|
53
|
+
THEN 3 ELSE 4 END
|
54
|
+
|
55
|
+
* You can now change the NULL/NOT NULL value of an existing column
|
56
|
+
using the set_column_allow_null method.
|
57
|
+
|
58
|
+
# Set NOT NULL
|
59
|
+
DB.alter_table(:artists){set_column_allow_null :name, false}
|
60
|
+
# Set NULL
|
61
|
+
DB.alter_table(:artists){set_column_allow_null :name, true}
|
62
|
+
|
63
|
+
* You can now get the schema information for a table in a non-public
|
64
|
+
schema in PostgreSQL using the implicit :schema__table syntax.
|
65
|
+
Before, the :schema option had to be given explicitly to
|
66
|
+
Database#schema. This allows models to get schema information for
|
67
|
+
tables outside the public schema.
|
68
|
+
|
69
|
+
* Transactions are now supported on MSSQL.
|
70
|
+
|
71
|
+
* Dataset#tables now returns all tables in the database for MySQL
|
72
|
+
databases accessed via JDBC.
|
73
|
+
|
74
|
+
* Database#drop_view can now drop multiple views at once.
|
75
|
+
|
76
|
+
Other Improvements
|
77
|
+
------------------
|
78
|
+
|
79
|
+
* The SQLite adapter now respects the Sequel.datetime_class option
|
80
|
+
for timestamp and datetime columns.
|
81
|
+
|
82
|
+
* Adding a unique constraint no longer explicity creates a unique
|
83
|
+
index. If you want a unique index, use index :unique=>true.
|
84
|
+
|
85
|
+
* If no language is specified when creating a full text index on
|
86
|
+
PostgreSQL, the simple language is assumed.
|
87
|
+
|
88
|
+
* Errors when typecasting fails are now Sequel::Error::InvalidValue
|
89
|
+
instead of the more generic Sequel::Error.
|
90
|
+
|
91
|
+
* Specifying constraints now works correctly for all types of
|
92
|
+
arguments. Previously, it did not work unless a block or
|
93
|
+
interpolated string were used.
|
94
|
+
|
95
|
+
* Loading an association with the same name as a table in the FROM
|
96
|
+
clause no longer causes an error.
|
97
|
+
|
98
|
+
* When eagerly loading many_to_one associations where no objects have
|
99
|
+
an associated object, the negative lookup is now cached.
|
100
|
+
|
101
|
+
* String keys can now be used with Dataset#multi_insert, just like
|
102
|
+
they can be used for Dataset#insert.
|
103
|
+
|
104
|
+
* Dataset#join_table now generates the correct SQL when doing the
|
105
|
+
first join to a dataset where the first source is a dataset, when
|
106
|
+
an unqualified column is used in the conditions.
|
107
|
+
|
108
|
+
* Cascading associations after *_to_many associations can now be
|
109
|
+
eagerly loaded via eager_graph.
|
110
|
+
|
111
|
+
* Eagerly loading *_to_many associations that are cascaded behind a
|
112
|
+
many_to_one association now have their duplicates removed if a
|
113
|
+
cartesian product join is done.
|
114
|
+
|
115
|
+
* The SQLite adapter now uses string literals in all of the AS
|
116
|
+
clauses. While the SQL standard specifies that identifiers should
|
117
|
+
be used, SQLite documentation explicitly states that string
|
118
|
+
literals are expected (though it generally works with identifiers
|
119
|
+
by converting them implicitly).
|
120
|
+
|
121
|
+
* Database methods that modify the schema now remove the cached
|
122
|
+
schema entry.
|
123
|
+
|
124
|
+
* The hash keys that Database#schema returns when no table is
|
125
|
+
requested are now always supposed to be symbols.
|
126
|
+
|
127
|
+
* The generation of SQL for composite foreign keys on MySQL has been
|
128
|
+
fixed.
|
129
|
+
|
130
|
+
* A schema.rdoc file was added to the documentation explaining the
|
131
|
+
various parts of Sequel related to schema generation and
|
132
|
+
modification and how they interact
|
133
|
+
(http://sequel.rubyforge.org/rdoc/files/doc/schema_rdoc.html).
|
134
|
+
|
135
|
+
* The RDoc template for the website was changed from the default
|
136
|
+
template to the hanna template.
|
137
|
+
|
138
|
+
Backwards Compatibility
|
139
|
+
-----------------------
|
140
|
+
|
141
|
+
* The :numeric_precision and :max_chars schema entries have been
|
142
|
+
removed. Use the :db_type entry to determine this information,
|
143
|
+
if available.
|
144
|
+
|
145
|
+
* The SQLite adapter used to always return Time instances for
|
146
|
+
timestamp types, even if Sequel.datetime_class was DateTime. For
|
147
|
+
datetime types it always returned a DateTime instance. It
|
148
|
+
now returns an instance of Sequel.datetime_class in both cases.
|
149
|
+
|
150
|
+
* It's possible that the including of associations' orders when eager
|
151
|
+
loading via eager_graph could cause problems. You can use the
|
152
|
+
:order_eager_graph=>false option to not use the :order option when
|
153
|
+
eager loading via :eager_graph.
|
154
|
+
|
155
|
+
* There were small changes in SQL creation where the AS keyword is
|
156
|
+
now used explicitly. These should have no effect, but could break
|
157
|
+
tests for explicit SQL.
|