sequel 3.28.0 → 3.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/CHANGELOG +119 -3
  2. data/Rakefile +5 -3
  3. data/bin/sequel +1 -5
  4. data/doc/model_hooks.rdoc +9 -1
  5. data/doc/opening_databases.rdoc +49 -40
  6. data/doc/prepared_statements.rdoc +27 -6
  7. data/doc/release_notes/3.28.0.txt +2 -2
  8. data/doc/release_notes/3.29.0.txt +459 -0
  9. data/doc/sharding.rdoc +7 -1
  10. data/doc/testing.rdoc +18 -9
  11. data/doc/transactions.rdoc +41 -1
  12. data/lib/sequel/adapters/ado.rb +28 -17
  13. data/lib/sequel/adapters/ado/mssql.rb +18 -6
  14. data/lib/sequel/adapters/amalgalite.rb +11 -7
  15. data/lib/sequel/adapters/db2.rb +122 -70
  16. data/lib/sequel/adapters/dbi.rb +15 -15
  17. data/lib/sequel/adapters/do.rb +5 -36
  18. data/lib/sequel/adapters/do/mysql.rb +0 -5
  19. data/lib/sequel/adapters/do/postgres.rb +0 -5
  20. data/lib/sequel/adapters/do/sqlite.rb +0 -5
  21. data/lib/sequel/adapters/firebird.rb +3 -6
  22. data/lib/sequel/adapters/ibmdb.rb +24 -16
  23. data/lib/sequel/adapters/informix.rb +2 -4
  24. data/lib/sequel/adapters/jdbc.rb +47 -11
  25. data/lib/sequel/adapters/jdbc/as400.rb +5 -24
  26. data/lib/sequel/adapters/jdbc/db2.rb +0 -5
  27. data/lib/sequel/adapters/jdbc/derby.rb +217 -0
  28. data/lib/sequel/adapters/jdbc/firebird.rb +0 -5
  29. data/lib/sequel/adapters/jdbc/h2.rb +10 -12
  30. data/lib/sequel/adapters/jdbc/hsqldb.rb +166 -0
  31. data/lib/sequel/adapters/jdbc/informix.rb +0 -5
  32. data/lib/sequel/adapters/jdbc/jtds.rb +0 -5
  33. data/lib/sequel/adapters/jdbc/mysql.rb +0 -10
  34. data/lib/sequel/adapters/jdbc/oracle.rb +70 -3
  35. data/lib/sequel/adapters/jdbc/postgresql.rb +0 -11
  36. data/lib/sequel/adapters/jdbc/sqlite.rb +0 -5
  37. data/lib/sequel/adapters/jdbc/sqlserver.rb +0 -5
  38. data/lib/sequel/adapters/jdbc/transactions.rb +56 -7
  39. data/lib/sequel/adapters/mock.rb +315 -0
  40. data/lib/sequel/adapters/mysql.rb +64 -51
  41. data/lib/sequel/adapters/mysql2.rb +15 -9
  42. data/lib/sequel/adapters/odbc.rb +13 -6
  43. data/lib/sequel/adapters/odbc/db2.rb +0 -4
  44. data/lib/sequel/adapters/odbc/mssql.rb +0 -5
  45. data/lib/sequel/adapters/openbase.rb +2 -4
  46. data/lib/sequel/adapters/oracle.rb +333 -51
  47. data/lib/sequel/adapters/postgres.rb +80 -27
  48. data/lib/sequel/adapters/shared/access.rb +0 -6
  49. data/lib/sequel/adapters/shared/db2.rb +13 -15
  50. data/lib/sequel/adapters/shared/firebird.rb +6 -6
  51. data/lib/sequel/adapters/shared/mssql.rb +23 -18
  52. data/lib/sequel/adapters/shared/mysql.rb +6 -6
  53. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +6 -0
  54. data/lib/sequel/adapters/shared/oracle.rb +185 -30
  55. data/lib/sequel/adapters/shared/postgres.rb +35 -18
  56. data/lib/sequel/adapters/shared/progress.rb +0 -6
  57. data/lib/sequel/adapters/shared/sqlite.rb +116 -37
  58. data/lib/sequel/adapters/sqlite.rb +16 -8
  59. data/lib/sequel/adapters/swift.rb +5 -5
  60. data/lib/sequel/adapters/swift/mysql.rb +0 -5
  61. data/lib/sequel/adapters/swift/postgres.rb +0 -5
  62. data/lib/sequel/adapters/swift/sqlite.rb +6 -4
  63. data/lib/sequel/adapters/tinytds.rb +13 -10
  64. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +8 -0
  65. data/lib/sequel/core.rb +40 -0
  66. data/lib/sequel/database/connecting.rb +1 -2
  67. data/lib/sequel/database/dataset.rb +3 -3
  68. data/lib/sequel/database/dataset_defaults.rb +58 -0
  69. data/lib/sequel/database/misc.rb +62 -2
  70. data/lib/sequel/database/query.rb +113 -49
  71. data/lib/sequel/database/schema_methods.rb +7 -2
  72. data/lib/sequel/dataset/actions.rb +37 -19
  73. data/lib/sequel/dataset/features.rb +24 -0
  74. data/lib/sequel/dataset/graph.rb +7 -6
  75. data/lib/sequel/dataset/misc.rb +11 -3
  76. data/lib/sequel/dataset/mutation.rb +2 -3
  77. data/lib/sequel/dataset/prepared_statements.rb +6 -4
  78. data/lib/sequel/dataset/query.rb +46 -15
  79. data/lib/sequel/dataset/sql.rb +28 -4
  80. data/lib/sequel/extensions/named_timezones.rb +5 -0
  81. data/lib/sequel/extensions/thread_local_timezones.rb +1 -1
  82. data/lib/sequel/model.rb +2 -1
  83. data/lib/sequel/model/associations.rb +115 -33
  84. data/lib/sequel/model/base.rb +91 -31
  85. data/lib/sequel/plugins/class_table_inheritance.rb +4 -4
  86. data/lib/sequel/plugins/dataset_associations.rb +100 -0
  87. data/lib/sequel/plugins/force_encoding.rb +6 -6
  88. data/lib/sequel/plugins/identity_map.rb +1 -1
  89. data/lib/sequel/plugins/many_through_many.rb +6 -10
  90. data/lib/sequel/plugins/prepared_statements.rb +12 -1
  91. data/lib/sequel/plugins/prepared_statements_associations.rb +1 -1
  92. data/lib/sequel/plugins/rcte_tree.rb +29 -15
  93. data/lib/sequel/plugins/serialization.rb +6 -1
  94. data/lib/sequel/plugins/sharding.rb +0 -5
  95. data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
  96. data/lib/sequel/plugins/typecast_on_load.rb +9 -12
  97. data/lib/sequel/plugins/update_primary_key.rb +1 -1
  98. data/lib/sequel/timezones.rb +42 -42
  99. data/lib/sequel/version.rb +1 -1
  100. data/spec/adapters/mssql_spec.rb +29 -29
  101. data/spec/adapters/mysql_spec.rb +86 -104
  102. data/spec/adapters/oracle_spec.rb +48 -76
  103. data/spec/adapters/postgres_spec.rb +98 -33
  104. data/spec/adapters/spec_helper.rb +0 -5
  105. data/spec/adapters/sqlite_spec.rb +24 -21
  106. data/spec/core/connection_pool_spec.rb +9 -15
  107. data/spec/core/core_sql_spec.rb +20 -31
  108. data/spec/core/database_spec.rb +491 -227
  109. data/spec/core/dataset_spec.rb +638 -1051
  110. data/spec/core/expression_filters_spec.rb +0 -1
  111. data/spec/core/mock_adapter_spec.rb +378 -0
  112. data/spec/core/object_graph_spec.rb +48 -114
  113. data/spec/core/schema_generator_spec.rb +3 -3
  114. data/spec/core/schema_spec.rb +51 -114
  115. data/spec/core/spec_helper.rb +3 -90
  116. data/spec/extensions/class_table_inheritance_spec.rb +1 -1
  117. data/spec/extensions/dataset_associations_spec.rb +199 -0
  118. data/spec/extensions/instance_hooks_spec.rb +71 -0
  119. data/spec/extensions/named_timezones_spec.rb +22 -2
  120. data/spec/extensions/nested_attributes_spec.rb +3 -0
  121. data/spec/extensions/schema_spec.rb +1 -1
  122. data/spec/extensions/serialization_modification_detection_spec.rb +1 -0
  123. data/spec/extensions/serialization_spec.rb +5 -8
  124. data/spec/extensions/spec_helper.rb +4 -0
  125. data/spec/extensions/thread_local_timezones_spec.rb +22 -2
  126. data/spec/extensions/typecast_on_load_spec.rb +1 -6
  127. data/spec/integration/associations_test.rb +123 -12
  128. data/spec/integration/dataset_test.rb +140 -47
  129. data/spec/integration/eager_loader_test.rb +19 -21
  130. data/spec/integration/model_test.rb +80 -1
  131. data/spec/integration/plugin_test.rb +179 -128
  132. data/spec/integration/prepared_statement_test.rb +92 -91
  133. data/spec/integration/schema_test.rb +42 -23
  134. data/spec/integration/spec_helper.rb +25 -31
  135. data/spec/integration/timezone_test.rb +38 -12
  136. data/spec/integration/transaction_test.rb +161 -34
  137. data/spec/integration/type_test.rb +3 -3
  138. data/spec/model/association_reflection_spec.rb +83 -7
  139. data/spec/model/associations_spec.rb +393 -676
  140. data/spec/model/base_spec.rb +186 -116
  141. data/spec/model/dataset_methods_spec.rb +7 -27
  142. data/spec/model/eager_loading_spec.rb +343 -867
  143. data/spec/model/hooks_spec.rb +160 -79
  144. data/spec/model/model_spec.rb +118 -165
  145. data/spec/model/plugins_spec.rb +7 -13
  146. data/spec/model/record_spec.rb +138 -207
  147. data/spec/model/spec_helper.rb +10 -73
  148. metadata +14 -8
data/CHANGELOG CHANGED
@@ -1,3 +1,119 @@
1
+ === 3.29.0 (2011-11-01)
2
+
3
+ * Allow Model.dataset_module to take a Module instance (jeremyevans)
4
+
5
+ * Apply Model.[] optimization in more cases (jeremyevans)
6
+
7
+ * Fix Model.[] optimization when dataset uses identifier_input_method different than database (jeremyevans)
8
+
9
+ * Work around pragma bug on jdbc/sqlite when emulating alter table support (jeremyevans)
10
+
11
+ * Database#<< and Dataset#<< now return self so they can be safely chained (jeremyevans)
12
+
13
+ * Fully support using an aliased table name as the :join_table option for a many_to_many association (jeremyevans)
14
+
15
+ * Make like case sensitive on SQLite and Microsoft SQL Server (use ilike for case insensitive matching) (jeremyevans)
16
+
17
+ * Add Database#extend_datasets for the equivalent of extending of the Database object's datasets with a module (jeremyevans)
18
+
19
+ * Speed up Dataset #map, #to_hash, and related methods if an array of symbols is given (jeremyevans)
20
+
21
+ * Add Database#dataset_class for modifying the class used for datasets for a single Database object (jeremyevans)
22
+
23
+ * Plugins that override Model.load should be modified to override Model.call instead (jeremyevans)
24
+
25
+ * Speed up loading model objects from the database by up to 7-16% (jeremyevans)
26
+
27
+ * Create accessor methods for all columns in a model's table, even if the dataset doesn't select the columns (jeremyevans)
28
+
29
+ * Add mock adapter for better mocking of a database connection (jeremyevans)
30
+
31
+ * Have models pass their dataset instead of table name to Database#schema (jeremyevans)
32
+
33
+ * Allow Database#schema to take a dataset as the table argument, and use its identifier input/output methods (jeremyevans)
34
+
35
+ * Significant improvements to the db2 adapter (jeremyevans)
36
+
37
+ * Handle methods with names that can't be called directly in Model.def_dataset_method (jeremyevans)
38
+
39
+ * Add dataset_associations plugin for making dataset methods that return datasets of associated objects (jeremyevans)
40
+
41
+ * Don't allow Model.def_dataset_method to override private model methods (jeremyevans)
42
+
43
+ * Parsing primary key information from system tables in the shared MSSQL adapter (jeremyevans)
44
+
45
+ * Fix handling of composite primary keys when emulating alter table operations on SQLite (jeremyevans)
46
+
47
+ * Emulate add_constraint and drop_constraint alter table operations on SQLite (jeremyevans)
48
+
49
+ * Apply the correct pragmas when connecting to SQLite via the Amalgalite and Swift adapters (jeremyevans)
50
+
51
+ * Fix bound variable usage for some types (e.g. Date) when used outside of prepared statements on SQLite (jeremyevans)
52
+
53
+ * Work around SQLite column naming bug when using subselects (jeremyevans)
54
+
55
+ * Make prepared_statements plugin work with adapters that require type specifiers for variable placeholders, such as oracle (jeremyevans)
56
+
57
+ * Add savepoint support to the generic JDBC transaction support (used by 6 jdbc subadapters) (jeremyevans)
58
+
59
+ * Add native prepared statement support to the oracle adapter (jeremyevans)
60
+
61
+ * Support sharding correctly by default when using transactions in model saving/destroying (jeremyevans)
62
+
63
+ * Add Database#in_transaction? method for checking if you are already in a transaction (jeremyevans)
64
+
65
+ * Add after_commit, after_rollback, after_destroy_commit, and after_destroy_rollback hooks to Model objects (jeremyevans)
66
+
67
+ * Add after_commit and after_rollback hooks to Database objects (jeremyevans)
68
+
69
+ * Support savepoints inside prepared transactions on MySQL (jeremyevans)
70
+
71
+ * Support opening transactions to multiple shards of the same Database object in the same Thread (jeremyevans)
72
+
73
+ * Add Sequel.transaction for running transactions on multiple databases at the same time (jeremyevans)
74
+
75
+ * Support :rollback => :always option in Database#transaction to always rollback the transaction (jeremyevans)
76
+
77
+ * Support :rollback => :reraise option in Database#transaction to reraise the Sequel::Rollback exception (jeremyevans)
78
+
79
+ * Add support for connecting to Apache Derby databases using the jdbc adapter (jeremyevans)
80
+
81
+ * Add support for connecting to HSQLDB databases using the jdbc adapter (jeremyevans)
82
+
83
+ * Fix inserting all default values into a table on DB2 (jeremyevans)
84
+
85
+ * Add :qualify option to many_to_one associations for whether to qualify the primary key column with the associated table (jeremyevans)
86
+
87
+ * Modify rcte_tree plugin to use column aliases if recursive CTEs require them (jeremyevans)
88
+
89
+ * Add Dataset#recursive_cte_requires_column_aliases? method to check if you must provide an argument list for a recursive CTE (jeremyevans)
90
+
91
+ * Much better support for Oracle in both the oci8-based oracle adapter and the jdbc oracle subadapter (jeremyevans)
92
+
93
+ * Handle CTEs in subselects in more places on databases that don't natively support CTEs in subselects (jeremyevans)
94
+
95
+ * Change Dataset#to_hash to not call the row_proc if 2 arguments are given (jeremyevans)
96
+
97
+ * Change Dataset#map to not call the row_proc if an argument is given (jeremyevans)
98
+
99
+ * Make Dataset#select_map and #select_order_map return an array of single element arrays if given an array with a single symbol (jeremyevans)
100
+
101
+ * Make Dataset#columns work correctly on jdbc, odbc, ado, and dbi adapters when using an emulated offset on MSSQL and DB2 (jeremyevans)
102
+
103
+ * Add Database#listen and #notify to the postgres adapter, for LISTEN and NOTIFY support (jeremyevans)
104
+
105
+ * Emulate the bitwise compliment operator on h2 (jeremyevans)
106
+
107
+ * Fix improper handling of emulated bitwise operators with more than two arguments (jeremyevans)
108
+
109
+ * Allow convert_invalid_date_time to be set on a per-Database basis in the mysql adapter (jeremyevans)
110
+
111
+ * Allow convert_tinyint_to_bool to be set on a per-Database basis in the mysql and mysql2 adapters (jeremyevans)
112
+
113
+ * Allow per-Database override of the typeconversion procs on the mysql, sqlite, and ibmdb adapters (jeremyevans)
114
+
115
+ * Add Database#timezone accessor, for overriding Sequel.database_timezone per Database object (jeremyevans)
116
+
1
117
  === 3.28.0 (2011-10-03)
2
118
 
3
119
  * Add firebird jdbc subadapter (jeremyevans)
@@ -3248,9 +3364,9 @@
3248
3364
 
3249
3365
  === 0.1.9.3 (2007-08-10)
3250
3366
 
3251
- * Added support for specifying field size in schema definitions (thanks Florian Aßmann.)
3367
+ * Added support for specifying field size in schema definitions (thanks Florian Assmann.)
3252
3368
 
3253
- * Added migration code based on work by Florian Aßmann.
3369
+ * Added migration code based on work by Florian Assmann.
3254
3370
 
3255
3371
  * Reintroduced metaid dependency. No need to keep a local copy of it.
3256
3372
 
@@ -3328,7 +3444,7 @@
3328
3444
 
3329
3445
  * Fixed Dataset#first to include a LIMIT clause for a single record.
3330
3446
 
3331
- * Small fix to Postgres driver to return a primary_key value for the inserted record if it is specified in the insertion values (thanks Florian Aßmann and Pedro Gutierrez).
3447
+ * Small fix to Postgres driver to return a primary_key value for the inserted record if it is specified in the insertion values (thanks Florian Assmann and Pedro Gutierrez).
3332
3448
 
3333
3449
  * Fixed Symbol#DESC to support qualified notation (thanks Pedro Gutierrez).
3334
3450
 
data/Rakefile CHANGED
@@ -55,7 +55,7 @@ end
55
55
 
56
56
  desc "Make local version of website"
57
57
  task :website do
58
- sh %{#{RUBY} www/make_www.rb}
58
+ sh %{#{FileUtils::RUBY} www/make_www.rb}
59
59
  end
60
60
 
61
61
  desc "Make rdoc for website"
@@ -97,11 +97,13 @@ begin
97
97
  require "spec/rake/spectask"
98
98
  spec_class = Spec::Rake::SpecTask
99
99
  spec_files_meth = :spec_files=
100
+ spec_opts_meth = :spec_opts=
100
101
  rescue LoadError
101
102
  # RSpec 2
102
103
  require "rspec/core/rake_task"
103
104
  spec_class = RSpec::Core::RakeTask
104
105
  spec_files_meth = :pattern=
106
+ spec_opts_meth = :rspec_opts=
105
107
  end
106
108
 
107
109
  spec = lambda do |name, files, d|
@@ -110,7 +112,7 @@ begin
110
112
  desc d
111
113
  spec_class.new(name) do |t|
112
114
  t.send spec_files_meth, files
113
- t.spec_opts = ENV['SEQUEL_SPEC_OPTS'].split if ENV['SEQUEL_SPEC_OPTS']
115
+ t.send spec_opts_meth, ENV['SEQUEL_SPEC_OPTS'].split if ENV['SEQUEL_SPEC_OPTS']
114
116
  end
115
117
  end
116
118
 
@@ -159,5 +161,5 @@ end
159
161
 
160
162
  desc "Check syntax of all .rb files"
161
163
  task :check_syntax do
162
- Dir['**/*.rb'].each{|file| print `#{RUBY} -c #{file} | fgrep -v "Syntax OK"`}
164
+ Dir['**/*.rb'].each{|file| print `#{FileUtils::RUBY} -c #{file} | fgrep -v "Syntax OK"`}
163
165
  end
data/bin/sequel CHANGED
@@ -112,11 +112,7 @@ end
112
112
 
113
113
  connect_proc = lambda do |database|
114
114
  db = if database.nil? || database.empty?
115
- db = Sequel::Database.new(:quote_identifiers=>false)
116
- def db.connect(*args); Object.new; end
117
- db.identifier_input_method = nil
118
- db.identifier_output_method = nil
119
- db
115
+ Sequel.connect('mock:///', db_opts)
120
116
  elsif File.exist?(database)
121
117
  require 'yaml'
122
118
  env ||= "development"
data/doc/model_hooks.rdoc CHANGED
@@ -67,7 +67,15 @@ Sequel calls hooks in the following order when destroying an existing object:
67
67
 
68
68
  Note that these hooks are only called when using <tt>Model#destroy</tt>, they are not called if you use <tt>Model#delete</tt>.
69
69
 
70
- <tt>Sequel::Model</tt> does support one additional hook, +after_intialize+, which is called after the model object has been initalized. It can be used to set default attribute values for new objects, since by default new <tt>Sequel::Model</tt> objects have no attributes, and the attributes are not filled in until the model object is saved. You should be careful when you are using +after_initialize+, since it is called for every created record. So if you run a query that returns 1000 model objects, it will be called 1000 times. If you only want to change the behavior for new records, you can override the +initialize_set+ private method, which is called with the hash passed to +initialize+.
70
+ <tt>Sequel::Model</tt> does support a few additional hooks. One is +after_intialize+, which is called after the model object has been initalized. It can be used to set default attribute values for new objects, since by default new <tt>Sequel::Model</tt> objects have no attributes, and the attributes are not filled in until the model object is saved. You should be careful when you are using +after_initialize+, since it is called for every created record. So if you run a query that returns 1000 model objects, it will be called 1000 times. If you only want to change the behavior for new records, you can override the +initialize_set+ private method, which is called with the hash passed to +initialize+.
71
+
72
+ == Transaction-related Hooks
73
+
74
+ There are four other model hooks that <tt>Sequel::Model</tt> supports, all related to transactions. These are +after_commit+, +after_rollback+, +after_destroy_commit+, and +after_destroy_rollback+. +after_commit+ is called after the transaction in which you saved the object commits, only if it commits. +after_rollback+ is called after the transaction in which you saved the object rolls back, if it rolls back. +after_destroy_commit+ is called after the transaction in which you destroyed the object commits, if it commits. +after_destroy_rollback+ is called after the transaction in which you destroyed the object rolls back, if it rolls back.
75
+
76
+ If you aren't using transactions when saving or destroying model objects, and there isn't a currently open transaction, +after_commit+ and +after_destroy_commit+ will be called after +after_save+ and +after_destroy+, respectively, and +after_rollback+ and +after_destroy_rollback+ won't be called at all.
77
+
78
+ The purpose of these hooks is dealing with external systems that are interacting with the same database. For example, let's say you have a model that stores a picture, and you have a background job library that makes thumbnails of all of the pictures. So when a model object is created, you want to add a background job that will create the thumbnail for the picture. If you used after_save for this and transactions are being used, you are subject to a race condition where the background job library will check the database table for the record before the transaction that saved the record commits, and it won't be able to see the record's data. Using after_commit, you are guaranteed that the background job library will not get notified of the record until after the transaction commits and the data is viewable.
71
79
 
72
80
  == Running Hooks
73
81
 
@@ -66,24 +66,24 @@ For example:
66
66
 
67
67
  These options are shared by all adapters unless otherwise noted.
68
68
 
69
- * :adapter - The adapter to use
70
- * :database - The name of the database to which to connect
71
- * :default_schema - The database schema to use by default.
72
- * :host - The hostname of the database server to which to connect
73
- * :logger - An array of SQL loggers to log to
74
- * :loggers - An array of SQL loggers to log to
75
- * :password - The password for the user account
76
- * :servers - A hash with symbol keys and hash or proc values, used with master/slave/partitioned database configurations
77
- * :single_threaded - Whether to use a single-threaded (non-thread safe) connection pool
78
- * :test - Whether to test that a valid database connection can be made (false by default)
79
- * :user - The user account name to use logging in
69
+ :adapter :: The adapter to use
70
+ :database :: The name of the database to which to connect
71
+ :default_schema :: The database schema to use by default.
72
+ :host :: The hostname of the database server to which to connect
73
+ :logger :: An array of SQL loggers to log to
74
+ :loggers :: An array of SQL loggers to log to
75
+ :password :: The password for the user account
76
+ :servers :: A hash with symbol keys and hash or proc values, used with master/slave/partitioned database configurations
77
+ :single_threaded :: Whether to use a single-threaded (non-thread safe) connection pool
78
+ :test :: Whether to test that a valid database connection can be made (false by default)
79
+ :user :: The user account name to use logging in
80
80
 
81
81
  The following options can be specified and are passed to the the database's internal connection pool.
82
82
 
83
- * :after_connect - A proc called after a new connection is made, with the connection object (default: nil)
84
- * :max_connections - The maximum size of the connection pool (default: 4 connections on most databases)
85
- * :pool_sleep_time - The number of seconds to sleep before trying to acquire a connection again (default: 0.001 seconds)
86
- * :pool_timeout - The number of seconds to wait if a connection cannot be acquired before raising an error (default: 5 seconds)
83
+ :after_connect :: A proc called after a new connection is made, with the connection object (default: nil)
84
+ :max_connections :: The maximum size of the connection pool (default: 4 connections on most databases)
85
+ :pool_sleep_time :: The number of seconds to sleep before trying to acquire a connection again (default: 0.001 seconds)
86
+ :pool_timeout :: The number of seconds to wait if a connection cannot be acquired before raising an error (default: 5 seconds)
87
87
 
88
88
  == Adapter specific connection options
89
89
 
@@ -138,8 +138,8 @@ Amalgalite is an ruby extension that provides self contained access to SQLite,
138
138
  so you don't need to install SQLite separately. As amalgalite is a file backed
139
139
  database, the :host, :user, and :password options are not used.
140
140
 
141
- * :database - The name of the database file
142
- * :timeout - The busy timeout period given in milliseconds
141
+ :database :: The name of the database file
142
+ :timeout :: The busy timeout period given in milliseconds
143
143
 
144
144
  Without a database argument, assumes a memory database, so you can do:
145
145
 
@@ -159,8 +159,8 @@ instead for new DB2 work, as it is better supported.
159
159
 
160
160
  Allows access to a multitude of databases via ruby-dbi. Additional options:
161
161
 
162
- * :db_type - Specifying 'mssql' allows Microsoft SQL Server specific syntax to
163
- be used. Otherwise has no effect.
162
+ :db_type :: Specifying 'mssql' allows Microsoft SQL Server specific syntax to
163
+ be used. Otherwise has no effect.
164
164
 
165
165
  DBI connection strings are a preprocessed a bit, and are specified with a dbi-
166
166
  in front of the protocol. Examples:
@@ -258,19 +258,24 @@ Example connection strings:
258
258
  jdbc:postgresql://localhost/database?user=username
259
259
  jdbc:mysql://localhost/test?user=root&password=root
260
260
  jdbc:h2:mem:
261
+ jdbc:hsqldb:mem:mymemdb
262
+ jdbc:derby:memory:myDb;create=true
261
263
  jdbc:sqlserver://localhost;database=sequel_test;integratedSecurity=true
262
264
  jdbc:jtds:sqlserver://localhost/sequel_test;user=sequel_test;password=sequel_test
263
-
265
+ jdbc:oracle:thin:user/password@localhost:1521:database
266
+ jdbc:db2://localhost:3700/database:user=user;password=password;
267
+ jdbc:firebirdsql:localhost/3050:/path/to/database.fdb
268
+
264
269
  You can also use JNDI connection strings:
265
270
 
266
271
  jdbc:jndi:java:comp/env/jndi_resource_name
267
272
 
268
273
  The following additional options are supported:
269
274
 
270
- * :convert_types - If set to false, does not attempt to convert some Java types to ruby types.
271
- Setting to false roughly doubles performance when selecting large numbers of rows.
272
- Note that you can't provide this option inside the connection string (as that is passed
273
- directly to JDBC), you have to pass it as a separate option.
275
+ :convert_types :: If set to false, does not attempt to convert some Java types to ruby types.
276
+ Setting to false roughly doubles performance when selecting large numbers of rows.
277
+ Note that you can't provide this option inside the connection string (as that is passed
278
+ directly to JDBC), you have to pass it as a separate option.
274
279
 
275
280
  === mysql
276
281
 
@@ -281,16 +286,16 @@ ActiveRecord, it requires the native adapter.
281
286
 
282
287
  The following additional options are supported:
283
288
 
284
- * :auto_is_null - If set to true, makes "WHERE primary_key IS NULL" select the last inserted id.
285
- * :charset - Same as :encoding, :encoding takes precedence.
286
- * :compress - Whether to compress data sent/received via the socket connection.
287
- * :config_default_group - The default group to read from the in the MySQL config file.
288
- * :config_local_infile - If provided, sets the Mysql::OPT_LOCAL_INFILE option on the connection with the given value.
289
- * :encoding - Specify the encoding/character set to use for the connection.
290
- * :socket - Can be used to specify a Unix socket file to connect to instead of a TCP host and port.
291
- * :timeout - Sets the wait_timeout for the connection, defaults to 1 month.
292
- * :read_timeout - Set the timeout in seconds for reading back results to a query.
293
- * :connect_timeout - Set the timeout in seconds before a connection attempt is abandoned.
289
+ :auto_is_null :: If set to true, makes "WHERE primary_key IS NULL" select the last inserted id.
290
+ :charset :: Same as :encoding, :encoding takes precedence.
291
+ :compress :: Whether to compress data sent/received via the socket connection.
292
+ :config_default_group :: The default group to read from the in the MySQL config file.
293
+ :config_local_infile :: If provided, sets the Mysql::OPT_LOCAL_INFILE option on the connection with the given value.
294
+ :encoding :: Specify the encoding/character set to use for the connection.
295
+ :socket :: Can be used to specify a Unix socket file to connect to instead of a TCP host and port.
296
+ :timeout :: Sets the wait_timeout for the connection, defaults to 1 month.
297
+ :read_timeout :: Set the timeout in seconds for reading back results to a query.
298
+ :connect_timeout :: Set the timeout in seconds before a connection attempt is abandoned.
294
299
 
295
300
  === mysql2
296
301
 
@@ -307,8 +312,8 @@ The :database option given ODBC database should be the DSN (Descriptive Service
307
312
 
308
313
  The :host and :port options are not respected. The following additional options are supported:
309
314
 
310
- * :db_type - Can be specified as 'mssql' or 'progress' to use SQL syntax specific to those databases.
311
- * :driver - The name of the ODBC driver to utilize.
315
+ :db_type :: Can be specified as 'mssql' or 'progress' to use SQL syntax specific to those databases.
316
+ :driver :: The name of the ODBC driver to utilize.
312
317
 
313
318
  === openbase
314
319
 
@@ -320,7 +325,11 @@ Requires: oci8
320
325
 
321
326
  The following additional options are supported:
322
327
 
323
- * :privilege - The Oracle privilege level.
328
+ :autosequence :: Set to true to use Sequel's conventions to guess the sequence to use for datasets. False
329
+ by default.
330
+ :prefetch_rows :: The number of rows to prefetch. Defaults to 1, a larger number can be specified
331
+ and will improve performance when retrieving a large number of rows.
332
+ :privilege :: The Oracle privilege level.
324
333
 
325
334
  === postgres
326
335
 
@@ -331,8 +340,8 @@ The pg library is the best supported, as it supports real bound variables and pr
331
340
 
332
341
  The following additional options are supported:
333
342
 
334
- * :charset - Same as :encoding, :encoding takes precedence
335
- * :encoding - Set the client_encoding to the given string
343
+ :charset :: Same as :encoding, :encoding takes precedence
344
+ :encoding :: Set the client_encoding to the given string
336
345
 
337
346
  === sqlite
338
347
 
@@ -359,7 +368,7 @@ Examples:
359
368
 
360
369
  The following additional options are supported:
361
370
 
362
- * :timeout - the busy timeout to use in milliseconds (default: 5000).
371
+ :timeout :: the busy timeout to use in milliseconds (default: 5000).
363
372
 
364
373
  === swift
365
374
 
@@ -9,6 +9,7 @@ the following adapters:
9
9
  * jdbc
10
10
  * mysql (prepared statements only)
11
11
  * mysql2 (prepared statements only)
12
+ * oracle (requires type specifiers for nil/NULL values)
12
13
  * postgres (when using the pg driver, may require type specifiers)
13
14
  * sqlite
14
15
  * tinytds
@@ -80,20 +81,20 @@ and update queries, the hash to insert/update is passed to +prepare+:
80
81
 
81
82
  If you are using the ruby-postgres or postgres-pr driver, PostgreSQL uses the
82
83
  default emulated support. If you are using ruby-pg, there is native support,
83
- but it may require type specifiers. This is easy if you have
84
+ but it may require type specifiers on some old versions (generally not anymore).
84
85
  direct control over the SQL string, but since Sequel abstracts that, the types
85
- can be specified another way. This is done by adding a __* suffix to the
86
- placeholder symbol (e.g. :$name__text, which will be compiled to "$1::text"
87
- in the SQL). Prepared statements are always server side.
86
+ You can add a __* suffix to the placeholder symbol to specify a type, which
87
+ casts to that type in the SQL (e.g. :$name__text, which will be compiled to
88
+ "$1::text" in the SQL). Prepared statements are always server side.
88
89
 
89
90
  === SQLite
90
91
 
91
92
  SQLite supports both prepared statements and bound variables. Prepared
92
93
  statements are cached per connection.
93
94
 
94
- === MySQL
95
+ === MySQL/Mysql2
95
96
 
96
- The MySQL ruby driver does not support bound variables, so the bound
97
+ The MySQL/Mysql2 ruby drivers do not support bound variables, so the bound
97
98
  variable methods fall back to string interpolation. It uses server side
98
99
  prepared statements.
99
100
 
@@ -105,6 +106,26 @@ over JDBC, you can add the prepareThreshold=N parameter to the connection
105
106
  string, which will use a server side prepared statement after N calls to
106
107
  the prepared statement.
107
108
 
109
+ === TinyTDS
110
+
111
+ Uses the sp_executesql stored procedure with bound variables, since
112
+ Microsoft SQL Server doesn't support true prepared statements.
113
+
114
+ === IBM_DB
115
+
116
+ DB2 supports both prepared statements and bound variables. Prepared
117
+ statement objects are cached per connection.
118
+
119
+ === Oracle
120
+
121
+ Oracle supports both prepared statements and bound variables. Prepared
122
+ statements (OCI8::Cursor objects) are cached per connection. If you
123
+ ever plan to use a nil/NULL value as a bound variable/prepared statement
124
+ value, you must specify the type in the placeholder using a __* suffix.
125
+ You can use any of the schema types that Sequel supports, such as
126
+ :$name__string or :$num__integer. Using blobs as bound variables is
127
+ not currently supported.
128
+
108
129
  === All Others
109
130
 
110
131
  Support is emulated using interpolation.
@@ -64,11 +64,11 @@
64
64
  query types that only load the related records from the database.
65
65
  The available values for the :eager_limit_strategy option are:
66
66
 
67
- :window_function: This uses the row_number window function
67
+ :window_function - This uses the row_number window function
68
68
  partitioned by the related key fields. It can only be used
69
69
  on databases that support window functions (PostgreSQL 8.4+,
70
70
  Microsoft SQL Server 2005+, DB2).
71
- :correlated_subquery: This uses a correlated subquery that is
71
+ :correlated_subquery - This uses a correlated subquery that is
72
72
  limited. It works on most databases except MySQL and DB2.
73
73
 
74
74
  You can provide a value of true as the option to have Sequel
@@ -0,0 +1,459 @@
1
+ = New Adapter Support
2
+
3
+ * Sequel now has much better support for Oracle, both in the
4
+ ruby-oci8-based oracle adapter and in the jdbc/oracle adapter.
5
+
6
+ * Sequel now has much better support for connecting to HSQLDB
7
+ using the jdbc adapter. This support does not work correctly
8
+ with the jdbc-hsqldb gem, since the version it uses is too
9
+ old. You'll need to load the .jar file manually until the
10
+ gem is updated.
11
+
12
+ * Sequel now has much better support for connecting to Apache
13
+ Derby databases using the jdbc adapter. This works with
14
+ the jdbc-derby gem, but it's recommend you grab an updated
15
+ .jar file as the jdbc-derby gem doesn't currently support
16
+ truncate or booleans.
17
+
18
+ * The db2 adapter has had most of the remaining issues fixed,
19
+ and can now run Sequel's test suite cleanly. It's still
20
+ recommended that users switch to the ibmdb adapter if they
21
+ are connecting to DB2.
22
+
23
+ * A mock adapter has been added which provides a mock Database
24
+ object that allows you to easily set the returned rows, the
25
+ number of rows modified by update/delete, and the
26
+ autogenerating primary key integer for insert. It also allows
27
+ you to set specific columns in the dataset when retrieving
28
+ rows. The specs were full of partial implementations of
29
+ mock adapters, this mock adapter is much more complete and
30
+ offers full support for mocking transactions and database
31
+ sharding. Example:
32
+
33
+ DB = Sequel.mock(:fetch=>{:id=>1}, :numrows=>2, :autoid=>3)
34
+ DB[:items].all # => [{:id => 1}]
35
+ DB[:items].insert # => 3
36
+ DB[:items].insert # => 4
37
+ DB[:items].delete # => 2
38
+ DB[:items].update(:id=>2) # => 2
39
+ DB.sqls # => ['SELECT ...', 'INSERT ...', ...]
40
+
41
+ In addition to being useful in the specs, the mock adapter is
42
+ also used if you use bin/sequel without a database argument,
43
+ which makes it much easier to play around with Sequel on the
44
+ command line without being tied to a real database.
45
+
46
+ = New Transaction Features
47
+
48
+ * Database after_commit and after_rollback hooks have been added,
49
+ allowing you to set procs that are called after the currently-
50
+ in-effect transaction commits or rolls back. If the Database
51
+ is not currently in a transaction, the after_commit proc is
52
+ called immediately and the after_rollback proc is ignored.
53
+
54
+ * Model after_commit, after_rollback, after_destroy_commit, and
55
+ after_destroy_rollback hooks have been added that use the new
56
+ Database after_commit/after_rollback hook to execute code after
57
+ commit or rollback.
58
+
59
+ * Database#transaction now supports a :rollback => :reraise option
60
+ to reraise any Sequel::Rollback exceptions raised by the block.
61
+
62
+ * Database#transaction now supports a :rollback => :always option
63
+ to always rollback the transaction, which is mostly useful when
64
+ using transaction-based testing.
65
+
66
+ * Sequel.transaction has been added, allowing you to run
67
+ simultaneous transactions on multiple Database objects:
68
+
69
+ Sequel.transaction([DB1, DB2]){...}
70
+ # similar to:
71
+ DB1.transaction{DB2.transaction{...}}
72
+
73
+ You can combine this with the :rollback => :always option to
74
+ easily use multiple databases in the same test suite and make sure
75
+ that changes are rolled back on all of them.
76
+
77
+ * Database#in_transaction? has been added so that users can detect
78
+ whether the code is currently inside a transaction.
79
+
80
+ * The generic JDBC transaction support, used by 6 of Sequel's jdbc
81
+ subapters, now supports savepoints if the underlying JDBC driver
82
+ supports savepoints.
83
+
84
+ = Other New Features
85
+
86
+ * A dataset_associations plugin has been added, allowing datasets
87
+ to call association methods, which return datasets of rows in
88
+ the associated table that are associated to rows in the current
89
+ dataset.
90
+
91
+ # Dataset of tracks from albums with name < 'M'
92
+ # by artists with name > 'M'
93
+
94
+ Artist.filter(:name > 'M').albums.filter(:name < 'M').tracks
95
+
96
+ # SELECT * FROM tracks
97
+ # WHERE (tracks.album_id IN (
98
+ # SELECT albums.id FROM albums
99
+ # WHERE ((albums.artist_id IN (
100
+ # SELECT artists.id FROM artists
101
+ # WHERE (name > 'M')))
102
+ # AND (name < 'M'))))
103
+
104
+ * Database#extend_datasets has been added, allowing you to do the
105
+ equivalent of extending all of the database's future datasets
106
+ with a module. For performance, it creates an anonymous
107
+ subclass of the current dataset class and includes a module in
108
+ it, and uses the subclass to create future datasets.
109
+
110
+ Using this feature allows you to override any dataset method
111
+ and call super, similar to how Sequel::Model plugins work. The
112
+ method takes either a module:
113
+
114
+ Sequel.extension :columns_introspection
115
+ DB.extend_datasets(Sequel::ColumnsIntrospection)
116
+
117
+ or a block that it uses to create an anonymous module:
118
+
119
+ DB.extend_datasets do
120
+ # Always select from table.* instead of *
121
+ def from(*tables)
122
+ ds = super
123
+ if !@opts[:select] || @opts[:select].empty?
124
+ ds = ds.select_all(*tables)
125
+ end
126
+ ds
127
+ end
128
+ end
129
+
130
+ * Database#<< and Dataset#<< now return self, which allow them
131
+ to be used in chaining:
132
+
133
+ DB << "UPADTE foo SET bar_id = NULL" << "DROP TABLE bars"
134
+ DB[:foo] << {:bar_id=>0} << DB[:bars].select(:id)
135
+
136
+ * A Database#timezone accessor has been added, allowing you to
137
+ override Sequel.database_timezone on a per-Database basis, which
138
+ allows you to use two separate Database objects in the same
139
+ process that have different timezones.
140
+
141
+ * You can now modify the type conversion procs on a per-Database
142
+ basis when using the mysql, sqlite, and ibmdb adapters, by
143
+ modifying the hash returned by Database#conversion_procs.
144
+
145
+ * Model.dataset_module now accepts a Module instance as an argument,
146
+ and extends the model's dataset with that module.
147
+
148
+ * When using the postgres adapter with the pg driver, you can now
149
+ use Database#listen to wait for notifications. All adapters that
150
+ connect to postgres now support Database#notify to send
151
+ notifications:
152
+
153
+ # process 1
154
+ DB.listen('foo') do |ev, pid, payload|
155
+ ev # => 'foo'
156
+ notify_pid # => some Integer
157
+ payload # => 'bar'
158
+ end
159
+
160
+ # process 2
161
+ DB.notify('foo', :payload=>'bar')
162
+
163
+ * many_to_one associations now have a :qualify option that can be set
164
+ to false to not qualify the primary key when loading the
165
+ association. This shouldn't be necessary to use in most cases, but
166
+ in some cases qualifying a primary key breaks certain queries (e.g.
167
+ using JOIN USING on the same column on Oracle).
168
+
169
+ * Database#schema can now take a dataset as an argument if it just
170
+ selects from a single table. If a dataset is provided, the
171
+ schema parsing will use that dataset's identifier_input_method
172
+ and identifier_output_method for the parsing, instead of the
173
+ database's default. This makes it possible for Model classes
174
+ to correctly get the table schema if they use a dataset whose
175
+ identifier_(input|output)_method differs from the database
176
+ default.
177
+
178
+ * On databases that support common table expressions (CTEs) but do
179
+ not support CTE usage in subselects, Sequel now emulates support
180
+ by moving CTEs from the subselect to the main select when using
181
+ the Dataset from, from_self, with, with_recursive, union,
182
+ intersect, and except methods.
183
+
184
+ * The bitwise compliment operator is now emulated on H2.
185
+
186
+ * You can now set the convert_tinyint_to_bool setting on a
187
+ per-Database basis in the mysql and mysql2 adapters.
188
+
189
+ * You can now set the convert_invalid_date_time setting on a
190
+ per-Database basis in the mysql adapter.
191
+
192
+ * Database instances now have a dataset_class accessor that allows
193
+ you to set which class is used when creating datasets. This is
194
+ mostly used to implement the extend_datasets support, but it
195
+ could be useful for other purposes.
196
+
197
+ * Dataset#unused_table_alias now accepts an optional 2nd argument,
198
+ which should be an array of additional symbols that should be
199
+ considered as already used.
200
+
201
+ * Dataset#requires_placeholder_type_specifiers? has been added to
202
+ check if the dataset requires you use type specifiers for
203
+ bound variable placeholders.
204
+
205
+ The prepared_statements plugin now checks this setting and works
206
+ correctly on adapters that set it to true, such as oracle.
207
+
208
+ * Dataset#recursive_cte_requires_column_aliases? has been added
209
+ to check if you must provide a column list for a recursive CTE.
210
+
211
+ The rcte_tree plugin now checks this setting an works correctly
212
+ on databases that set it to true, such as Oracle and HSQLDB.
213
+
214
+ = Performance Improvements
215
+
216
+ * Numerous optimizations were made to loading model objects from
217
+ the database, resulting in a 7-16% speedup.
218
+
219
+ Model.call was added, and now .load is just an alias for .call.
220
+ This allows you to make the model dataset's row_proc the model
221
+ itself, instead of needing a separate block, which improves
222
+ performance.
223
+
224
+ While Model.load used to call .new (and therefore #initialize),
225
+ Model.call uses .allocate/#set_values/#after_initialize for speed.
226
+ This saves a method call or two, and skips setting the @new
227
+ instance variable.
228
+
229
+ * Dataset#map, #to_hash, #select_map, #select_order_map, and
230
+ #select_hash are now faster if any of the provided arguments are
231
+ an array of symbols.
232
+
233
+ * The Model.[] optimization is now applied in more cases.
234
+
235
+ = Other Improvements
236
+
237
+ * Sequel now creates accessor methods for all columns in a model's
238
+ table, even if the dataset doesn't select the columns. This has
239
+ been the specified behavior for a while, but the spec was broken.
240
+ This allows you do to:
241
+
242
+ Model.dataset = DB[:table].select(:column1, :column2)
243
+ Model.select_more(:column3).first.column3
244
+
245
+ * Model.def_dataset_method now correctly handles method names that
246
+ can't be used directly (such as method names with spaces). This
247
+ isn't so the method can be used with arbitrary user input, but
248
+ it will allow safe creation of dataset methods that are derived
249
+ from column names, which could contain spaces.
250
+
251
+ * Model.def_dataset_method no longer overrides private model
252
+ methods.
253
+
254
+ * The optimization that Model.[] uses now works correctly if the
255
+ model's dataset uses a different identifier_input_method than
256
+ the database.
257
+
258
+ * Sharding is supported correctly by default for the transactions
259
+ used by model objects. Previously, you had to use the sharding
260
+ plugin to make sure the same shard was used for transactions as
261
+ for the insert/update/delete statements.
262
+
263
+ * Sequel now fully supports using an aliased table for the
264
+ :join_table option of a many_to_many association. The only real
265
+ use case for an aliased :join_table option is when the join table
266
+ is the same as the associated model table.
267
+
268
+ * A bug when eagerly loading a many_through_many association with
269
+ composite keys where one of the join tables requires an alias
270
+ has been fixed.
271
+
272
+ * Sequel's transaction internals have had substantial improvments.
273
+ You can now open up simultaneous transactions on two separate
274
+ shards of the same Database object in the same thread. The new
275
+ design allows for future support of connection pools that aren't
276
+ based on threads. Sequel no longer abuses thread-local variables
277
+ to store savepoint state.
278
+
279
+ * Dataset#select_map and #select_order_map now return an array of
280
+ single element arrays if given an array with a single entry as
281
+ an argument. Previously, they returned an array of values, which
282
+ wasn't consistent.
283
+
284
+ * Sequel's emulation of bitwise operators with more than 2 arguments
285
+ now works on all adapters that use the emulation. The emulation
286
+ was broken in 3.28.0 when more than 2 arguments were used on H2,
287
+ DB2, Microsoft SQL Server, PostgreSQL, and SQLite.
288
+
289
+ * Dataset#columns now correctly handles the emulated offset support
290
+ used on DB2, Oracle, and Microsoft SQL Server when using the
291
+ jdbc, odbc, ado, and dbi adapters. Previously, Dataet#columns
292
+ could contain the row number column, which wasn't in the
293
+ hashes yielded by Dataset#each.
294
+
295
+ * Sequel can now parse primary key information on Microsoft SQL
296
+ Server. Previously, the only adapter that supported this was the
297
+ jdbc adapter, which uses the generic JDBC support. The shared
298
+ mssql adapter now supports parsing the information directly from
299
+ the database system tables. This means that if you are using
300
+ Model objects with a Microsoft SQL Server database using the
301
+ tinytds, odbc, or ado adapters, the model primary key
302
+ information will be set automatically.
303
+
304
+ * Sequel's prepared statement support no longer defines singleton
305
+ methods on the prepared statement objects.
306
+
307
+ * StringMethods#like is now case sensitive on SQLite and Microsoft
308
+ SQL Server, making it more similar to other databases.
309
+
310
+ * Sequel now works around an SQLite column naming bug if you select
311
+ columns qualified with the alias of a subselect without providing
312
+ an alias for the column itself.
313
+
314
+ * Sequel now handles more bound variable types when using bound
315
+ variables outside of prepared statements on SQLite.
316
+
317
+ * Sequel now works around a bug in certain versions of the
318
+ JDBC/SQLite driver when emulating alter table support for
319
+ operations such as drop_column.
320
+
321
+ * Sequel now emulates the add_constraint and drop_constraint
322
+ alter table operations on SQLite, though the emulation has
323
+ issues.
324
+
325
+ * Sequel now correctly handles composite primary keys when
326
+ emulating alter_table operations on SQLite.
327
+
328
+ * Sequel now applies the correct PRAGMA statements by default when
329
+ connecting to SQLite via the amalgalite and swift adapters.
330
+
331
+ * Sequel now supports using savepoints inside prepared transactions
332
+ on MySQL.
333
+
334
+ * Sequel now closes JDBC ResultSet objects as soon as it is done
335
+ using them, leading to potentially lower memory usage in the JDBC
336
+ adapter, and fixes issues if you try to drop a table before
337
+ GC has collected a related ResultSet.
338
+
339
+ * Sequel can now correctly insert all default values into a table
340
+ on DB2. Before, this didn't work correctly if the table had more
341
+ than one column.
342
+
343
+ * Another type of disconnection error is now recognized in the
344
+ mysql2 adapter.
345
+
346
+ * Sequel now uses better error messages if you attempt to execute a
347
+ prepared statement without a name using the postgres, mysql, and
348
+ mysql2 adapters.
349
+
350
+ * Some small fixes have been made that allow Sequel to run better
351
+ when $SAFE=1. However, Sequel is not officially supported using
352
+ $SAFE > 0, so there could be many issues remaining.
353
+
354
+ * Sequel's core and model specs were cleaned up by using the mock
355
+ adapter to eliminate a lot of redundant code.
356
+
357
+ * Sequel's integration tests were sped up considerably, halving
358
+ the execution time on some adapters.
359
+
360
+ = Backwards Compatibility
361
+
362
+ * Because Model.load is now an alias for .call, plugins should no
363
+ longer override load. Instead, they should override .call.
364
+
365
+ * Loading model objects from the database no longer calls
366
+ Model#initialize. Instead, it calls Model.allocate,
367
+ Model#set_values, and Model#after_initialize. So if you were
368
+ overriding #initialize and expecting the changes to affect model
369
+ objects loaded from the database, you need to change your code.
370
+
371
+ Additionally, @new is no longer set to false for objects retieved
372
+ from the database, since setting it to false hurts performance.
373
+ Model#new? still returns true or false, so this only affects you
374
+ if you are checking the instance variables directly.
375
+
376
+ * Dataset#<< no longer returns the autogenerated primary key for the
377
+ inserted row. As mentioned above, it now returns self to allow for
378
+ chaining. If you were previously relying on the return value,
379
+ switch from #<< to #insert.
380
+
381
+ * Dataset#map no longer calls the row_proc if given an argument, and
382
+ Dataset#to_hash no longer calls the row_proc if given two arguments.
383
+ This should only affect your code if you were using a row_proc that
384
+ modified the content of the hash (e.g. Model#after_initialize). If
385
+ you were relying on the old behavior, switch:
386
+
387
+ dataset.map(:foo)
388
+ # to
389
+ dataset.map{|r| r[:foo]}
390
+
391
+ dataset.to_hash(:foo, :bar)
392
+ # to
393
+ h = {}
394
+ dataset.each{|r| h[r[:foo]] = r[:bar]}
395
+ h
396
+
397
+ * Model classes now need to have a dataset before you can define
398
+ associations on them.
399
+
400
+ * Model classes now pass their dataset to Database#schema, instead of
401
+ their table name.
402
+
403
+ * The :eager_block association option (which defaults to the
404
+ association's block argument) is now called before the :eager_graph
405
+ association option has been applied, instead of after.
406
+
407
+ * The many_to_many association reflection :qualified_right_key entry
408
+ is now a method named qualified_right_key. Switch any
409
+ code using association_reflection[:qualified_right_key] to use
410
+ association_reflection.qualified_right_key.
411
+
412
+ * If you are using like on SQLite and Microsoft SQL Server and want
413
+ it to be case insensitive, switch to using ilike:
414
+
415
+ # Case sensitive
416
+ DB[:foos].where(:name.like('bar%'))
417
+ # Case insensitive
418
+ DB[:foos].where(:name.ilike('bar%'))
419
+
420
+ Sequel now sets the case_sensitive_like PRAGMA to true by default
421
+ on SQLite. To set it to false instead, pass the
422
+ :case_sensitive_like=>false option to the database when creating it.
423
+
424
+ * Sequel's alter table emulation on SQLite now renames the current
425
+ table then populates the replacement table, instead of
426
+ populating the replacement table at a temporary name, dropping
427
+ the current table, and then renaming the replacement table.
428
+
429
+ * The strings 'n' and 'no' (case insensitive) when typecasted to
430
+ boolean are now considered false values instead of true.
431
+
432
+ * The transaction internals had extensive changes, if you have any
433
+ code that depended on the transaction internals, it will probably
434
+ require changes.
435
+
436
+ * Using the Sequel::MySQL module settings for convert_tinyint_to_bool
437
+ and convert_invalid_date_time now only affects future Database
438
+ objects. You should switch to using the per-Database methods
439
+ if you are currently using the Sequel::MySQL module methods.
440
+
441
+ * The customized transaction support in the do (DataObjects) adapter
442
+ was removed. All three subadapters (postgres, mysql, sqlite) of
443
+ the do adapter implement their own transaction support, so this
444
+ should have no effect unless you were using the do adapter with
445
+ a different database type.
446
+
447
+ * The oracle support changed dramatically, so if you were relying
448
+ on the internals of the oracle support, you should take extra
449
+ care when upgrading.
450
+
451
+ = Advance Notice
452
+
453
+ * The next release of Sequel will contain significant changes to
454
+ how a dataset is literalized into an SQL string. If you have
455
+ a custom plugin, extension, or adapter that overrides a
456
+ method containing "literal", "sql", or "quote", or you make
457
+ other modifications or extensions to how Sequel currently
458
+ literalizes datasets to SQL, your code will likely need to
459
+ be modified to support the next release.