sequel 3.47.0 → 3.48.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +230 -0
  3. data/README.rdoc +31 -40
  4. data/Rakefile +1 -14
  5. data/doc/active_record.rdoc +29 -29
  6. data/doc/association_basics.rdoc +4 -13
  7. data/doc/cheat_sheet.rdoc +8 -6
  8. data/doc/code_order.rdoc +89 -0
  9. data/doc/core_extensions.rdoc +3 -3
  10. data/doc/dataset_basics.rdoc +7 -8
  11. data/doc/dataset_filtering.rdoc +7 -2
  12. data/doc/mass_assignment.rdoc +2 -3
  13. data/doc/migration.rdoc +8 -8
  14. data/doc/model_hooks.rdoc +11 -7
  15. data/doc/object_model.rdoc +2 -2
  16. data/doc/opening_databases.rdoc +5 -14
  17. data/doc/prepared_statements.rdoc +5 -9
  18. data/doc/querying.rdoc +23 -28
  19. data/doc/reflection.rdoc +11 -0
  20. data/doc/release_notes/3.48.0.txt +477 -0
  21. data/doc/schema_modification.rdoc +12 -5
  22. data/doc/security.rdoc +2 -2
  23. data/doc/sharding.rdoc +1 -2
  24. data/doc/sql.rdoc +10 -13
  25. data/doc/testing.rdoc +8 -4
  26. data/doc/transactions.rdoc +2 -2
  27. data/doc/validations.rdoc +40 -17
  28. data/doc/virtual_rows.rdoc +2 -2
  29. data/lib/sequel/adapters/ado.rb +25 -20
  30. data/lib/sequel/adapters/ado/access.rb +1 -0
  31. data/lib/sequel/adapters/ado/mssql.rb +1 -0
  32. data/lib/sequel/adapters/db2.rb +9 -7
  33. data/lib/sequel/adapters/dbi.rb +16 -16
  34. data/lib/sequel/adapters/do.rb +17 -18
  35. data/lib/sequel/adapters/do/mysql.rb +1 -0
  36. data/lib/sequel/adapters/do/postgres.rb +2 -0
  37. data/lib/sequel/adapters/do/sqlite.rb +1 -0
  38. data/lib/sequel/adapters/firebird.rb +5 -7
  39. data/lib/sequel/adapters/ibmdb.rb +23 -20
  40. data/lib/sequel/adapters/informix.rb +8 -2
  41. data/lib/sequel/adapters/jdbc.rb +39 -35
  42. data/lib/sequel/adapters/jdbc/as400.rb +1 -0
  43. data/lib/sequel/adapters/jdbc/cubrid.rb +1 -0
  44. data/lib/sequel/adapters/jdbc/db2.rb +1 -0
  45. data/lib/sequel/adapters/jdbc/derby.rb +1 -0
  46. data/lib/sequel/adapters/jdbc/firebird.rb +1 -0
  47. data/lib/sequel/adapters/jdbc/h2.rb +1 -0
  48. data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -0
  49. data/lib/sequel/adapters/jdbc/informix.rb +1 -0
  50. data/lib/sequel/adapters/jdbc/jtds.rb +1 -0
  51. data/lib/sequel/adapters/jdbc/mssql.rb +1 -0
  52. data/lib/sequel/adapters/jdbc/mysql.rb +1 -0
  53. data/lib/sequel/adapters/jdbc/oracle.rb +1 -0
  54. data/lib/sequel/adapters/jdbc/postgresql.rb +2 -0
  55. data/lib/sequel/adapters/jdbc/progress.rb +1 -0
  56. data/lib/sequel/adapters/jdbc/sqlite.rb +1 -0
  57. data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -0
  58. data/lib/sequel/adapters/mock.rb +30 -31
  59. data/lib/sequel/adapters/mysql.rb +6 -7
  60. data/lib/sequel/adapters/mysql2.rb +5 -6
  61. data/lib/sequel/adapters/odbc.rb +22 -20
  62. data/lib/sequel/adapters/odbc/mssql.rb +1 -0
  63. data/lib/sequel/adapters/openbase.rb +4 -1
  64. data/lib/sequel/adapters/oracle.rb +10 -8
  65. data/lib/sequel/adapters/postgres.rb +12 -10
  66. data/lib/sequel/adapters/shared/access.rb +6 -0
  67. data/lib/sequel/adapters/shared/cubrid.rb +2 -0
  68. data/lib/sequel/adapters/shared/db2.rb +2 -0
  69. data/lib/sequel/adapters/shared/firebird.rb +2 -0
  70. data/lib/sequel/adapters/shared/informix.rb +2 -0
  71. data/lib/sequel/adapters/shared/mssql.rb +14 -8
  72. data/lib/sequel/adapters/shared/mysql.rb +6 -0
  73. data/lib/sequel/adapters/shared/oracle.rb +2 -0
  74. data/lib/sequel/adapters/shared/postgres.rb +14 -4
  75. data/lib/sequel/adapters/shared/progress.rb +1 -0
  76. data/lib/sequel/adapters/shared/sqlite.rb +4 -3
  77. data/lib/sequel/adapters/sqlite.rb +6 -7
  78. data/lib/sequel/adapters/swift.rb +20 -21
  79. data/lib/sequel/adapters/swift/mysql.rb +1 -0
  80. data/lib/sequel/adapters/swift/postgres.rb +2 -0
  81. data/lib/sequel/adapters/swift/sqlite.rb +1 -0
  82. data/lib/sequel/adapters/tinytds.rb +5 -6
  83. data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +68 -0
  84. data/lib/sequel/connection_pool.rb +1 -1
  85. data/lib/sequel/core.rb +57 -50
  86. data/lib/sequel/database/connecting.rb +9 -10
  87. data/lib/sequel/database/dataset.rb +11 -6
  88. data/lib/sequel/database/dataset_defaults.rb +61 -69
  89. data/lib/sequel/database/features.rb +21 -0
  90. data/lib/sequel/database/misc.rb +23 -3
  91. data/lib/sequel/database/query.rb +13 -7
  92. data/lib/sequel/database/schema_methods.rb +6 -6
  93. data/lib/sequel/database/transactions.rb +1 -0
  94. data/lib/sequel/dataset/actions.rb +51 -38
  95. data/lib/sequel/dataset/features.rb +1 -0
  96. data/lib/sequel/dataset/graph.rb +9 -33
  97. data/lib/sequel/dataset/misc.rb +30 -5
  98. data/lib/sequel/dataset/mutation.rb +2 -3
  99. data/lib/sequel/dataset/prepared_statements.rb +1 -1
  100. data/lib/sequel/dataset/query.rb +91 -27
  101. data/lib/sequel/dataset/sql.rb +40 -6
  102. data/lib/sequel/deprecated.rb +74 -0
  103. data/lib/sequel/deprecated_core_extensions.rb +135 -0
  104. data/lib/sequel/extensions/columns_introspection.rb +1 -5
  105. data/lib/sequel/extensions/core_extensions.rb +10 -3
  106. data/lib/sequel/extensions/date_arithmetic.rb +1 -0
  107. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +33 -0
  108. data/lib/sequel/extensions/filter_having.rb +58 -0
  109. data/lib/sequel/extensions/graph_each.rb +63 -0
  110. data/lib/sequel/extensions/hash_aliases.rb +44 -0
  111. data/lib/sequel/extensions/looser_typecasting.rb +14 -3
  112. data/lib/sequel/extensions/migration.rb +2 -3
  113. data/lib/sequel/extensions/named_timezones.rb +14 -1
  114. data/lib/sequel/extensions/null_dataset.rb +7 -1
  115. data/lib/sequel/extensions/pagination.rb +15 -5
  116. data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -0
  117. data/lib/sequel/extensions/pg_hstore_ops.rb +48 -14
  118. data/lib/sequel/extensions/pg_json.rb +7 -7
  119. data/lib/sequel/extensions/pg_range_ops.rb +8 -2
  120. data/lib/sequel/extensions/pg_statement_cache.rb +1 -0
  121. data/lib/sequel/extensions/pretty_table.rb +13 -4
  122. data/lib/sequel/extensions/query.rb +21 -4
  123. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +22 -0
  124. data/lib/sequel/extensions/schema_caching.rb +10 -7
  125. data/lib/sequel/extensions/schema_dumper.rb +35 -48
  126. data/lib/sequel/extensions/select_remove.rb +13 -4
  127. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +117 -0
  128. data/lib/sequel/extensions/set_overrides.rb +43 -0
  129. data/lib/sequel/extensions/to_dot.rb +6 -0
  130. data/lib/sequel/model.rb +12 -6
  131. data/lib/sequel/model/associations.rb +80 -38
  132. data/lib/sequel/model/base.rb +137 -52
  133. data/lib/sequel/model/errors.rb +7 -2
  134. data/lib/sequel/plugins/active_model.rb +13 -0
  135. data/lib/sequel/plugins/after_initialize.rb +43 -0
  136. data/lib/sequel/plugins/association_proxies.rb +63 -7
  137. data/lib/sequel/plugins/auto_validations.rb +56 -16
  138. data/lib/sequel/plugins/blacklist_security.rb +63 -0
  139. data/lib/sequel/plugins/class_table_inheritance.rb +9 -0
  140. data/lib/sequel/plugins/constraint_validations.rb +50 -8
  141. data/lib/sequel/plugins/dataset_associations.rb +2 -0
  142. data/lib/sequel/plugins/hook_class_methods.rb +7 -1
  143. data/lib/sequel/plugins/identity_map.rb +4 -0
  144. data/lib/sequel/plugins/json_serializer.rb +32 -13
  145. data/lib/sequel/plugins/optimistic_locking.rb +1 -1
  146. data/lib/sequel/plugins/rcte_tree.rb +4 -4
  147. data/lib/sequel/plugins/scissors.rb +33 -0
  148. data/lib/sequel/plugins/serialization.rb +1 -1
  149. data/lib/sequel/plugins/single_table_inheritance.rb +6 -0
  150. data/lib/sequel/plugins/tree.rb +5 -1
  151. data/lib/sequel/plugins/validation_class_methods.rb +2 -1
  152. data/lib/sequel/plugins/validation_helpers.rb +15 -11
  153. data/lib/sequel/plugins/xml_serializer.rb +12 -3
  154. data/lib/sequel/sql.rb +12 -2
  155. data/lib/sequel/timezones.rb +1 -1
  156. data/lib/sequel/version.rb +1 -1
  157. data/lib/sequel_core.rb +1 -0
  158. data/lib/sequel_model.rb +1 -0
  159. data/spec/adapters/mssql_spec.rb +24 -57
  160. data/spec/adapters/postgres_spec.rb +27 -55
  161. data/spec/adapters/spec_helper.rb +1 -1
  162. data/spec/adapters/sqlite_spec.rb +1 -1
  163. data/spec/bin_spec.rb +251 -0
  164. data/spec/core/database_spec.rb +46 -32
  165. data/spec/core/dataset_spec.rb +233 -181
  166. data/spec/core/deprecated_spec.rb +78 -0
  167. data/spec/core/expression_filters_spec.rb +3 -4
  168. data/spec/core/mock_adapter_spec.rb +9 -9
  169. data/spec/core/object_graph_spec.rb +9 -19
  170. data/spec/core/schema_spec.rb +3 -1
  171. data/spec/core/spec_helper.rb +19 -0
  172. data/spec/core_extensions_spec.rb +80 -30
  173. data/spec/extensions/after_initialize_spec.rb +24 -0
  174. data/spec/extensions/association_proxies_spec.rb +37 -1
  175. data/spec/extensions/auto_validations_spec.rb +20 -4
  176. data/spec/extensions/blacklist_security_spec.rb +87 -0
  177. data/spec/extensions/boolean_readers_spec.rb +2 -1
  178. data/spec/extensions/class_table_inheritance_spec.rb +7 -0
  179. data/spec/extensions/columns_introspection_spec.rb +3 -3
  180. data/spec/extensions/constraint_validations_plugin_spec.rb +83 -5
  181. data/spec/extensions/core_refinements_spec.rb +7 -7
  182. data/spec/extensions/dataset_associations_spec.rb +2 -2
  183. data/spec/extensions/date_arithmetic_spec.rb +1 -1
  184. data/spec/extensions/defaults_setter_spec.rb +2 -1
  185. data/spec/extensions/empty_array_ignore_nulls_spec.rb +24 -0
  186. data/spec/extensions/filter_having_spec.rb +40 -0
  187. data/spec/extensions/graph_each_spec.rb +109 -0
  188. data/spec/extensions/hash_aliases_spec.rb +16 -0
  189. data/spec/extensions/hook_class_methods_spec.rb +2 -2
  190. data/spec/extensions/identity_map_spec.rb +3 -3
  191. data/spec/extensions/json_serializer_spec.rb +19 -19
  192. data/spec/extensions/lazy_attributes_spec.rb +1 -0
  193. data/spec/extensions/list_spec.rb +13 -13
  194. data/spec/extensions/looser_typecasting_spec.rb +10 -3
  195. data/spec/extensions/many_through_many_spec.rb +1 -1
  196. data/spec/extensions/migration_spec.rb +7 -7
  197. data/spec/extensions/named_timezones_spec.rb +6 -0
  198. data/spec/extensions/nested_attributes_spec.rb +2 -2
  199. data/spec/extensions/null_dataset_spec.rb +1 -1
  200. data/spec/extensions/pagination_spec.rb +2 -2
  201. data/spec/extensions/pg_hstore_ops_spec.rb +75 -0
  202. data/spec/extensions/pg_range_ops_spec.rb +4 -2
  203. data/spec/extensions/pg_row_plugin_spec.rb +1 -1
  204. data/spec/extensions/pretty_table_spec.rb +1 -1
  205. data/spec/extensions/query_literals_spec.rb +1 -1
  206. data/spec/extensions/query_spec.rb +3 -3
  207. data/spec/extensions/schema_caching_spec.rb +3 -3
  208. data/spec/extensions/schema_dumper_spec.rb +27 -2
  209. data/spec/extensions/schema_spec.rb +2 -2
  210. data/spec/extensions/scissors_spec.rb +26 -0
  211. data/spec/extensions/select_remove_spec.rb +1 -1
  212. data/spec/extensions/sequel_3_dataset_methods_spec.rb +102 -0
  213. data/spec/extensions/set_overrides_spec.rb +45 -0
  214. data/spec/extensions/single_table_inheritance_spec.rb +10 -0
  215. data/spec/extensions/spec_helper.rb +24 -1
  216. data/spec/extensions/static_cache_spec.rb +1 -1
  217. data/spec/extensions/string_stripper_spec.rb +2 -1
  218. data/spec/extensions/to_dot_spec.rb +1 -1
  219. data/spec/extensions/typecast_on_load_spec.rb +3 -2
  220. data/spec/extensions/update_primary_key_spec.rb +2 -2
  221. data/spec/extensions/validation_class_methods_spec.rb +19 -19
  222. data/spec/extensions/validation_helpers_spec.rb +30 -21
  223. data/spec/extensions/xml_serializer_spec.rb +5 -5
  224. data/spec/integration/associations_test.rb +10 -30
  225. data/spec/integration/dataset_test.rb +20 -24
  226. data/spec/integration/eager_loader_test.rb +5 -5
  227. data/spec/integration/model_test.rb +3 -3
  228. data/spec/integration/plugin_test.rb +7 -39
  229. data/spec/integration/schema_test.rb +4 -38
  230. data/spec/integration/spec_helper.rb +2 -1
  231. data/spec/model/association_reflection_spec.rb +70 -5
  232. data/spec/model/associations_spec.rb +11 -11
  233. data/spec/model/base_spec.rb +25 -8
  234. data/spec/model/class_dataset_methods_spec.rb +143 -0
  235. data/spec/model/dataset_methods_spec.rb +1 -1
  236. data/spec/model/eager_loading_spec.rb +25 -25
  237. data/spec/model/hooks_spec.rb +1 -1
  238. data/spec/model/model_spec.rb +22 -7
  239. data/spec/model/plugins_spec.rb +1 -6
  240. data/spec/model/record_spec.rb +37 -29
  241. data/spec/model/spec_helper.rb +23 -1
  242. data/spec/model/validations_spec.rb +15 -17
  243. metadata +32 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 145949fd1421f21d5a6f4c980bb3c68ad9d79cbc
4
- data.tar.gz: 26ae6dfbcb667675caa5b2de7d89a63472fc1c62
3
+ metadata.gz: 339910a226e23b822c21d4ed5c0ec1b656e02c42
4
+ data.tar.gz: 62b3fc6e7c75d5edb560b97e9cccd4824c59fe3d
5
5
  SHA512:
6
- metadata.gz: 05bf4a0d1b5ec9b9870a7544e56971ddfbba7c244f909a8fb1acdd035463ba4b05a587f81a492c8f38adb53bc2c8e6b9d5faac7194de563fa29e0ecf2482ea93
7
- data.tar.gz: 456c3859c61bba059d5ff24dcb0dc3ea79984c919ec1f0e38ef0f7f63a2b94e86d2fd6ab15ed0e7283860509ba081beb2a0f5322bf650f18277ff67b9d720c7a
6
+ metadata.gz: a594024cffd3c08ef06a75e249faf27d86296164f882e56d9f01969078ac918362112422df36af749d35c05cc6b93de0555d282f5a3d2ac1ae2336c89d3cb475
7
+ data.tar.gz: 4f500ea855dc1bb0cc2733e17a5016deeaeafa353a067bebe6dfd2601a0822da4e5f71673d13e69eebd0daed5186d20a9caa4f35feb608aac0c8a2a379b76867
data/CHANGELOG CHANGED
@@ -1,3 +1,233 @@
1
+ === 3.48.0 (2013-06-01)
2
+
3
+ * Make named_timezones extension usable by databases allowing timezone strings to be given to Database#timezone= (jeremyevans)
4
+
5
+ * Make Dataset#or just clone if given an empty argument (jeremyevans)
6
+
7
+ * Deprecated using a mismatched number of placeholders and arguments in a placeholder literal string (jeremyevans)
8
+
9
+ * Add Dataset#qualify_to and #qualify_to_first_source to sequel_3_dataset_methods extension (jeremyevans)
10
+
11
+ * Add scissors plugin for Model.update, .delete, and .destroy (jeremyevans)
12
+
13
+ * Validate against explicit nil values in NOT NULL columns with default values in the auto_validations plugin (jeremyevans)
14
+
15
+ * Support :not_null=>:presence option for auto_validations plugin, for using presence validation for not null columns (jeremyevans)
16
+
17
+ * Rename auto_validate_presence_columns to auto_validate_not_null_columns (jeremyevans)
18
+
19
+ * Make pg_hstore_ops extension integrate with pg_array, pg_hstore, and pg_array_ops extensions (jeremyevans)
20
+
21
+ * Add Sequel.json_parser_error_class and Sequel.object_to_json to allow the use of alternative JSON implementations (jeremyevans) (#662)
22
+
23
+ * Deprecate JSON.create_id usage in the json_serializer plugin (jeremyevans)
24
+
25
+ * Emulate offsets on Microsoft Access using reverse orders and total counts (jeremyevans) (#661)
26
+
27
+ * Make ado adapter handle disconnecting an already disconnected connection (jeremyevans)
28
+
29
+ * Deprecate parsing columns for the same table name in multiple schemas on jdbc (jeremyevans)
30
+
31
+ * Allow association_proxies plugin to accept a block to give user control over which methods are proxied to the dataset (jeremyevans) (#660)
32
+
33
+ * Deprecate calling Dataset#add_graph_aliases before #graph or #set_graph_aliases (jeremyevans)
34
+
35
+ * Deprecate Model.add_graph_aliases, .insert_multiple, .query, .set_overrides, .set_defaults, .to_csv, and .paginate (jeremyevans)
36
+
37
+ * Add guide for ordering code with Sequel (jeremyevans)
38
+
39
+ * Deprecate Database#transaction :disconnect=>:retry option (jeremyevans)
40
+
41
+ * Deprecate Model.set, .update, .delete, and .destroy (jeremyevans)
42
+
43
+ * Deprecate Dataset#set (jeremyevans)
44
+
45
+ * Add specs for bin/sequel (jeremyevans)
46
+
47
+ * Make constraint_validations plugin reflect validations by column (jeremyevans)
48
+
49
+ * Allow for per-model/per-validation type customization of validation options in constraint_validations plugin (jeremyevans)
50
+
51
+ * Make Database#constraint_validations in the constraint_validations plugin have raw row values (jeremyevans)
52
+
53
+ * Fix statement freeing in the ibmdb adapter (jeremyevans)
54
+
55
+ * Make single and class table inheritance plugins handle usage of set_dataset in a subclass (jeremyevans)
56
+
57
+ * Allow validates_schema_types in validation_helpers plugin accept an options hash (jeremyevans)
58
+
59
+ * Deprecate Model.set_primary_key taking multiple arguments (jeremyevans)
60
+
61
+ * Make auto_validations plugin work with databases that don't support index parsing (jeremyevans)
62
+
63
+ * Model classes will no longer call Database#schema if it isn't supported (jeremyevans)
64
+
65
+ * Speed up Model.with_pk and with_pk! class methods (jeremyevans)
66
+
67
+ * Speed up Dataset#clone when called without an argument (jeremyevans)
68
+
69
+ * Deprecate Postgres::PGRangeOp#{starts_before,ends_after} (jeremyevans)
70
+
71
+ * Deprecate global use of null_dataset, pagination, pretty_table, query, select_remove, schema_caching, schema_dumper, and to_dot extensions (jeremyevans)
72
+
73
+ * Deprecate Dataset.introspect_all_columns in the columns_introspection extension (jeremyevans)
74
+
75
+ * Add empty_array_ignore_nulls extension for ignoring null handling for IN/NOT with an empty array (jeremyevans)
76
+
77
+ * Deprecate Sequel.empty_array_handle_nulls accessor (jeremyevans)
78
+
79
+ * Deprecate Sequel.{k,ts,tsk}_require and Sequel.check_requiring_thread (jeremyevans)
80
+
81
+ * Discontinue use of manual thread-safe requiring (jeremyevans)
82
+
83
+ * Deprecate using an unsupported client_min_messages setting on PostgreSQL (jeremyevans)
84
+
85
+ * Deprecate passing non-hash 4th argument to Dataset#join_table (jeremyevans)
86
+
87
+ * Deprecate passing non-hash 2nd argument to Dataset#union/intersect/except (jeremyevans)
88
+
89
+ * Deprecate one_to_many with :one_to_one option raising an error (jeremyevans)
90
+
91
+ * Automatically typecast hash and array to string for string columns in the looser_typecasting extension (jeremyevans)
92
+
93
+ * Deprecate automatic typecasting of hash and array to string for string columns (jeremyevans)
94
+
95
+ * Deprecate :eager_loader and :eager_grapher association options getting passed 3 separate arguments (jeremyevans)
96
+
97
+ * Deprecate validates_not_string (jeremyevans)
98
+
99
+ * Deprecate casting via __type suffix for prepared type placeholders in the postgres adapter (jeremyevans)
100
+
101
+ * Deprecate json_serializer's Model.json_create (jeremyevans)
102
+
103
+ * Deprecate json_serializer from_json and xml_serializer from_xml :all_columns and :all_associations options (jeremyevans)
104
+
105
+ * Deprecate passing an unsupported lock mode to Dataset#lock on PostgreSQL (jeremyevans)
106
+
107
+ * Deprecate Model::InstanceMethods.class_attr_{overridable,reader} (jeremyevans)
108
+
109
+ * Deprecate all methods in Dataset::PUBLIC_APPEND_METHODS except for literal, quote_identifier, quote_schema_table (jeremyevans)
110
+
111
+ * Deprecate all methods in Dataset::PRIVATE_APPEND_METHODS (jeremyevans)
112
+
113
+ * Deprecate Dataset.def_append_methods (jeremyevans)
114
+
115
+ * Deprecate Dataset#table_ref_append (jeremyevans)
116
+
117
+ * Deprecate SQL::Expression#to_s taking an argument and returning a literal SQL string (jeremyevans)
118
+
119
+ * Deprecate creating Model class methods automatically from plugin public dataset methods (jeremyevans)
120
+
121
+ * Add Sequel.cache_anonymous_models accessor (jeremyevans)
122
+
123
+ * Deprecate Sequel::Model.cache_anonymous_models accessor (jeremyevans)
124
+
125
+ * Deprecate identity_map plugin (jeremyevans)
126
+
127
+ * Deprecate Model#set_values (jeremyevans)
128
+
129
+ * Deprecate pg_auto_parameterize and pg_statement_cache extensions (jeremyevans)
130
+
131
+ * Deprecate Model#pk_or_nil (jeremyevans)
132
+
133
+ * Deprecate Model.print and Model.each_page (jeremyevans)
134
+
135
+ * Deprecate Dataset checking that the Database implements the identifier mangling methods (jeremyevans)
136
+
137
+ * Deprecate Database#reset_schema_utility_dataset private method (jeremyevans)
138
+
139
+ * Speed up Database#fetch, #from, #select, and #get by using a cached dataset (jeremyevans)
140
+
141
+ * Make sure adapters with subadapters have fully initialized database instances before calling Database.after_initialize (jeremyevans)
142
+
143
+ * Set identifier mangling methods on Database initialization (jeremyevans)
144
+
145
+ * Switch internal use of class variables to instance variables (jeremyevans)
146
+
147
+ * Deprecate passing an options hash to Database#dataset or Dataset.new (jeremyevans)
148
+
149
+ * Speed up Dataset#clone (jeremyevans)
150
+
151
+ * Add sequel_3_dataset_methods extension for Dataset#[]=, #insert_multiple, #set, #to_csv, #db=, and #opts= (jeremyevans)
152
+
153
+ * Deprecate Dataset#[]=, #insert_multiple, #to_csv, #db=, and #opts= (jeremyevans)
154
+
155
+ * Add blacklist_security plugin for Model.restricted_columns, Model.set_restricted_columns, Model#set_except, and Model#update_except (jeremyevans)
156
+
157
+ * Deprecate Model.restricted_columns, Model.set_restricted_columns, Model#set_except, and Model#update_except (jeremyevans)
158
+
159
+ * Deprecate Database#default_schema (jeremyevans)
160
+
161
+ * Deprecate Sequel::NotImplemented and defining methods that raise it (jeremyevans)
162
+
163
+ * Add Database#supports_{index_parsing,foreign_key_parsing,table_listing,view_listing}? (jeremyevans)
164
+
165
+ * Deprecate Sequel.virtual_row_instance_eval accessor (jeremyevans)
166
+
167
+ * Deprecate sequel_core.rb and sequel_model.rb (jeremyevans)
168
+
169
+ * Add graph_each extension for Dataset#graph_each (jeremyevans)
170
+
171
+ * Deprecate Dataset#graph_each (jeremyevans)
172
+
173
+ * Add set_overrides extension for Dataset#set_overrides and #set_defaults (jeremyevans)
174
+
175
+ * Deprecate Dataset#set_overrides and #set_defaults (jeremyevans)
176
+
177
+ * Deprecate Database#query in the informix adapter (jeremyevans)
178
+
179
+ * Deprecate Database#do as an alias to execute/execute_dui in some adapters (jeremyevans)
180
+
181
+ * Deprecate modifying initial Dataset hash if the hash wasn't provided as an argument (jeremyevans)
182
+
183
+ * Make active_model plugin use an errors class with autovivification (jeremyevans)
184
+
185
+ * Deprecate Model::Errors#[] autovivification (returning empty array when missing) (jeremyevans)
186
+
187
+ * Add Model#errors_class private method for choosing the errors class on a per-model basis (jeremyevans)
188
+
189
+ * Add after_initialize plugin for the after_initialize hook (jeremyevans)
190
+
191
+ * Deprecate Model after_initialize hook (jeremyevans)
192
+
193
+ * Deprecate passing two arguments to Model.new (jeremyevans)
194
+
195
+ * Deprecate choosing reciprocal associations with conditions, blocks, or differing primary keys (jeremyevans)
196
+
197
+ * Deprecate choosing first from ambiguous reciprocal associations (jeremyevans)
198
+
199
+ * Deprecate validates_type allowing nil values by default (jeremyevans)
200
+
201
+ * Deprecate the correlated_subquery eager limit strategy (jeremyevans)
202
+
203
+ * Add hash_aliases extension for making Dataset#select and #from treat hashes as alias specifiers (jeremyevans)
204
+
205
+ * Deprecate having Dataset#select and #from treat hashes as alias specifiers (jeremyevans)
206
+
207
+ * Do not automatically convert virtual row block return values to arrays by some Dataset methods (jeremyevans)
208
+
209
+ * Add filter_having extension for making Dataset#{and,filter,exclude,or} affect the HAVING clause if present (jeremyevans)
210
+
211
+ * Deprecate Dataset#select_more meaning Dataset#select when called without an existing selection (jeremyevans)
212
+
213
+ * Deprecate Dataset#and, #or, and #invert raising exceptions for no existing filter (jeremyevans)
214
+
215
+ * Deprecate Dataset#{and,filter,exclude,or} affecting the HAVING clause (jeremyevans)
216
+
217
+ * Deprecate passing explicit columns to update as separate arguments to Model#save (jeremyevans)
218
+
219
+ * Allow specifying explicit columns to update in Model#save via the :columns option (jeremyevans)
220
+
221
+ * Add ability set the default for join_table's :qualify option via Dataset#default_join_table_qualification (jeremyevans)
222
+
223
+ * Deprecated :root=>true meaning :root=>:both in the json_serializer (jeremyevans)
224
+
225
+ * Deprecate core extension usage if the core_extensions have not been explicitly loaded (jeremyevans)
226
+
227
+ * Deprecate Symbol#{[],<,<=,>,>=} methods when using the core_extensions (jeremyevans)
228
+
229
+ * Add ruby18_symbol_extensions extension for the Symbol#{[],<,<=,>,>=} methods (jeremyevans)
230
+
1
231
  === 3.47.0 (2013-05-01)
2
232
 
3
233
  * Don't fail for missing conversion proc in pg_typecast_on_load plugin (jeremyevans)
@@ -39,7 +39,6 @@ If you have any comments or suggestions please post to the Google group.
39
39
 
40
40
  == A Short Example
41
41
 
42
- require 'rubygems'
43
42
  require 'sequel'
44
43
 
45
44
  DB = Sequel.sqlite # memory database
@@ -122,6 +121,15 @@ You can specify a block to connect, which will disconnect from the database afte
122
121
 
123
122
  Sequel.connect('postgres://user:password@host:port/database_name'){|db| db[:posts].delete}
124
123
 
124
+ === The DB convention
125
+
126
+ Throughout Sequel's documentation, you will see the +DB+ constant used to refer to the Sequel::Database instance you create.
127
+ This reflects the recommendation that for an app with a single Sequel::Database instance, the Sequel convention is to store
128
+ the instance in the +DB+ constant. This is just a convention, it's not required, but it is recommended.
129
+
130
+ Note that some frameworks that use Sequel may create the Sequel::Database instance for you, and you might not know
131
+ how to access it. In most cases, you can access the Sequel::Database instance through <tt>Sequel::Model.db</tt>.
132
+
125
133
  === Arbitrary SQL queries
126
134
 
127
135
  You can execute arbitrary SQL code using <tt>Database#run</tt>:
@@ -363,7 +371,7 @@ Updating records in the table is done with +update+:
363
371
 
364
372
  You can reference table columns when choosing what values to set:
365
373
 
366
- posts.where{|o| o.stamp < Date.today - 7}.update(:backup_number => :backup_number + 1)
374
+ posts.where{|o| o.stamp < Date.today - 7}.update(:backup_number => Sequel.+(:backup_number, 1))
367
375
  # UPDATE posts SET backup_number = backup_number + 1 WHERE stamp < '2010-07-07'
368
376
 
369
377
  As with +delete+, +update+ affects all rows in the dataset, so +where+ first,
@@ -417,18 +425,6 @@ You can then do anything you like with the dataset:
417
425
  # ON order_items.item_id = items.id
418
426
  # WHERE order_items.order_id = 1234
419
427
 
420
- === Graphing Datasets
421
-
422
- When retrieving records from joined datasets, you get the results in a single hash, which is subject to clobbering if you have columns with the same name in multiple tables:
423
-
424
- DB[:items].join(:order_items, :item_id => :id).first
425
- => {:id=>order_items.id, :item_id=>order_items.item_id}
426
-
427
- Using +graph+, you can split the result hashes into subhashes, one per join:
428
-
429
- DB[:items].graph(:order_items, :item_id => :id).first
430
- => {:items=>{:id=>items.id}, :order_items=>{:id=>order_items.id, :item_id=>order_items.item_id}}
431
-
432
428
  == Column references in Sequel
433
429
 
434
430
  Sequel expects column names to be specified using symbols. In addition, returned hashes always use symbols as their keys. This allows you to freely mix literal values and column references in many cases. For example, the two following lines produce equivalent SQL:
@@ -491,6 +487,10 @@ Model classes are defined as regular Ruby classes inheriting from <tt>Sequel::Mo
491
487
  class Post < Sequel::Model
492
488
  end
493
489
 
490
+ When a model class is created, it parses the schema in the table from the database, and
491
+ automatically sets up accessor methods for all of the columns in the table (Sequel::Model
492
+ implements the active record pattern).
493
+
494
494
  Sequel model classes assume that the table name is an underscored plural of the class name:
495
495
 
496
496
  Post.table_name #=> :posts
@@ -535,9 +535,9 @@ A single model instance can also be fetched by specifying a condition:
535
535
  post = Post[:title => 'hello world']
536
536
  post = Post.first{num_comments < 10}
537
537
 
538
- === Iterating over records
538
+ === Acts like a dataset
539
539
 
540
- A model class lets you iterate over subsets of records by proxying many methods to the underlying dataset. This means that you can use most of the +Dataset+ API to create customized queries that return model instances, e.g.:
540
+ A model class forwards many methods to the underlying dataset. This means that you can use most of the +Dataset+ API to create customized queries that return model instances, e.g.:
541
541
 
542
542
  Post.where(:category => 'ruby').each{|post| p post}
543
543
 
@@ -562,21 +562,25 @@ If the record's attributes names are not valid columns in the model's dataset (m
562
562
  post[:id] #=> 123
563
563
  post[:title] #=> 'hello world'
564
564
 
565
- You can also modify record values using attribute setters, the <tt>[]=</tt> method, or the +set+ method:
565
+ You can also modify record values using attribute setters or the <tt>[]=</tt> method.
566
+
566
567
 
567
568
  post.title = 'hey there'
568
- # or
569
569
  post[:title] = 'hey there'
570
- # or
571
- post.set(:title=>'hey there')
572
570
 
573
571
  That will just change the value for the object, it will not update the row in the database. To update the database row, call the +save+ method:
574
572
 
575
573
  post.save
576
574
 
577
- You can modify record values and save the changes to the object in a single method call using the +update+ method:
575
+ === Mass assignment
576
+
577
+ You can also set the values for multiple columns in a single method call, using one of the mass-assignment methods. See the {mass assignment guide}[link:files/doc/mass_assignment_rdoc.html] for details. For example +set+ updates the model's column values without saving:
578
578
 
579
- post.update(:title => 'hey there')
579
+ post.set(:title=>'hey there', :updated_by=>'foo')
580
+
581
+ and +update+ updates the model's column values and then saves the changes to the database:
582
+
583
+ post.update(:title => 'hey there', :updated_by=>'foo')
580
584
 
581
585
  === Creating new records
582
586
 
@@ -625,13 +629,13 @@ You can delete individual records by calling +delete+ or +destroy+. The only dif
625
629
  post.delete # => bypasses hooks
626
630
  post.destroy # => runs hooks
627
631
 
628
- Records can also be deleted en-masse by calling <tt>Model.delete</tt> and <tt>Model.destroy</tt>. As stated above, you can specify filters for the deleted records:
632
+ Records can also be deleted en-masse by calling <tt>delete</tt> and <tt>destroy</tt> on the model's dataset. As stated above, you can specify filters for the deleted records:
629
633
 
630
634
  Post.where(:category => 32).delete # => bypasses hooks
631
635
  Post.where(:category => 32).destroy # => runs hooks
632
636
 
633
- Please note that if <tt>Model.destroy</tt> is called, each record is deleted
634
- separately, but <tt>Model.delete</tt> deletes all matching records with a single
637
+ Please note that if <tt>destroy</tt> is called, each record is deleted
638
+ separately, but <tt>delete</tt> deletes all matching records with a single
635
639
  SQL query.
636
640
 
637
641
  === Associations
@@ -744,19 +748,7 @@ You can dynamically customize eager loads for both +eager+ and +eager_graph+ whi
744
748
 
745
749
  === Extending the underlying dataset
746
750
 
747
- The obvious way to add table-wide logic is to define class methods to the model class definition. That way you can define subsets of the underlying dataset, change the ordering, or perform actions on multiple records:
748
-
749
- class Post < Sequel::Model
750
- def self.posts_with_few_comments
751
- where{num_comments < 30}
752
- end
753
-
754
- def self.clean_posts_with_few_comments
755
- posts_with_few_comments.delete
756
- end
757
- end
758
-
759
- You can also implement table-wide logic by defining methods on the dataset using +dataset_module+:
751
+ The recommended way to implement table-wide logic by defining methods on the dataset using +dataset_module+:
760
752
 
761
753
  class Post < Sequel::Model
762
754
  dataset_module do
@@ -770,7 +762,7 @@ You can also implement table-wide logic by defining methods on the dataset using
770
762
  end
771
763
  end
772
764
 
773
- This is the recommended way of implementing table-wide operations, and allows you to have access to your model API from filtered datasets as well:
765
+ This allows you to have access to your model API from filtered datasets as well:
774
766
 
775
767
  Post.where(:category => 'ruby').clean_posts_with_few_comments
776
768
 
@@ -798,4 +790,3 @@ raise an error or return false depending on how it is configured
798
790
  errors.add(:written_on, "should be in the past") if written_on >= Time.now
799
791
  end
800
792
  end
801
-
data/Rakefile CHANGED
@@ -162,6 +162,7 @@ begin
162
162
 
163
163
  task :default => [:spec]
164
164
  spec_with_cov.call("spec", Dir["spec/{core,model}/*_spec.rb"], "Run core and model specs"){|t| t.rcov_opts.concat(%w'--exclude "lib/sequel/(adapters/([a-ln-z]|m[a-np-z])|extensions/core_extensions)"')}
165
+ spec.call("spec_bin", ["spec/bin_spec.rb"], "Run bin/sequel specs")
165
166
  spec.call("spec_core", Dir["spec/core/*_spec.rb"], "Run core specs")
166
167
  spec.call("spec_model", Dir["spec/model/*_spec.rb"], "Run model specs")
167
168
  spec.call("_spec_model_no_assoc", Dir["spec/model/*_spec.rb"].delete_if{|f| f =~ /association|eager_loading/}, '')
@@ -197,20 +198,6 @@ rescue LoadError
197
198
  end
198
199
  end
199
200
 
200
- desc "check documentation coverage"
201
- task :dcov do
202
- sh %{find lib -name '*.rb' | xargs dcov}
203
- end
204
-
205
- ### Statistics
206
-
207
- desc "Report code statistics (KLOCs, etc) from the application"
208
- task :stats do
209
- STATS_DIRECTORIES = [%w(Code lib/), %w(Spec spec)].map{|name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir)}
210
- require "./extra/stats"
211
- CodeStatistics.new(*STATS_DIRECTORIES).to_s
212
- end
213
-
214
201
  desc "Print Sequel version"
215
202
  task :version do
216
203
  puts VERS.call
@@ -1,7 +1,6 @@
1
1
  = Sequel for ActiveRecord Users
2
2
 
3
- This guide is aimed at helping ActiveRecord users transition to Sequel. It assumes the user is familiar with ActiveRecord 2, but if you are familiar with ActiveRecord 3, the transition should be even easier.
4
-
3
+ This guide is aimed at helping ActiveRecord users transition to Sequel. It assumes the user is familiar with ActiveRecord 2, but if you are familiar with a newer ActiveRecord version, the transition should be even easier.
5
4
 
6
5
  == Introduction
7
6
 
@@ -164,7 +163,7 @@ By now, you should have the idea that Sequel supports most things that ActiveRec
164
163
 
165
164
  === Method Chaining
166
165
 
167
- Unlike ActiveRecord 2, Sequel uses method chains on datasets for retrieving objects, so instead of:
166
+ Unlike ActiveRecord 2 (and similar to ActiveRecord 3+), Sequel uses method chains on datasets for retrieving objects, so instead of:
168
167
 
169
168
  Album.find(:all, :conditions=>['name > ? AND artist_id = ?', 'RF', 1],
170
169
  :order=>'copies_sold', :select=>'id, name')
@@ -423,8 +422,8 @@ ActiveRecord option :: Sequel option
423
422
  <tt>:foreign_key</tt> :: <tt>:left_key</tt>
424
423
  <tt>:association_foreign_key</tt> :: <tt>:right_key</tt>
425
424
  <tt>:join_table</tt> :: <tt>:join_table</tt>
426
- <tt>:delete_sql</tt> :: Override the _remove_association method for the association
427
- <tt>:insert_sql</tt> :: Override the _add_association method for the association
425
+ <tt>:delete_sql</tt> :: <tt>:remover</tt>
426
+ <tt>:insert_sql</tt> :: <tt>:adder</tt>
428
427
 
429
428
  == Validation Errors
430
429
 
@@ -499,15 +498,7 @@ Sequel only uses connections for the minimum amount of time necessary, checking
499
498
  ...
500
499
  end
501
500
 
502
- Note that the connection is yielded to the block, and the block ensures it is returned to the pool. Sequel doesn't have a method that returns a connection, since that would check it out with no ability to ensure it is returned to the pool
503
-
504
- ==== +count+
505
-
506
- Without arguments, +count+ works the same in Sequel as in ActiveRecord. For a single column:
507
-
508
- Album.get{count(column)}
509
-
510
- For options, you should use method chaining to build your query and execute it.
501
+ Note that the connection is yielded to the block, and the block ensures it is returned to the pool. Sequel doesn't have a method that returns a connection, since that would check it out with no ability to ensure it is returned to the pool.
511
502
 
512
503
  ==== +count_by_sql+
513
504
 
@@ -517,11 +508,15 @@ You can call +with_sql+ to set the SQL to use, and the +single_value+ to retriev
517
508
 
518
509
  ==== +delete+, +delete_all+
519
510
 
520
- Calling +delete+ directly on the class will probably delete all rows in the table. You want to filter first, then call +delete+:
511
+ You probably want to filter first, then call +delete+:
521
512
 
522
513
  Album.where(:id=>id).delete
523
514
  Album.where("artist_id = ?", 5).delete
524
515
 
516
+ If you really want to delete all rows in the table,call +delete+ on the Model's dataset:
517
+
518
+ Album.dataset.delete
519
+
525
520
  ==== +destroy+, +destroy_all+
526
521
 
527
522
  Similar to +delete+, you filter first, then +destroy+:
@@ -529,6 +524,10 @@ Similar to +delete+, you filter first, then +destroy+:
529
524
  Album.where(:id=>id).destroy
530
525
  Album.where("artist_id = ?", 5).destroy
531
526
 
527
+ If you really want to destroy all rows in the table,call +destroy+ on the Model's dataset:
528
+
529
+ Album.dataset.destroy
530
+
532
531
  ==== +establish_connection+
533
532
 
534
533
  If you want to use a specific <tt>Sequel::Database</tt> object, you can use <tt>db=</tt>:
@@ -553,7 +552,10 @@ ActiveRecord's +find+ can be used for a lot of different things. If you are try
553
552
 
554
553
  Album[1]
555
554
 
556
- Note that Sequel returns nil if no record is found, it doesn't raise an exception.
555
+ Note that Sequel returns nil if no record is found, it doesn't raise an exception. To raise an exception if no record
556
+ is found:
557
+
558
+ Album.with_pk!(1)
557
559
 
558
560
  If you want to find multiple objects using an array of primary keys:
559
561
 
@@ -578,8 +580,8 @@ Here's a mapping of ActiveRecord +find+ options to <tt>Sequel::Dataset</tt> meth
578
580
  :conditions :: filter, where
579
581
  :order :: order
580
582
  :group :: group
581
- :limit :: limit # first argument
582
- :offset :: limit # second argument
583
+ :limit :: limit
584
+ :offset :: limit # second entry in limit array
583
585
  :joins :: join, left_join, etc. # many other join methods
584
586
  :include :: eager, eager_graph # eager does preloading, eager_graph does JOINs
585
587
  :select :: select
@@ -628,6 +630,7 @@ For anything more complex, you can use +dataset_module+:
628
630
 
629
631
  If you want to completely reload the schema for the table:
630
632
 
633
+ Album.instance_variable_set(:@db_schema, nil)
631
634
  Album.send(:get_db_schema, true)
632
635
 
633
636
  ==== +serialize+, +seralized_attributes+
@@ -679,6 +682,10 @@ Just like +delete+ and +destroy+, you filter first, then +update+:
679
682
  Album.where(:id=>id).update(:name=>'RF')
680
683
  Album.where("artist_id = ?", 5).update(:copies_sold=>0)
681
684
 
685
+ Likewise, to update all rows in the model:
686
+
687
+ Album.dataset.update(:name=>'RF')
688
+
682
689
  Note that +update+ in that case will operate on a dataset, so it won't run model validations or hooks. If you want those run:
683
690
 
684
691
  Album[id].update(:name=>'RF')
@@ -698,6 +705,7 @@ ActiveRecord Method :: Sequel Method
698
705
  +average+ :: +avg+
699
706
  +belongs_to+ :: +many_to_one+
700
707
  +columns_hash+ :: +db_schema+
708
+ +count+ :: +count+
701
709
  +changed+ :: +changed_columns+
702
710
  +create+ :: +create+
703
711
  +has_and_belongs_to_many+ :: +many_to_many+
@@ -772,14 +780,6 @@ If it is a new record:
772
780
  album = Album.new
773
781
  album.send(:set_values, gold_album.values)
774
782
 
775
- ==== +clone+
776
-
777
- You probably have to use +set_values+, a private method:
778
-
779
- album = Album[1]
780
- cloned_album = Album.new
781
- cloned_album.send(:set_values, album.values.dup)
782
-
783
783
  ==== +column_for_attribute+
784
784
 
785
785
  You can access this through the +db_schema+ hash:
@@ -806,7 +806,7 @@ Assuming you want the full behavior of saving just one column without validating
806
806
 
807
807
  album.values[:column] ||= 0
808
808
  album.values[:column] -= 1 # or += 1 for increment!
809
- album.save(:column, :validate=>false)
809
+ album.save(:columns=>[:column], :validate=>false)
810
810
 
811
811
  ==== <tt>has_attribute?</tt>
812
812
 
@@ -837,7 +837,7 @@ No equivalent, but very easy to add:
837
837
 
838
838
  If you want to save just that column:
839
839
 
840
- album.save(:column, :validate=>false)
840
+ album.save(:columns=>[:column], :validate=>false)
841
841
 
842
842
  ==== +transaction+
843
843
 
@@ -850,7 +850,7 @@ Just like in the class, you can access the transaction method through the +db+:
850
850
  To only set and save a specific column:
851
851
 
852
852
  album.set(:column => value)
853
- album.save(:column, :validate=>false)
853
+ album.save(:columns=>[:column], :validate=>false)
854
854
 
855
855
  ==== +update_attributes+, <tt>update_attributes!</tt>
856
856