sequel 3.48.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +114 -0
  3. data/Rakefile +10 -7
  4. data/doc/association_basics.rdoc +25 -23
  5. data/doc/code_order.rdoc +7 -0
  6. data/doc/core_extensions.rdoc +0 -10
  7. data/doc/object_model.rdoc +4 -1
  8. data/doc/querying.rdoc +3 -3
  9. data/doc/release_notes/4.0.0.txt +262 -0
  10. data/doc/security.rdoc +0 -28
  11. data/doc/testing.rdoc +8 -14
  12. data/lib/sequel/adapters/ado.rb +7 -11
  13. data/lib/sequel/adapters/ado/access.rb +8 -8
  14. data/lib/sequel/adapters/ado/mssql.rb +4 -4
  15. data/lib/sequel/adapters/amalgalite.rb +6 -6
  16. data/lib/sequel/adapters/cubrid.rb +7 -7
  17. data/lib/sequel/adapters/db2.rb +5 -9
  18. data/lib/sequel/adapters/dbi.rb +2 -6
  19. data/lib/sequel/adapters/do.rb +4 -4
  20. data/lib/sequel/adapters/firebird.rb +4 -4
  21. data/lib/sequel/adapters/ibmdb.rb +8 -8
  22. data/lib/sequel/adapters/informix.rb +2 -10
  23. data/lib/sequel/adapters/jdbc.rb +17 -17
  24. data/lib/sequel/adapters/jdbc/as400.rb +2 -2
  25. data/lib/sequel/adapters/jdbc/cubrid.rb +1 -1
  26. data/lib/sequel/adapters/jdbc/db2.rb +1 -1
  27. data/lib/sequel/adapters/jdbc/derby.rb +1 -1
  28. data/lib/sequel/adapters/jdbc/h2.rb +2 -2
  29. data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
  30. data/lib/sequel/adapters/jdbc/informix.rb +1 -1
  31. data/lib/sequel/adapters/jdbc/mssql.rb +2 -2
  32. data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
  33. data/lib/sequel/adapters/jdbc/oracle.rb +5 -1
  34. data/lib/sequel/adapters/jdbc/postgresql.rb +3 -3
  35. data/lib/sequel/adapters/jdbc/sqlite.rb +3 -3
  36. data/lib/sequel/adapters/jdbc/transactions.rb +3 -3
  37. data/lib/sequel/adapters/mock.rb +7 -7
  38. data/lib/sequel/adapters/mysql.rb +3 -3
  39. data/lib/sequel/adapters/mysql2.rb +4 -4
  40. data/lib/sequel/adapters/odbc.rb +2 -6
  41. data/lib/sequel/adapters/odbc/mssql.rb +1 -1
  42. data/lib/sequel/adapters/openbase.rb +1 -5
  43. data/lib/sequel/adapters/oracle.rb +13 -17
  44. data/lib/sequel/adapters/postgres.rb +20 -25
  45. data/lib/sequel/adapters/shared/cubrid.rb +3 -3
  46. data/lib/sequel/adapters/shared/db2.rb +2 -2
  47. data/lib/sequel/adapters/shared/firebird.rb +7 -7
  48. data/lib/sequel/adapters/shared/mssql.rb +9 -9
  49. data/lib/sequel/adapters/shared/mysql.rb +29 -13
  50. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +7 -7
  51. data/lib/sequel/adapters/shared/oracle.rb +22 -13
  52. data/lib/sequel/adapters/shared/postgres.rb +61 -46
  53. data/lib/sequel/adapters/shared/sqlite.rb +9 -9
  54. data/lib/sequel/adapters/sqlite.rb +17 -11
  55. data/lib/sequel/adapters/swift.rb +3 -3
  56. data/lib/sequel/adapters/swift/mysql.rb +1 -1
  57. data/lib/sequel/adapters/swift/sqlite.rb +1 -1
  58. data/lib/sequel/adapters/tinytds.rb +8 -8
  59. data/lib/sequel/ast_transformer.rb +3 -1
  60. data/lib/sequel/connection_pool.rb +4 -2
  61. data/lib/sequel/connection_pool/sharded_single.rb +2 -2
  62. data/lib/sequel/connection_pool/sharded_threaded.rb +5 -5
  63. data/lib/sequel/connection_pool/threaded.rb +7 -7
  64. data/lib/sequel/core.rb +4 -67
  65. data/lib/sequel/database.rb +1 -0
  66. data/lib/sequel/database/connecting.rb +2 -8
  67. data/lib/sequel/database/dataset.rb +2 -7
  68. data/lib/sequel/database/dataset_defaults.rb +0 -18
  69. data/lib/sequel/database/features.rb +4 -4
  70. data/lib/sequel/database/misc.rb +6 -8
  71. data/lib/sequel/database/query.rb +5 -61
  72. data/lib/sequel/database/schema_generator.rb +22 -20
  73. data/lib/sequel/database/schema_methods.rb +48 -20
  74. data/lib/sequel/database/transactions.rb +7 -17
  75. data/lib/sequel/dataset.rb +2 -0
  76. data/lib/sequel/dataset/actions.rb +23 -91
  77. data/lib/sequel/dataset/features.rb +1 -4
  78. data/lib/sequel/dataset/graph.rb +3 -47
  79. data/lib/sequel/dataset/misc.rb +4 -33
  80. data/lib/sequel/dataset/prepared_statements.rb +3 -1
  81. data/lib/sequel/dataset/query.rb +116 -240
  82. data/lib/sequel/dataset/sql.rb +19 -97
  83. data/lib/sequel/deprecated.rb +0 -16
  84. data/lib/sequel/exceptions.rb +0 -3
  85. data/lib/sequel/extensions/_pretty_table.rb +1 -1
  86. data/lib/sequel/extensions/columns_introspection.rb +1 -12
  87. data/lib/sequel/extensions/constraint_validations.rb +3 -3
  88. data/lib/sequel/extensions/core_extensions.rb +0 -9
  89. data/lib/sequel/extensions/date_arithmetic.rb +1 -2
  90. data/lib/sequel/extensions/graph_each.rb +11 -0
  91. data/lib/sequel/extensions/migration.rb +5 -5
  92. data/lib/sequel/extensions/null_dataset.rb +11 -13
  93. data/lib/sequel/extensions/pagination.rb +3 -6
  94. data/lib/sequel/extensions/pg_array.rb +6 -4
  95. data/lib/sequel/extensions/pg_array_ops.rb +35 -1
  96. data/lib/sequel/extensions/pg_json.rb +12 -2
  97. data/lib/sequel/extensions/pg_json_ops.rb +266 -0
  98. data/lib/sequel/extensions/pg_range.rb +2 -2
  99. data/lib/sequel/extensions/pg_range_ops.rb +0 -8
  100. data/lib/sequel/extensions/pg_row.rb +2 -2
  101. data/lib/sequel/extensions/pretty_table.rb +0 -4
  102. data/lib/sequel/extensions/query.rb +3 -8
  103. data/lib/sequel/extensions/schema_caching.rb +0 -7
  104. data/lib/sequel/extensions/schema_dumper.rb +10 -17
  105. data/lib/sequel/extensions/select_remove.rb +0 -4
  106. data/lib/sequel/extensions/set_overrides.rb +28 -0
  107. data/lib/sequel/extensions/to_dot.rb +6 -10
  108. data/lib/sequel/model.rb +6 -7
  109. data/lib/sequel/model/associations.rb +127 -182
  110. data/lib/sequel/model/base.rb +88 -211
  111. data/lib/sequel/model/errors.rb +0 -13
  112. data/lib/sequel/model/plugins.rb +2 -2
  113. data/lib/sequel/no_core_ext.rb +0 -1
  114. data/lib/sequel/plugins/after_initialize.rb +11 -17
  115. data/lib/sequel/plugins/association_autoreloading.rb +1 -47
  116. data/lib/sequel/plugins/association_dependencies.rb +2 -2
  117. data/lib/sequel/plugins/auto_validations.rb +2 -8
  118. data/lib/sequel/plugins/blacklist_security.rb +32 -2
  119. data/lib/sequel/plugins/caching.rb +1 -1
  120. data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
  121. data/lib/sequel/plugins/composition.rb +10 -8
  122. data/lib/sequel/plugins/constraint_validations.rb +2 -2
  123. data/lib/sequel/plugins/dataset_associations.rb +4 -0
  124. data/lib/sequel/plugins/defaults_setter.rb +8 -6
  125. data/lib/sequel/plugins/dirty.rb +6 -6
  126. data/lib/sequel/plugins/force_encoding.rb +13 -8
  127. data/lib/sequel/plugins/hook_class_methods.rb +1 -7
  128. data/lib/sequel/plugins/json_serializer.rb +13 -74
  129. data/lib/sequel/plugins/lazy_attributes.rb +2 -4
  130. data/lib/sequel/plugins/list.rb +1 -1
  131. data/lib/sequel/plugins/many_through_many.rb +4 -11
  132. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +1 -49
  133. data/lib/sequel/plugins/nested_attributes.rb +1 -1
  134. data/lib/sequel/plugins/optimistic_locking.rb +3 -5
  135. data/lib/sequel/plugins/pg_array_associations.rb +453 -0
  136. data/lib/sequel/plugins/pg_typecast_on_load.rb +23 -7
  137. data/lib/sequel/plugins/prepared_statements.rb +1 -1
  138. data/lib/sequel/plugins/prepared_statements_associations.rb +20 -14
  139. data/lib/sequel/plugins/prepared_statements_safe.rb +2 -2
  140. data/lib/sequel/plugins/rcte_tree.rb +1 -1
  141. data/lib/sequel/plugins/serialization.rb +5 -4
  142. data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
  143. data/lib/sequel/plugins/sharding.rb +7 -1
  144. data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
  145. data/lib/sequel/plugins/timestamps.rb +1 -1
  146. data/lib/sequel/plugins/touch.rb +2 -2
  147. data/lib/sequel/plugins/tree.rb +1 -1
  148. data/lib/sequel/plugins/typecast_on_load.rb +19 -4
  149. data/lib/sequel/plugins/validation_class_methods.rb +0 -30
  150. data/lib/sequel/plugins/validation_helpers.rb +13 -31
  151. data/lib/sequel/plugins/xml_serializer.rb +18 -57
  152. data/lib/sequel/sql.rb +20 -22
  153. data/lib/sequel/version.rb +2 -2
  154. data/spec/adapters/db2_spec.rb +14 -23
  155. data/spec/adapters/firebird_spec.rb +25 -29
  156. data/spec/adapters/informix_spec.rb +11 -14
  157. data/spec/adapters/mssql_spec.rb +71 -77
  158. data/spec/adapters/mysql_spec.rb +165 -172
  159. data/spec/adapters/oracle_spec.rb +36 -39
  160. data/spec/adapters/postgres_spec.rb +175 -100
  161. data/spec/adapters/spec_helper.rb +13 -11
  162. data/spec/adapters/sqlite_spec.rb +36 -44
  163. data/spec/core/connection_pool_spec.rb +2 -1
  164. data/spec/core/database_spec.rb +55 -55
  165. data/spec/core/dataset_spec.rb +45 -249
  166. data/spec/core/deprecated_spec.rb +0 -8
  167. data/spec/core/expression_filters_spec.rb +23 -5
  168. data/spec/core/object_graph_spec.rb +4 -66
  169. data/spec/core/schema_spec.rb +35 -12
  170. data/spec/core/spec_helper.rb +3 -2
  171. data/spec/core_extensions_spec.rb +17 -19
  172. data/spec/extensions/arbitrary_servers_spec.rb +2 -3
  173. data/spec/extensions/association_dependencies_spec.rb +14 -14
  174. data/spec/extensions/auto_validations_spec.rb +7 -0
  175. data/spec/extensions/blacklist_security_spec.rb +5 -5
  176. data/spec/extensions/blank_spec.rb +2 -0
  177. data/spec/extensions/class_table_inheritance_spec.rb +2 -2
  178. data/spec/extensions/columns_introspection_spec.rb +2 -29
  179. data/spec/extensions/composition_spec.rb +10 -17
  180. data/spec/extensions/core_refinements_spec.rb +5 -1
  181. data/spec/extensions/dataset_associations_spec.rb +18 -0
  182. data/spec/extensions/date_arithmetic_spec.rb +2 -2
  183. data/spec/extensions/defaults_setter_spec.rb +9 -9
  184. data/spec/extensions/dirty_spec.rb +0 -5
  185. data/spec/extensions/eval_inspect_spec.rb +2 -0
  186. data/spec/extensions/force_encoding_spec.rb +2 -18
  187. data/spec/extensions/hash_aliases_spec.rb +8 -0
  188. data/spec/extensions/hook_class_methods_spec.rb +39 -58
  189. data/spec/extensions/inflector_spec.rb +2 -0
  190. data/spec/extensions/instance_filters_spec.rb +8 -8
  191. data/spec/extensions/json_serializer_spec.rb +1 -41
  192. data/spec/extensions/list_spec.rb +1 -1
  193. data/spec/extensions/many_through_many_spec.rb +106 -109
  194. data/spec/extensions/migration_spec.rb +2 -0
  195. data/spec/extensions/named_timezones_spec.rb +1 -0
  196. data/spec/extensions/pg_array_associations_spec.rb +603 -0
  197. data/spec/extensions/pg_array_ops_spec.rb +25 -0
  198. data/spec/extensions/pg_array_spec.rb +9 -1
  199. data/spec/extensions/pg_hstore_ops_spec.rb +13 -0
  200. data/spec/extensions/pg_hstore_spec.rb +1 -0
  201. data/spec/extensions/pg_json_ops_spec.rb +131 -0
  202. data/spec/extensions/pg_json_spec.rb +10 -4
  203. data/spec/extensions/pg_range_ops_spec.rb +2 -5
  204. data/spec/extensions/pg_range_spec.rb +6 -2
  205. data/spec/extensions/pg_row_ops_spec.rb +2 -0
  206. data/spec/extensions/prepared_statements_associations_spec.rb +26 -5
  207. data/spec/extensions/rcte_tree_spec.rb +15 -15
  208. data/spec/extensions/schema_dumper_spec.rb +0 -1
  209. data/spec/extensions/schema_spec.rb +9 -9
  210. data/spec/extensions/serialization_modification_detection_spec.rb +1 -1
  211. data/spec/extensions/serialization_spec.rb +18 -29
  212. data/spec/extensions/set_overrides_spec.rb +4 -0
  213. data/spec/extensions/{many_to_one_pk_lookup_spec.rb → shared_caching_spec.rb} +1 -4
  214. data/spec/extensions/single_table_inheritance_spec.rb +4 -4
  215. data/spec/extensions/spec_helper.rb +8 -9
  216. data/spec/extensions/sql_expr_spec.rb +2 -0
  217. data/spec/extensions/string_date_time_spec.rb +2 -0
  218. data/spec/extensions/string_stripper_spec.rb +2 -0
  219. data/spec/extensions/tactical_eager_loading_spec.rb +12 -12
  220. data/spec/extensions/thread_local_timezones_spec.rb +2 -0
  221. data/spec/extensions/timestamps_spec.rb +1 -1
  222. data/spec/extensions/to_dot_spec.rb +1 -1
  223. data/spec/extensions/touch_spec.rb +24 -24
  224. data/spec/extensions/tree_spec.rb +7 -7
  225. data/spec/extensions/typecast_on_load_spec.rb +8 -1
  226. data/spec/extensions/update_primary_key_spec.rb +10 -10
  227. data/spec/extensions/validation_class_methods_spec.rb +10 -39
  228. data/spec/extensions/validation_helpers_spec.rb +29 -47
  229. data/spec/extensions/xml_serializer_spec.rb +1 -23
  230. data/spec/integration/associations_test.rb +231 -40
  231. data/spec/integration/database_test.rb +1 -1
  232. data/spec/integration/dataset_test.rb +64 -64
  233. data/spec/integration/eager_loader_test.rb +28 -28
  234. data/spec/integration/migrator_test.rb +1 -1
  235. data/spec/integration/model_test.rb +2 -2
  236. data/spec/integration/plugin_test.rb +21 -21
  237. data/spec/integration/prepared_statement_test.rb +7 -7
  238. data/spec/integration/schema_test.rb +115 -110
  239. data/spec/integration/spec_helper.rb +17 -27
  240. data/spec/integration/timezone_test.rb +1 -1
  241. data/spec/integration/transaction_test.rb +10 -10
  242. data/spec/integration/type_test.rb +2 -2
  243. data/spec/model/association_reflection_spec.rb +2 -28
  244. data/spec/model/associations_spec.rb +239 -188
  245. data/spec/model/base_spec.rb +27 -68
  246. data/spec/model/dataset_methods_spec.rb +4 -4
  247. data/spec/model/eager_loading_spec.rb +160 -172
  248. data/spec/model/hooks_spec.rb +62 -79
  249. data/spec/model/model_spec.rb +36 -51
  250. data/spec/model/plugins_spec.rb +5 -19
  251. data/spec/model/record_spec.rb +125 -151
  252. data/spec/model/spec_helper.rb +8 -6
  253. data/spec/model/validations_spec.rb +4 -17
  254. data/spec/spec_config.rb +2 -10
  255. metadata +50 -56
  256. data/lib/sequel/deprecated_core_extensions.rb +0 -135
  257. data/lib/sequel/extensions/pg_auto_parameterize.rb +0 -185
  258. data/lib/sequel/extensions/pg_statement_cache.rb +0 -318
  259. data/lib/sequel/plugins/identity_map.rb +0 -260
  260. data/lib/sequel_core.rb +0 -2
  261. data/lib/sequel_model.rb +0 -2
  262. data/spec/extensions/association_autoreloading_spec.rb +0 -102
  263. data/spec/extensions/identity_map_spec.rb +0 -337
  264. data/spec/extensions/pg_auto_parameterize_spec.rb +0 -70
  265. data/spec/extensions/pg_statement_cache_spec.rb +0 -208
  266. data/spec/rcov.opts +0 -8
  267. data/spec/spec_config.rb.example +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 339910a226e23b822c21d4ed5c0ec1b656e02c42
4
- data.tar.gz: 62b3fc6e7c75d5edb560b97e9cccd4824c59fe3d
3
+ metadata.gz: 3f1f6d7107eb83ff3840572817d310bdf10371ad
4
+ data.tar.gz: 4f04ad59f41290e20d2aba5af08947ef0ceb52e0
5
5
  SHA512:
6
- metadata.gz: a594024cffd3c08ef06a75e249faf27d86296164f882e56d9f01969078ac918362112422df36af749d35c05cc6b93de0555d282f5a3d2ac1ae2336c89d3cb475
7
- data.tar.gz: 4f500ea855dc1bb0cc2733e17a5016deeaeafa353a067bebe6dfd2601a0822da4e5f71673d13e69eebd0daed5186d20a9caa4f35feb608aac0c8a2a379b76867
6
+ metadata.gz: 355ac8d6ada27fbb499219b662c1a0a884777b0f6e95e98681415acc321bcef3178e494e5252fffa3417b086c3fcc2c04bd6fa9f45fbdc7d0f894fe5883fcbc8
7
+ data.tar.gz: 5cb1f4ef00bfaabc721e75baf1b02756e2b82a9f9c1fa2c241f01a6d717bee27c6d37b7c0bfd6876c85d9d0b78447a1d57ee9e2f6906902cf079f9d1773c0c9d
data/CHANGELOG CHANGED
@@ -1,3 +1,117 @@
1
+ === 4.0.0 (2013-07-01)
2
+
3
+ * Correctly parse composite primary keys on SQLite 3.7.16+ (jeremyevans)
4
+
5
+ * Recognize another disconnect error in the jdbc/oracle adapter (jeremyevans)
6
+
7
+ * Add pg_json_ops extension for calling JSON functions and operators in PostgreSQL 9.3+ (jeremyevans)
8
+
9
+ * Handle non-JSON plain strings, integers, and floats in PostgreSQL JSON columns in pg_json extension (jeremyevans)
10
+
11
+ * Dataset#from now accepts virtual row blocks (jeremyevans)
12
+
13
+ * Add Database#refresh_view on PostgreSQL to support refreshing materialized views (jeremyevans)
14
+
15
+ * Support the Database#drop_view :if_exists option on PostgreSQL (jeremyevans)
16
+
17
+ * Support the Database#{create,drop}_view :materialized option for creating materialized views in PostgreSQL 9.3+ (jeremyevans)
18
+
19
+ * Support the Database#create_view :recursive option for creating recursive views in PostgreSQL 9.3+ (jeremyevans)
20
+
21
+ * Support the Database#create_view :columns option for using explicit columns (jeremyevans)
22
+
23
+ * Support the Database#create_schema :owner and :if_not_exists options on PostgreSQL (jeremyevans)
24
+
25
+ * Support :index_type=>:gist option to create GIST full text indexes on PostgreSQL (jeremyevans)
26
+
27
+ * Add Postgres::ArrayOp#replace for the array_replace function in PostgreSQL 9.3+ (jeremyevans)
28
+
29
+ * Add Postgres::ArrayOp#remove for the array_remove function in PostgreSQL 9.3+ (jeremyevans)
30
+
31
+ * Add Postgres::ArrayOp#hstore for creating hstores from arrays (jeremyevans)
32
+
33
+ * Make Postgres::ArrayOp#[] return ArrayOp if given a range (jeremyevans)
34
+
35
+ * Ensure that CHECK constraints are surrounded with parentheses (jeremyevans)
36
+
37
+ * Ensure Dataset#unbind returned variable hash uses symbol keys (jeremyevans)
38
+
39
+ * Add pg_array_associations plugin, for associations based on PostgreSQL arrays containing foreign keys (jeremyevans)
40
+
41
+ * Add Sequel.deep_qualify, for easily doing a deep qualification (jeremyevans)
42
+
43
+ * Enable use of window functions for limited eager loading by default (jeremyevans)
44
+
45
+ * Handle offsets correctly when eager loading one_to_one associations (jeremyevans)
46
+
47
+ * Raise exception for infinite and NaN floats on MySQL (jeremyevans) (#677)
48
+
49
+ * Make dataset string literalization that requires database connection use dataset's chosen server (jeremyevans)
50
+
51
+ * Make sure an offset without a limit is handled correctly when eager loading (jeremyevans)
52
+
53
+ * Allow providing ranges as subscripts for array[start:end] (jeremyevans)
54
+
55
+ * Prepare one_to_one associations in the prepared_statements_associations plugin (jeremyevans)
56
+
57
+ * Use prepared statements when the association has :conditions in the prepared_statements_associations plugin (jeremyevans)
58
+
59
+ * Fix prepared statement usage in some additional cases in the prepared_statements_associations plugin (jeremyevans)
60
+
61
+ * Hex escape blob input on MySQL (jeremyevans)
62
+
63
+ * Handle more disconnect errors when using the postgres adapter with the postgres-pr driver (jeremyevans)
64
+
65
+ * Model#setter_methods private method now accepts 1 argument instead of 2 (jeremyevans)
66
+
67
+ * Model#set_restricted and #update_restricted private methods now accept 2 arguments instead of 3 (jeremyevans)
68
+
69
+ * ungraphed on an eager_graph dataset now resets the original row_proc (jeremyevans)
70
+
71
+ * eager_graph now returns a naked dataset (jeremyevans)
72
+
73
+ * All behavior deprecated in Sequel 3.48.0 has been removed (jeremyevans)
74
+
75
+ * Make adapter/integration spec environment variables more consistent (jeremyevans)
76
+
77
+ * Sequel no longer provides default databases for adapter/integration specs (jeremyevans)
78
+
79
+ * Model#save no longer calls #_refresh internally (jeremyevans)
80
+
81
+ * Model#set_all and #update_all can now update the primary key (jeremyevans)
82
+
83
+ * Integrate many_to_one_pk_lookup and association_autoreloading plugins into main associations plugin (jeremyevans)
84
+
85
+ * Make defaults_setter plugin operate in a lazy manner (jeremyevans)
86
+
87
+ * Plugins now extend the model class with ClassMethods before including InstanceMethods (jeremyevans)
88
+
89
+ * Remove Model::EMPTY_INSTANCE_VARIABLES (jeremyevans)
90
+
91
+ * Model.raise_on_typecast_failure now defaults to false (jeremyevans)
92
+
93
+ * Model#_save private method now only takes a single argument (jeremyevans)
94
+
95
+ * Remove Dataset#columns_without_introspection from columns_introspection extension (jeremyevans)
96
+
97
+ * Make boolean prepared statement arguments work on sqlite adapter when integer_booleans is true (jeremyevans)
98
+
99
+ * Make Database#tables and #views reflect search_path on PostgreSQL (jeremyevans)
100
+
101
+ * SQLite now defaults to true for integer_booleans and false for use_timestamp_timezones (jeremyevans)
102
+
103
+ * Make the default value for most option hashes a shared frozen hash (jeremyevans)
104
+
105
+ * Remove Sequel::NotImplemented exception (jeremyevans)
106
+
107
+ * Automatically alias single expressions in Dataset#get, #select_map, and #select_order_map, to work around possible DoS issues (jeremyevans)
108
+
109
+ * Use a connection queue instead of stack by default for threaded connection pools (jeremyevans)
110
+
111
+ * Remove SQL::SQLArray alias for SQL::ValueList (jeremyevans)
112
+
113
+ * Remove SQL::NoBooleanInputMethods empty module (jeremyevans)
114
+
1
115
  === 3.48.0 (2013-06-01)
2
116
 
3
117
  * Make named_timezones extension usable by databases allowing timezone strings to be given to Database#timezone= (jeremyevans)
data/Rakefile CHANGED
@@ -148,7 +148,7 @@ begin
148
148
  if RUBY_VERSION < '1.9'
149
149
  t = spec.call("#{name}_cov", files, "#{d} with coverage")
150
150
  t.rcov = true
151
- t.rcov_opts = File.read("spec/rcov.opts").split("\n")
151
+ t.rcov_opts = File.file?("spec/rcov.opts") ? File.read("spec/rcov.opts").split("\n") : []
152
152
  b.call(t) if b
153
153
  else
154
154
  desc "#{d} with coverage"
@@ -167,22 +167,25 @@ begin
167
167
  spec.call("spec_model", Dir["spec/model/*_spec.rb"], "Run model specs")
168
168
  spec.call("_spec_model_no_assoc", Dir["spec/model/*_spec.rb"].delete_if{|f| f =~ /association|eager_loading/}, '')
169
169
  spec_with_cov.call("spec_core_ext", ["spec/core_extensions_spec.rb"], "Run core extensions specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/([a-z_]+\.rb|adapters|connection_pool|database|dataset|model)"')}
170
- spec_with_cov.call("spec_plugin", Dir["spec/extensions/*_spec.rb"], "Run extension/plugin specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/([a-z_]+\.rb|adapters|connection_pool|database|dataset|model)"')}
170
+ spec_with_cov.call("spec_plugin", Dir["spec/extensions/*_spec.rb"].sort_by{rand}, "Run extension/plugin specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/([a-z_]+\.rb|adapters|connection_pool|database|dataset|model)"')}
171
171
  spec_with_cov.call("spec_integration", Dir["spec/integration/*_test.rb"], "Run integration tests")
172
172
 
173
173
  %w'postgres sqlite mysql informix oracle firebird mssql db2'.each do |adapter|
174
174
  spec_with_cov.call("spec_#{adapter}", ["spec/adapters/#{adapter}_spec.rb"] + Dir["spec/integration/*_test.rb"], "Run #{adapter} specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/([a-z_]+\.rb|connection_pool|database|dataset|model|extensions|plugins)"')}
175
175
  end
176
176
 
177
- task :spec_travis=>[:spec, :spec_plugin, :spec_core_ext, :spec_sqlite] do
177
+ task :spec_travis=>[:spec, :spec_plugin, :spec_core_ext] do
178
178
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
179
- ENV['SEQUEL_PG_SPEC_DB'] = "jdbc:postgresql://localhost/sequel_test?user=postgres"
180
- ENV['SEQUEL_MY_SPEC_DB'] = "jdbc:mysql://localhost/sequel_test?user=root"
179
+ ENV['SEQUEL_SQLITE_URL'] = "jdbc:sqlite::memory:"
180
+ ENV['SEQUEL_POSTGRES_URL'] = "jdbc:postgresql://localhost/sequel_test?user=postgres"
181
+ ENV['SEQUEL_MYSQL_URL'] = "jdbc:mysql://localhost/sequel_test?user=root"
181
182
  else
182
- ENV['SEQUEL_PG_SPEC_DB'] = "postgres://localhost/sequel_test?user=postgres"
183
- ENV['SEQUEL_MY_SPEC_DB'] = "mysql2://localhost/sequel_test?user=root"
183
+ ENV['SEQUEL_SQLITE_URL'] = "sqlite:/"
184
+ ENV['SEQUEL_POSTGRES_URL'] = "postgres://localhost/sequel_test?user=postgres"
185
+ ENV['SEQUEL_MYSQL_URL'] = "mysql2://localhost/sequel_test?user=root"
184
186
  end
185
187
 
188
+ Rake::Task['spec_sqlite'].invoke
186
189
  Rake::Task['spec_postgres'].invoke
187
190
  Rake::Task['spec_mysql'].invoke
188
191
  end
@@ -1673,18 +1673,19 @@ plugin.
1673
1673
 
1674
1674
  This setting determines what strategy to use for loading the associations
1675
1675
  that use the :limit setting to limit the number of returned records. You
1676
- can't use LIMIT directly, since you want a limit for each associated
1677
- record, not a LIMIT on the number of records returned by the dataset.
1678
-
1679
- By default, no strategy is used for one_to_one associations, and
1680
- the :ruby strategy is used for *_many associations, which does a simple
1681
- array slice after loading the associated records. That doesn't provide
1682
- a performance advantage, since all records are still loaded from the
1683
- database, but it at least makes sure the cached records are accurately
1684
- limited as they would be in the lazy load case.
1685
-
1686
- The reason no strategy is used by default for one_to_one associations
1687
- is that none is needed for a true one_to_one association (since there
1676
+ can't use LIMIT directly, since you want a limit for each group of
1677
+ associated records, not a LIMIT on the total number of records returned
1678
+ by the dataset.
1679
+
1680
+ By default, if a *_to_many association uses a limit or offset, or a
1681
+ one_to_one association uses an offset, Sequel will choose to use an
1682
+ eager limit strategy. The default strategy depends on the database
1683
+ being used. For databases which support window functions, a window
1684
+ function will be used. Other databases will just have an ruby array
1685
+ slice done on the entire record set.
1686
+
1687
+ For one_to_one associations without offsets, no strategy is used by default
1688
+ because none is needed for a true one_to_one association (since there
1688
1689
  is only one associated record per current record). However, if you are
1689
1690
  using a one_to_one association where the relationship is really one_to_many,
1690
1691
  and using an order to pick the first matching row, then if you don't
@@ -1693,17 +1694,18 @@ rows just to have Sequel ignore all rows after the first. By using a
1693
1694
  strategy to change the query to only return one associated record per
1694
1695
  current record, you can get much better database performance.
1695
1696
 
1696
- You can set a value of +true+ for this option to have Sequel select what
1697
- it thinks is the best way of limiting the records for your database. You
1698
- can also specify a symbol to manually choose a strategy. The available
1697
+ In general, Sequel picks an appropriate strategy, so it is not usually
1698
+ necessary to specify a specific strategy. The exception is for one_to_one
1699
+ associations where there is more than one associated record per current
1700
+ record. For those, you should probably specify true to this option to have
1701
+ Sequel pick an appropriate strategy.
1702
+
1703
+ You can also specify a symbol to manually choose a strategy. The available
1699
1704
  strategies are:
1700
1705
 
1701
1706
  :distinct_on :: Uses DISTINCT ON to ensure only the first matching record
1702
- is loaded (one_to_one associations only). This is used by
1703
- default on PostgreSQL.
1704
- :window_function :: Uses window functions if the database supports it.
1705
- This is used by default on databases that support window
1706
- functions.
1707
- :ruby :: Uses ruby array slicing to emulate database limiting (*_many
1708
- associations only). This is the default if the database doesn't
1709
- support window functions.
1707
+ is loaded (only used for one_to_one associations without
1708
+ offsets on PostgreSQL).
1709
+ :window_function :: Uses a ROW_NUMBER window functions to ensure the
1710
+ correctly limited/offset records are returned.
1711
+ :ruby :: Uses ruby array slicing to emulate database limiting/offsetting.
@@ -18,6 +18,13 @@ be executed unless the library has been required first. Example:
18
18
  Global extensions are loaded with Sequel.extension, and affect
19
19
  other parts of Sequel or the general ruby environment. It's not
20
20
  necessary to load them first, but it is a recommended practice.
21
+
22
+ The exception to this is global extensions that integrate with
23
+ Database-specific extensions, where the Database-specific
24
+ extension should be loaded first (such as some of the pg_*
25
+ extensions). In those cases, the global extensions should be
26
+ loaded after the Database-specific extensions.
27
+
21
28
  Example:
22
29
 
23
30
  Sequel.extension :blank
@@ -36,16 +36,6 @@ All of Sequel's extensions to the core classes are stored in Sequel's core_exten
36
36
 
37
37
  Sequel.extension :core_extensions
38
38
 
39
- For backwards compatibility, the core_extensions are loaded by default in Sequel 3. Starting in Sequel 4, the core extensions will no longer be loaded by default, so you will have to load the core_extensions extension manually using the above code. If you plan to use the core extensions, it's recommended that you manually load the extension, even in Sequel 3. If you do not plan to use the core extensions, you can change from:
40
-
41
- require 'sequel'
42
-
43
- to:
44
-
45
- require 'sequel/no_core_ext'
46
-
47
- which will load Sequel without the core extensions.
48
-
49
39
  == No Internal Dependency
50
40
 
51
41
  Sequel has no internal dependency on the core extensions. This includes Sequel's core, Sequel::Model, and all plugins and extensions that ship with Sequel. However, it is possible that external plugins and extensions will depend on the core extensions. Such plugins and extensions should be updated so that they no longer depend on the core extensions.
@@ -504,18 +504,21 @@ The following shortcuts exist for creating Sequel::SQL::OrderedExpression object
504
504
  === Sequel::SQL::Subscript
505
505
 
506
506
  Sequel::SQL::Subscript objects represent SQL database array access. They take an
507
- expression and an array of indexes:
507
+ expression and an array of indexes (or a range for an SQL array slice):
508
508
 
509
509
  Sequel::SQL::Subscript.new(:a, [1]) # "a"[1]
510
510
  Sequel::SQL::Subscript.new(:a, [1, 2]) # "a"[1, 2]
511
+ Sequel::SQL::Subscript.new(:a, [1..2]) # "a"[1:2]
511
512
 
512
513
  The following shortcuts exist for creating Sequel::SQL::Subscript objects:
513
514
 
514
515
  Sequel.subscript(:a, 1)
515
516
  Sequel.subscript(:a, 1, 2)
517
+ Sequel.subscript(:a, 1..2)
516
518
 
517
519
  :a.sql_subscript(1) # core_extensions extension
518
520
  :a.sql_subscript(1, 2) # core_extensions extension
521
+ :a.sql_subscript(1..2) # core_extensions extension
519
522
 
520
523
  === Sequel::SQL::VirtualRow
521
524
 
@@ -678,13 +678,13 @@ filters the results after the grouping has been applied, instead of
678
678
  before. One possible use is if you only wanted to return artists
679
679
  who had at least 10 albums:
680
680
 
681
- Album.group_and_count(:artist_id).having{count >= 10}
681
+ Album.group_and_count(:artist_id).having{count(:*){} >= 10}
682
682
  # SELECT artist_id, count(*) AS count FROM albums
683
- # GROUP BY artist_id HAVING count >= 10
683
+ # GROUP BY artist_id HAVING count(*) >= 10
684
684
 
685
685
  Both the WHERE clause and the HAVING clause are removed by +unfiltered+:
686
686
 
687
- Album.group_and_count(:artist_id).having{count >= 10}.
687
+ Album.group_and_count(:artist_id).having{count(:*){} >= 10}.
688
688
  where(:name.like('A%')).unfiltered
689
689
  # SELECT artist_id, count(*) AS count FROM albums GROUP BY artist_id
690
690
 
@@ -0,0 +1,262 @@
1
+ = Backwards Compatibility
2
+
3
+ * All behavior resulting in deprecation messages in 3.48.0 has been
4
+ removed or modified. If you plan on upgrading to Sequel 4.0.0 and
5
+ have not yet upgraded to 3.48.0, upgrade to 3.48.0 first, fix code
6
+ that results in deprecation warnings, and then upgrade to 4.0.0.
7
+
8
+ * The threaded connection pools now default to
9
+ :connection_handling=>:queue. You can manually set
10
+ :connection_handling=>:stack to get the previous behavior.
11
+
12
+ * Model.raise_on_typecast_failure now defaults to false. Set this to
13
+ true to get the previous behavior of raising typecast errors in the
14
+ setter methods.
15
+
16
+ * Model#save no longer calls Model#_refresh or Model#set_values
17
+ internally after an insert. Manual refreshes are now treated
18
+ differently than after creation refreshes.
19
+
20
+ * On SQLite, integer_booleans now defaults to true. Set this to
21
+ false to get the previous behavior of 't' for true and 'f' for
22
+ false. Sequel will not automatically upgrade your data, users
23
+ are responsible for doing that if they want to switch the
24
+ integer_booleans setting. Note that regardless of the setting,
25
+ Sequel will return the correct ruby values when retrieving the
26
+ rows.
27
+
28
+ Example Code to Migrate Existing Data:
29
+
30
+ DB[:table].where(:column=>'t').update(:column=>1)
31
+ DB[:table].where(:column=>'f').update(:column=>0)
32
+
33
+ * On SQLite, use_timestamp_timezones is now false by default. Set
34
+ this to true to get the previous behavior with timezone information
35
+ in timestamps. Sequel will not automatically upgrade your data,
36
+ users are responsible for doing that if they want to switch the
37
+ use_timestamp_timezones setting. Note that regardless of the
38
+ setting, Sequel will return the correct ruby values when
39
+ retrieving the rows.
40
+
41
+ * Using window functions when eagerly loading associations with
42
+ limits or offsets is now done automatically if the database
43
+ supports it. Previously, this had to be enabled manually. If
44
+ you would like to disable this optimization and just do the
45
+ slicing in ruby, set default_eager_limit_strategy = nil.
46
+
47
+ * The default value for most option hash arguments is now an shared
48
+ empty frozen hash. If you are overriding methods and modifying
49
+ option hashes, fix your code.
50
+
51
+ * The defaults_setter plugin now works in a lazy manner instead of
52
+ an eager manner. So calling the related method returns the
53
+ default value if there is no value stored, but Sequel does not
54
+ add the default values to the internal values hash, and will not
55
+ attempt to insert what it thinks is the default value when
56
+ saving the new object.
57
+
58
+ * Model#set_all and #update_all now allow setting the primary key
59
+ columns.
60
+
61
+ * The many_to_one_pk_lookup and association_autoreloading plugins
62
+ are now integrated into the default associations support.
63
+
64
+ * Plugins now extend the class with ClassMethods before including
65
+ InstanceMethods in the class.
66
+
67
+ * Dataset#get, #select_map, and #select_order_map now automatically
68
+ add aliases for unaliased expressions if given a single expression.
69
+
70
+ * Database#tables and #views on PostgreSQL now check against
71
+ the current schemas in the search path.
72
+
73
+ * Calling ungraphed on an eager_graph dataset will restore the
74
+ row_proc for that dataset. This is not backwards compatible if
75
+ your method chain does:
76
+
77
+ dataset.eager_graph.naked.ungraphed
78
+
79
+ Switch such code to:
80
+
81
+ dataset.eager_graph.ungraphed.naked
82
+
83
+ * The Model#set_restricted and #update_restricted private methods
84
+ have a slightly different API now.
85
+
86
+ * Sequel::SQL::SQLArray alias for ValueList has been removed.
87
+
88
+ * Sequel::SQL::NoBooleanInputMethods has been removed.
89
+
90
+ * Sequel::NotImplemented has been removed. Default implementations
91
+ of methods that used to raise this exception have been removed.
92
+
93
+ * Sequel::Model::EMPTY_INSTANCE_VARIABLES has been removed.
94
+
95
+ * The Sequel::Postgres::DatabaseMethods::EXCLUDE_SCHEMAS and
96
+ SYSTEM_TABLE_REGEXP constants have been removed.
97
+
98
+ * Dataset#columns_without_introspection has been removed from the
99
+ columns_introspection extension.
100
+
101
+ * Sequel no longer provides a default database for the adapter or
102
+ integration specs. Additionally, if you are using spec_config.rb
103
+ to configure a database to use when adapter/integration testing,
104
+ you may need to modify it, as Sequel now uses the DB constant for
105
+ the database being tested.
106
+
107
+ * The SEQUEL_MSSQL_SPEC_REQUIRE and SEQUEL_DB2_SPEC_REQUIRE
108
+ environment variables are no longer respected when
109
+ adapter/integration testing those databases. Use RUBYOPT with the
110
+ -r flag.
111
+
112
+ * In the 3.48.0 release notes, it was announced that
113
+ Dataset#join_table would default to :qualify=>:deep in 4.0.0. This
114
+ change was made but reverted before the release of 4.0.0 as it was
115
+ determined too likely to break existing code, there was no
116
+ deprecation warning (since it just changed a setting), and the
117
+ benefit was minimal. You can make deep qualification the default by
118
+ by overriding Dataset#default_join_table_qualification.
119
+
120
+ = New Features
121
+
122
+ * A pg_array_associations plugin has been added, for creating
123
+ an association based on a PostgreSQL array column containing
124
+ foreign keys. Example:
125
+
126
+ # Database schema:
127
+ # tags albums
128
+ # :id (int4) <--\ :id
129
+ # :name \-- :tag_ids (int4[])
130
+ # :name
131
+
132
+ class Album
133
+ plugin :pg_array_associations
134
+ pg_array_to_many :tags
135
+ end
136
+ class Tag
137
+ plugin :pg_array_associations
138
+ many_to_pg_array :albums
139
+ end
140
+
141
+ This operates similarly to a many_to_many association, but does not
142
+ require a join table. All of the usual Sequel association features
143
+ are supported, such as adding, removing, and clearing associations,
144
+ eager loading via eager and eager_graph, filtering by associations,
145
+ and dataset associations.
146
+
147
+ Note that until PostgreSQL gains the ability to enforce foreign key
148
+ constraints in array columns, this plugin is not recommended for
149
+ production use unless you plan on emulating referential integrity
150
+ constraints via triggers.
151
+
152
+ * Dataset#from now accepts virtual_row blocks, making it easy to use
153
+ with table returning functions:
154
+
155
+ DB.from{table_returning_function(arg)}
156
+
157
+ * Sequel.deep_qualify has been added, for easily doing a deep
158
+ qualification of objects:
159
+
160
+ Sequel.deep_qualify(:table, Sequel.+(:column, 1))
161
+ # ("table"."column" + 1)
162
+ Sequel.deep_qualify(:table, Sequel.like(:a, 'b'))
163
+ # ("table"."a" LIKE 'b' ESCAPE '\')
164
+
165
+ * The prepared_statements_associations plugin now handles one_to_one
166
+ associations.
167
+
168
+ * SQL::Subscript objects now handle ruby range arguments, operating as
169
+ an SQL array slice:
170
+
171
+ Sequel.subscript(:a, 1..2) # a[1:2]
172
+
173
+ * Database#create_view now accepts a :columns option to provide
174
+ explicit column names for the view.
175
+
176
+ * Postgres::ArrayOp#[] now returns an ArrayOp if given a range, since
177
+ a PostgreSQL array slice can be treated as an array.
178
+
179
+ * Postgres::ArrayOp#hstore has been added for creating hstores from
180
+ PostgreSQL arrays.
181
+
182
+ * When creating full text indexes on PostgreSQL, the :index_type=>:gist
183
+ option can be used to use a gist index instead of the default gin
184
+ index. This can be useful if insert/update speed is more important
185
+ than lookup speed.
186
+
187
+ * You can now provide the :owner option to Database#create_schema on
188
+ PostgreSQL to specify the owner of the schema.
189
+
190
+ * You can now provide the :if_exists option to Database#drop_view
191
+ on PostgreSQL to not raise an error if the view doesn't exist.
192
+
193
+ * The pg_json extension now handles non-JSON plain strings, integers
194
+ and floats in PostgreSQL JSON columns.
195
+
196
+ = Support for New Features in PostgreSQL 9.3
197
+
198
+ * A pg_json_ops extension has been added to support the new json
199
+ operators and functions.
200
+
201
+ * Postgres::ArrayOp#replace and #remove have been added for using the
202
+ array_replace and array_remove functions.
203
+
204
+ * You can now provide the :if_not_exists option when using
205
+ Database#create_schema on PostgreSQL to not raise an error if the
206
+ schema already exists.
207
+
208
+ * Database#create_view now supports a :recursive option on PostgreSQL
209
+ for creating recursive views.
210
+
211
+ * Database#create_view and #drop_view now support a :materialized option
212
+ on PostgreSQL for creating/dropping materialized views.
213
+
214
+ * Database#refresh_view has been added on PostgreSQL for refreshing
215
+ materialized views.
216
+
217
+ = Other Improvements
218
+
219
+ * Check constraints are now always surrounded by parantheses, since that
220
+ is required by the SQL standard. This fixes issues in the cases where
221
+ parentheses were not used automatically, such as when a function call
222
+ was used.
223
+
224
+ * Using an offset without a limit when eager loading now works
225
+ correctly.
226
+
227
+ * The prepared_statements_associations plugin now works correctly when
228
+ the associated class uses a filtered dataset.
229
+
230
+ * The prepared_statements_associations plugin can now use a prepared
231
+ statement for cases where the association uses :conditions.
232
+
233
+ * Boolean prepared statement arguments now work correctly in the sqlite
234
+ adapter when the integer_booleans setting is true.
235
+
236
+ * Dataset#inspect on prepared statements now handles anonymous dataset
237
+ classes correctly.
238
+
239
+ * When dataset string/blob literalization depends on having a database
240
+ connection and the dataset has an assigned server, a connection to
241
+ the assigned server is used.
242
+
243
+ * More disconnect errors are now handled when using the postgres
244
+ adapter with the postgres-pr driver, and in the jdbc/oracle adapter.
245
+
246
+ * Composite primary keys are now parsed correctly on SQLite 3.7.16+.
247
+
248
+ * Blobs are now hex escaped on MySQL, which can solve some encoding
249
+ issues when blobs are used as literals in the same SQL query with
250
+ UTF-8 strings.
251
+
252
+ * BigDecimals instances are now formatted nicer in the pretty_table
253
+ extension.
254
+
255
+ * Sequel now raises an exception when attempting to literalize infinite
256
+ and NaN floats on MySQL. In general, this would result in MySQL
257
+ raising an error, but in extreme cases it could have failed silently.
258
+
259
+ * You can now use a NO_SEQUEL_PG environment variable to not
260
+ automatically require sequel_pg in the postgres adapter.
261
+
262
+ * Dataset#unbind now always uses symbol keys in the bind variable hash.