sequel 4.26.0 → 5.37.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (692) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +405 -5656
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +232 -157
  5. data/bin/sequel +32 -9
  6. data/doc/advanced_associations.rdoc +252 -188
  7. data/doc/association_basics.rdoc +231 -273
  8. data/doc/bin_sequel.rdoc +5 -3
  9. data/doc/cheat_sheet.rdoc +75 -48
  10. data/doc/code_order.rdoc +28 -10
  11. data/doc/core_extensions.rdoc +104 -63
  12. data/doc/dataset_basics.rdoc +12 -21
  13. data/doc/dataset_filtering.rdoc +99 -86
  14. data/doc/extensions.rdoc +3 -10
  15. data/doc/mass_assignment.rdoc +74 -31
  16. data/doc/migration.rdoc +72 -46
  17. data/doc/model_dataset_method_design.rdoc +129 -0
  18. data/doc/model_hooks.rdoc +15 -25
  19. data/doc/model_plugins.rdoc +12 -12
  20. data/doc/mssql_stored_procedures.rdoc +3 -3
  21. data/doc/object_model.rdoc +59 -69
  22. data/doc/opening_databases.rdoc +84 -94
  23. data/doc/postgresql.rdoc +268 -38
  24. data/doc/prepared_statements.rdoc +29 -24
  25. data/doc/querying.rdoc +184 -164
  26. data/doc/reflection.rdoc +5 -6
  27. data/doc/release_notes/5.0.0.txt +159 -0
  28. data/doc/release_notes/5.1.0.txt +31 -0
  29. data/doc/release_notes/5.10.0.txt +84 -0
  30. data/doc/release_notes/5.11.0.txt +83 -0
  31. data/doc/release_notes/5.12.0.txt +141 -0
  32. data/doc/release_notes/5.13.0.txt +27 -0
  33. data/doc/release_notes/5.14.0.txt +63 -0
  34. data/doc/release_notes/5.15.0.txt +39 -0
  35. data/doc/release_notes/5.16.0.txt +110 -0
  36. data/doc/release_notes/5.17.0.txt +31 -0
  37. data/doc/release_notes/5.18.0.txt +69 -0
  38. data/doc/release_notes/5.19.0.txt +28 -0
  39. data/doc/release_notes/5.2.0.txt +33 -0
  40. data/doc/release_notes/5.20.0.txt +89 -0
  41. data/doc/release_notes/5.21.0.txt +87 -0
  42. data/doc/release_notes/5.22.0.txt +48 -0
  43. data/doc/release_notes/5.23.0.txt +56 -0
  44. data/doc/release_notes/5.24.0.txt +56 -0
  45. data/doc/release_notes/5.25.0.txt +32 -0
  46. data/doc/release_notes/5.26.0.txt +35 -0
  47. data/doc/release_notes/5.27.0.txt +21 -0
  48. data/doc/release_notes/5.28.0.txt +16 -0
  49. data/doc/release_notes/5.29.0.txt +22 -0
  50. data/doc/release_notes/5.3.0.txt +121 -0
  51. data/doc/release_notes/5.30.0.txt +20 -0
  52. data/doc/release_notes/5.31.0.txt +148 -0
  53. data/doc/release_notes/5.32.0.txt +46 -0
  54. data/doc/release_notes/5.33.0.txt +24 -0
  55. data/doc/release_notes/5.34.0.txt +40 -0
  56. data/doc/release_notes/5.35.0.txt +56 -0
  57. data/doc/release_notes/5.36.0.txt +60 -0
  58. data/doc/release_notes/5.37.0.txt +30 -0
  59. data/doc/release_notes/5.4.0.txt +80 -0
  60. data/doc/release_notes/5.5.0.txt +61 -0
  61. data/doc/release_notes/5.6.0.txt +31 -0
  62. data/doc/release_notes/5.7.0.txt +108 -0
  63. data/doc/release_notes/5.8.0.txt +170 -0
  64. data/doc/release_notes/5.9.0.txt +99 -0
  65. data/doc/schema_modification.rdoc +102 -77
  66. data/doc/security.rdoc +160 -87
  67. data/doc/sharding.rdoc +74 -47
  68. data/doc/sql.rdoc +135 -122
  69. data/doc/testing.rdoc +34 -18
  70. data/doc/thread_safety.rdoc +2 -4
  71. data/doc/transactions.rdoc +101 -19
  72. data/doc/validations.rdoc +64 -51
  73. data/doc/virtual_rows.rdoc +90 -109
  74. data/lib/sequel.rb +3 -1
  75. data/lib/sequel/adapters/ado.rb +154 -22
  76. data/lib/sequel/adapters/ado/access.rb +21 -21
  77. data/lib/sequel/adapters/ado/mssql.rb +8 -15
  78. data/lib/sequel/adapters/amalgalite.rb +17 -25
  79. data/lib/sequel/adapters/ibmdb.rb +52 -58
  80. data/lib/sequel/adapters/jdbc.rb +149 -127
  81. data/lib/sequel/adapters/jdbc/db2.rb +32 -40
  82. data/lib/sequel/adapters/jdbc/derby.rb +56 -58
  83. data/lib/sequel/adapters/jdbc/h2.rb +40 -30
  84. data/lib/sequel/adapters/jdbc/hsqldb.rb +22 -33
  85. data/lib/sequel/adapters/jdbc/jtds.rb +4 -10
  86. data/lib/sequel/adapters/jdbc/mssql.rb +6 -12
  87. data/lib/sequel/adapters/jdbc/mysql.rb +17 -18
  88. data/lib/sequel/adapters/jdbc/oracle.rb +25 -19
  89. data/lib/sequel/adapters/jdbc/postgresql.rb +90 -69
  90. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +14 -24
  91. data/lib/sequel/adapters/jdbc/sqlite.rb +50 -12
  92. data/lib/sequel/adapters/jdbc/sqlserver.rb +36 -9
  93. data/lib/sequel/adapters/jdbc/transactions.rb +25 -39
  94. data/lib/sequel/adapters/mock.rb +104 -113
  95. data/lib/sequel/adapters/mysql.rb +42 -61
  96. data/lib/sequel/adapters/mysql2.rb +126 -35
  97. data/lib/sequel/adapters/odbc.rb +21 -28
  98. data/lib/sequel/adapters/odbc/db2.rb +3 -1
  99. data/lib/sequel/adapters/odbc/mssql.rb +11 -15
  100. data/lib/sequel/adapters/odbc/oracle.rb +11 -0
  101. data/lib/sequel/adapters/oracle.rb +62 -68
  102. data/lib/sequel/adapters/postgres.rb +257 -311
  103. data/lib/sequel/adapters/postgresql.rb +3 -1
  104. data/lib/sequel/adapters/shared/access.rb +75 -79
  105. data/lib/sequel/adapters/shared/db2.rb +96 -74
  106. data/lib/sequel/adapters/shared/mssql.rb +258 -213
  107. data/lib/sequel/adapters/shared/mysql.rb +284 -216
  108. data/lib/sequel/adapters/shared/oracle.rb +175 -60
  109. data/lib/sequel/adapters/shared/postgres.rb +829 -383
  110. data/lib/sequel/adapters/shared/sqlanywhere.rb +105 -127
  111. data/lib/sequel/adapters/shared/sqlite.rb +382 -159
  112. data/lib/sequel/adapters/sqlanywhere.rb +53 -38
  113. data/lib/sequel/adapters/sqlite.rb +111 -105
  114. data/lib/sequel/adapters/tinytds.rb +38 -46
  115. data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +8 -9
  116. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +7 -5
  117. data/lib/sequel/adapters/utils/mysql_mysql2.rb +87 -0
  118. data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +56 -0
  119. data/lib/sequel/adapters/utils/replace.rb +3 -4
  120. data/lib/sequel/adapters/utils/split_alter_table.rb +2 -0
  121. data/lib/sequel/adapters/utils/stored_procedures.rb +9 -22
  122. data/lib/sequel/adapters/utils/unmodified_identifiers.rb +28 -0
  123. data/lib/sequel/ast_transformer.rb +13 -89
  124. data/lib/sequel/connection_pool.rb +54 -26
  125. data/lib/sequel/connection_pool/sharded_single.rb +19 -12
  126. data/lib/sequel/connection_pool/sharded_threaded.rb +160 -111
  127. data/lib/sequel/connection_pool/single.rb +21 -12
  128. data/lib/sequel/connection_pool/threaded.rb +137 -119
  129. data/lib/sequel/core.rb +352 -320
  130. data/lib/sequel/database.rb +19 -2
  131. data/lib/sequel/database/connecting.rb +70 -55
  132. data/lib/sequel/database/dataset.rb +15 -5
  133. data/lib/sequel/database/dataset_defaults.rb +20 -102
  134. data/lib/sequel/database/features.rb +20 -4
  135. data/lib/sequel/database/logging.rb +25 -7
  136. data/lib/sequel/database/misc.rb +132 -118
  137. data/lib/sequel/database/query.rb +51 -28
  138. data/lib/sequel/database/schema_generator.rb +188 -75
  139. data/lib/sequel/database/schema_methods.rb +161 -92
  140. data/lib/sequel/database/transactions.rb +260 -58
  141. data/lib/sequel/dataset.rb +28 -12
  142. data/lib/sequel/dataset/actions.rb +354 -170
  143. data/lib/sequel/dataset/dataset_module.rb +46 -0
  144. data/lib/sequel/dataset/features.rb +81 -34
  145. data/lib/sequel/dataset/graph.rb +82 -58
  146. data/lib/sequel/dataset/misc.rb +139 -47
  147. data/lib/sequel/dataset/placeholder_literalizer.rb +66 -26
  148. data/lib/sequel/dataset/prepared_statements.rb +188 -85
  149. data/lib/sequel/dataset/query.rb +428 -214
  150. data/lib/sequel/dataset/sql.rb +446 -339
  151. data/lib/sequel/deprecated.rb +14 -2
  152. data/lib/sequel/exceptions.rb +48 -16
  153. data/lib/sequel/extensions/_model_constraint_validations.rb +16 -0
  154. data/lib/sequel/extensions/_model_pg_row.rb +43 -0
  155. data/lib/sequel/extensions/_pretty_table.rb +10 -9
  156. data/lib/sequel/extensions/any_not_empty.rb +45 -0
  157. data/lib/sequel/extensions/arbitrary_servers.rb +15 -11
  158. data/lib/sequel/extensions/auto_literal_strings.rb +74 -0
  159. data/lib/sequel/extensions/blank.rb +2 -0
  160. data/lib/sequel/extensions/caller_logging.rb +79 -0
  161. data/lib/sequel/extensions/columns_introspection.rb +9 -4
  162. data/lib/sequel/extensions/connection_expiration.rb +99 -0
  163. data/lib/sequel/extensions/connection_validator.rb +26 -13
  164. data/lib/sequel/extensions/constant_sql_override.rb +65 -0
  165. data/lib/sequel/extensions/constraint_validations.rb +93 -38
  166. data/lib/sequel/extensions/core_extensions.rb +45 -53
  167. data/lib/sequel/extensions/core_refinements.rb +44 -46
  168. data/lib/sequel/extensions/current_datetime_timestamp.rb +5 -4
  169. data/lib/sequel/extensions/dataset_source_alias.rb +4 -0
  170. data/lib/sequel/extensions/date_arithmetic.rb +42 -16
  171. data/lib/sequel/extensions/datetime_parse_to_time.rb +37 -0
  172. data/lib/sequel/extensions/duplicate_columns_handler.rb +94 -0
  173. data/lib/sequel/extensions/empty_array_consider_nulls.rb +7 -3
  174. data/lib/sequel/extensions/error_sql.rb +7 -3
  175. data/lib/sequel/extensions/escaped_like.rb +100 -0
  176. data/lib/sequel/extensions/eval_inspect.rb +14 -15
  177. data/lib/sequel/extensions/exclude_or_null.rb +68 -0
  178. data/lib/sequel/extensions/fiber_concurrency.rb +24 -0
  179. data/lib/sequel/extensions/freeze_datasets.rb +3 -0
  180. data/lib/sequel/extensions/from_block.rb +2 -31
  181. data/lib/sequel/extensions/graph_each.rb +19 -6
  182. data/lib/sequel/extensions/identifier_mangling.rb +180 -0
  183. data/lib/sequel/extensions/implicit_subquery.rb +48 -0
  184. data/lib/sequel/extensions/index_caching.rb +109 -0
  185. data/lib/sequel/extensions/inflector.rb +8 -4
  186. data/lib/sequel/extensions/integer64.rb +32 -0
  187. data/lib/sequel/extensions/looser_typecasting.rb +19 -9
  188. data/lib/sequel/extensions/migration.rb +132 -80
  189. data/lib/sequel/extensions/mssql_emulate_lateral_with_apply.rb +4 -0
  190. data/lib/sequel/extensions/named_timezones.rb +88 -23
  191. data/lib/sequel/extensions/no_auto_literal_strings.rb +4 -0
  192. data/lib/sequel/extensions/null_dataset.rb +12 -8
  193. data/lib/sequel/extensions/pagination.rb +35 -28
  194. data/lib/sequel/extensions/pg_array.rb +227 -316
  195. data/lib/sequel/extensions/pg_array_ops.rb +19 -7
  196. data/lib/sequel/extensions/pg_enum.rb +69 -24
  197. data/lib/sequel/extensions/pg_extended_date_support.rb +250 -0
  198. data/lib/sequel/extensions/pg_hstore.rb +50 -59
  199. data/lib/sequel/extensions/pg_hstore_ops.rb +9 -3
  200. data/lib/sequel/extensions/pg_inet.rb +34 -15
  201. data/lib/sequel/extensions/pg_inet_ops.rb +5 -1
  202. data/lib/sequel/extensions/pg_interval.rb +26 -26
  203. data/lib/sequel/extensions/pg_json.rb +422 -141
  204. data/lib/sequel/extensions/pg_json_ops.rb +248 -9
  205. data/lib/sequel/extensions/pg_loose_count.rb +5 -1
  206. data/lib/sequel/extensions/pg_range.rb +162 -146
  207. data/lib/sequel/extensions/pg_range_ops.rb +10 -5
  208. data/lib/sequel/extensions/pg_row.rb +53 -87
  209. data/lib/sequel/extensions/pg_row_ops.rb +36 -13
  210. data/lib/sequel/extensions/pg_static_cache_updater.rb +6 -2
  211. data/lib/sequel/extensions/pg_timestamptz.rb +28 -0
  212. data/lib/sequel/extensions/pretty_table.rb +4 -0
  213. data/lib/sequel/extensions/query.rb +12 -7
  214. data/lib/sequel/extensions/round_timestamps.rb +6 -9
  215. data/lib/sequel/extensions/run_transaction_hooks.rb +72 -0
  216. data/lib/sequel/extensions/s.rb +59 -0
  217. data/lib/sequel/extensions/schema_caching.rb +14 -1
  218. data/lib/sequel/extensions/schema_dumper.rb +83 -55
  219. data/lib/sequel/extensions/select_remove.rb +8 -4
  220. data/lib/sequel/extensions/sequel_4_dataset_methods.rb +85 -0
  221. data/lib/sequel/extensions/server_block.rb +50 -17
  222. data/lib/sequel/extensions/server_logging.rb +61 -0
  223. data/lib/sequel/extensions/split_array_nil.rb +8 -4
  224. data/lib/sequel/extensions/sql_comments.rb +96 -0
  225. data/lib/sequel/extensions/sql_expr.rb +4 -1
  226. data/lib/sequel/extensions/string_agg.rb +181 -0
  227. data/lib/sequel/extensions/string_date_time.rb +2 -0
  228. data/lib/sequel/extensions/symbol_aref.rb +53 -0
  229. data/lib/sequel/extensions/symbol_aref_refinement.rb +43 -0
  230. data/lib/sequel/extensions/symbol_as.rb +23 -0
  231. data/lib/sequel/extensions/symbol_as_refinement.rb +37 -0
  232. data/lib/sequel/extensions/synchronize_sql.rb +45 -0
  233. data/lib/sequel/extensions/thread_local_timezones.rb +4 -0
  234. data/lib/sequel/extensions/to_dot.rb +15 -5
  235. data/lib/sequel/extensions/virtual_row_method_block.rb +44 -0
  236. data/lib/sequel/model.rb +36 -126
  237. data/lib/sequel/model/associations.rb +850 -257
  238. data/lib/sequel/model/base.rb +652 -764
  239. data/lib/sequel/model/dataset_module.rb +13 -10
  240. data/lib/sequel/model/default_inflections.rb +3 -1
  241. data/lib/sequel/model/errors.rb +3 -3
  242. data/lib/sequel/model/exceptions.rb +12 -12
  243. data/lib/sequel/model/inflections.rb +8 -19
  244. data/lib/sequel/model/plugins.rb +111 -0
  245. data/lib/sequel/plugins/accessed_columns.rb +2 -0
  246. data/lib/sequel/plugins/active_model.rb +32 -7
  247. data/lib/sequel/plugins/after_initialize.rb +3 -1
  248. data/lib/sequel/plugins/association_dependencies.rb +27 -18
  249. data/lib/sequel/plugins/association_lazy_eager_option.rb +66 -0
  250. data/lib/sequel/plugins/association_multi_add_remove.rb +85 -0
  251. data/lib/sequel/plugins/association_pks.rb +181 -83
  252. data/lib/sequel/plugins/association_proxies.rb +33 -9
  253. data/lib/sequel/plugins/auto_validations.rb +58 -23
  254. data/lib/sequel/plugins/before_after_save.rb +8 -0
  255. data/lib/sequel/plugins/blacklist_security.rb +23 -12
  256. data/lib/sequel/plugins/boolean_readers.rb +9 -6
  257. data/lib/sequel/plugins/boolean_subsets.rb +64 -0
  258. data/lib/sequel/plugins/caching.rb +27 -16
  259. data/lib/sequel/plugins/class_table_inheritance.rb +192 -94
  260. data/lib/sequel/plugins/column_conflicts.rb +18 -3
  261. data/lib/sequel/plugins/column_select.rb +9 -5
  262. data/lib/sequel/plugins/columns_updated.rb +42 -0
  263. data/lib/sequel/plugins/composition.rb +36 -24
  264. data/lib/sequel/plugins/constraint_validations.rb +37 -16
  265. data/lib/sequel/plugins/csv_serializer.rb +58 -35
  266. data/lib/sequel/plugins/dataset_associations.rb +60 -18
  267. data/lib/sequel/plugins/def_dataset_method.rb +90 -0
  268. data/lib/sequel/plugins/defaults_setter.rb +74 -13
  269. data/lib/sequel/plugins/delay_add_association.rb +4 -1
  270. data/lib/sequel/plugins/dirty.rb +65 -24
  271. data/lib/sequel/plugins/eager_each.rb +27 -3
  272. data/lib/sequel/plugins/eager_graph_eager.rb +139 -0
  273. data/lib/sequel/plugins/empty_failure_backtraces.rb +38 -0
  274. data/lib/sequel/plugins/error_splitter.rb +19 -12
  275. data/lib/sequel/plugins/finder.rb +246 -0
  276. data/lib/sequel/plugins/forbid_lazy_load.rb +216 -0
  277. data/lib/sequel/plugins/force_encoding.rb +9 -12
  278. data/lib/sequel/plugins/hook_class_methods.rb +39 -54
  279. data/lib/sequel/plugins/input_transformer.rb +20 -10
  280. data/lib/sequel/plugins/insert_conflict.rb +72 -0
  281. data/lib/sequel/plugins/insert_returning_select.rb +4 -2
  282. data/lib/sequel/plugins/instance_filters.rb +12 -8
  283. data/lib/sequel/plugins/instance_hooks.rb +36 -17
  284. data/lib/sequel/plugins/instance_specific_default.rb +113 -0
  285. data/lib/sequel/plugins/inverted_subsets.rb +24 -13
  286. data/lib/sequel/plugins/json_serializer.rb +123 -47
  287. data/lib/sequel/plugins/lazy_attributes.rb +20 -14
  288. data/lib/sequel/plugins/list.rb +40 -26
  289. data/lib/sequel/plugins/many_through_many.rb +28 -12
  290. data/lib/sequel/plugins/modification_detection.rb +17 -5
  291. data/lib/sequel/plugins/mssql_optimistic_locking.rb +8 -5
  292. data/lib/sequel/plugins/nested_attributes.rb +55 -28
  293. data/lib/sequel/plugins/optimistic_locking.rb +5 -3
  294. data/lib/sequel/plugins/pg_array_associations.rb +52 -18
  295. data/lib/sequel/plugins/pg_auto_constraint_validations.rb +348 -0
  296. data/lib/sequel/plugins/pg_row.rb +7 -51
  297. data/lib/sequel/plugins/prepared_statements.rb +53 -72
  298. data/lib/sequel/plugins/prepared_statements_safe.rb +13 -5
  299. data/lib/sequel/plugins/rcte_tree.rb +43 -63
  300. data/lib/sequel/plugins/serialization.rb +37 -44
  301. data/lib/sequel/plugins/serialization_modification_detection.rb +3 -1
  302. data/lib/sequel/plugins/sharding.rb +17 -10
  303. data/lib/sequel/plugins/single_table_inheritance.rb +62 -28
  304. data/lib/sequel/plugins/singular_table_names.rb +2 -0
  305. data/lib/sequel/plugins/skip_create_refresh.rb +5 -3
  306. data/lib/sequel/plugins/skip_saving_columns.rb +108 -0
  307. data/lib/sequel/plugins/split_values.rb +13 -6
  308. data/lib/sequel/plugins/static_cache.rb +79 -53
  309. data/lib/sequel/plugins/static_cache_cache.rb +53 -0
  310. data/lib/sequel/plugins/string_stripper.rb +5 -3
  311. data/lib/sequel/plugins/subclasses.rb +20 -2
  312. data/lib/sequel/plugins/subset_conditions.rb +48 -0
  313. data/lib/sequel/plugins/table_select.rb +4 -2
  314. data/lib/sequel/plugins/tactical_eager_loading.rb +120 -6
  315. data/lib/sequel/plugins/throw_failures.rb +110 -0
  316. data/lib/sequel/plugins/timestamps.rb +22 -8
  317. data/lib/sequel/plugins/touch.rb +21 -8
  318. data/lib/sequel/plugins/tree.rb +57 -30
  319. data/lib/sequel/plugins/typecast_on_load.rb +14 -4
  320. data/lib/sequel/plugins/unlimited_update.rb +3 -7
  321. data/lib/sequel/plugins/update_or_create.rb +6 -4
  322. data/lib/sequel/plugins/update_primary_key.rb +3 -1
  323. data/lib/sequel/plugins/update_refresh.rb +28 -15
  324. data/lib/sequel/plugins/uuid.rb +70 -0
  325. data/lib/sequel/plugins/validate_associated.rb +20 -0
  326. data/lib/sequel/plugins/validation_class_methods.rb +40 -19
  327. data/lib/sequel/plugins/validation_contexts.rb +49 -0
  328. data/lib/sequel/plugins/validation_helpers.rb +49 -31
  329. data/lib/sequel/plugins/whitelist_security.rb +122 -0
  330. data/lib/sequel/plugins/xml_serializer.rb +31 -30
  331. data/lib/sequel/sql.rb +479 -329
  332. data/lib/sequel/timezones.rb +62 -32
  333. data/lib/sequel/version.rb +10 -3
  334. metadata +177 -477
  335. data/Rakefile +0 -165
  336. data/doc/active_record.rdoc +0 -912
  337. data/doc/release_notes/1.0.txt +0 -38
  338. data/doc/release_notes/1.1.txt +0 -143
  339. data/doc/release_notes/1.3.txt +0 -101
  340. data/doc/release_notes/1.4.0.txt +0 -53
  341. data/doc/release_notes/1.5.0.txt +0 -155
  342. data/doc/release_notes/2.0.0.txt +0 -298
  343. data/doc/release_notes/2.1.0.txt +0 -271
  344. data/doc/release_notes/2.10.0.txt +0 -328
  345. data/doc/release_notes/2.11.0.txt +0 -215
  346. data/doc/release_notes/2.12.0.txt +0 -534
  347. data/doc/release_notes/2.2.0.txt +0 -253
  348. data/doc/release_notes/2.3.0.txt +0 -88
  349. data/doc/release_notes/2.4.0.txt +0 -106
  350. data/doc/release_notes/2.5.0.txt +0 -137
  351. data/doc/release_notes/2.6.0.txt +0 -157
  352. data/doc/release_notes/2.7.0.txt +0 -166
  353. data/doc/release_notes/2.8.0.txt +0 -171
  354. data/doc/release_notes/2.9.0.txt +0 -97
  355. data/doc/release_notes/3.0.0.txt +0 -221
  356. data/doc/release_notes/3.1.0.txt +0 -406
  357. data/doc/release_notes/3.10.0.txt +0 -286
  358. data/doc/release_notes/3.11.0.txt +0 -254
  359. data/doc/release_notes/3.12.0.txt +0 -304
  360. data/doc/release_notes/3.13.0.txt +0 -210
  361. data/doc/release_notes/3.14.0.txt +0 -118
  362. data/doc/release_notes/3.15.0.txt +0 -78
  363. data/doc/release_notes/3.16.0.txt +0 -45
  364. data/doc/release_notes/3.17.0.txt +0 -58
  365. data/doc/release_notes/3.18.0.txt +0 -120
  366. data/doc/release_notes/3.19.0.txt +0 -67
  367. data/doc/release_notes/3.2.0.txt +0 -268
  368. data/doc/release_notes/3.20.0.txt +0 -41
  369. data/doc/release_notes/3.21.0.txt +0 -87
  370. data/doc/release_notes/3.22.0.txt +0 -39
  371. data/doc/release_notes/3.23.0.txt +0 -172
  372. data/doc/release_notes/3.24.0.txt +0 -420
  373. data/doc/release_notes/3.25.0.txt +0 -88
  374. data/doc/release_notes/3.26.0.txt +0 -88
  375. data/doc/release_notes/3.27.0.txt +0 -82
  376. data/doc/release_notes/3.28.0.txt +0 -304
  377. data/doc/release_notes/3.29.0.txt +0 -459
  378. data/doc/release_notes/3.3.0.txt +0 -192
  379. data/doc/release_notes/3.30.0.txt +0 -135
  380. data/doc/release_notes/3.31.0.txt +0 -146
  381. data/doc/release_notes/3.32.0.txt +0 -202
  382. data/doc/release_notes/3.33.0.txt +0 -157
  383. data/doc/release_notes/3.34.0.txt +0 -671
  384. data/doc/release_notes/3.35.0.txt +0 -144
  385. data/doc/release_notes/3.36.0.txt +0 -245
  386. data/doc/release_notes/3.37.0.txt +0 -338
  387. data/doc/release_notes/3.38.0.txt +0 -234
  388. data/doc/release_notes/3.39.0.txt +0 -237
  389. data/doc/release_notes/3.4.0.txt +0 -325
  390. data/doc/release_notes/3.40.0.txt +0 -73
  391. data/doc/release_notes/3.41.0.txt +0 -155
  392. data/doc/release_notes/3.42.0.txt +0 -74
  393. data/doc/release_notes/3.43.0.txt +0 -105
  394. data/doc/release_notes/3.44.0.txt +0 -152
  395. data/doc/release_notes/3.45.0.txt +0 -179
  396. data/doc/release_notes/3.46.0.txt +0 -122
  397. data/doc/release_notes/3.47.0.txt +0 -270
  398. data/doc/release_notes/3.48.0.txt +0 -477
  399. data/doc/release_notes/3.5.0.txt +0 -510
  400. data/doc/release_notes/3.6.0.txt +0 -366
  401. data/doc/release_notes/3.7.0.txt +0 -179
  402. data/doc/release_notes/3.8.0.txt +0 -151
  403. data/doc/release_notes/3.9.0.txt +0 -233
  404. data/doc/release_notes/4.0.0.txt +0 -262
  405. data/doc/release_notes/4.1.0.txt +0 -85
  406. data/doc/release_notes/4.10.0.txt +0 -226
  407. data/doc/release_notes/4.11.0.txt +0 -147
  408. data/doc/release_notes/4.12.0.txt +0 -105
  409. data/doc/release_notes/4.13.0.txt +0 -169
  410. data/doc/release_notes/4.14.0.txt +0 -68
  411. data/doc/release_notes/4.15.0.txt +0 -56
  412. data/doc/release_notes/4.16.0.txt +0 -36
  413. data/doc/release_notes/4.17.0.txt +0 -38
  414. data/doc/release_notes/4.18.0.txt +0 -36
  415. data/doc/release_notes/4.19.0.txt +0 -45
  416. data/doc/release_notes/4.2.0.txt +0 -129
  417. data/doc/release_notes/4.20.0.txt +0 -79
  418. data/doc/release_notes/4.21.0.txt +0 -94
  419. data/doc/release_notes/4.22.0.txt +0 -72
  420. data/doc/release_notes/4.23.0.txt +0 -65
  421. data/doc/release_notes/4.24.0.txt +0 -99
  422. data/doc/release_notes/4.25.0.txt +0 -181
  423. data/doc/release_notes/4.26.0.txt +0 -44
  424. data/doc/release_notes/4.3.0.txt +0 -40
  425. data/doc/release_notes/4.4.0.txt +0 -92
  426. data/doc/release_notes/4.5.0.txt +0 -34
  427. data/doc/release_notes/4.6.0.txt +0 -30
  428. data/doc/release_notes/4.7.0.txt +0 -103
  429. data/doc/release_notes/4.8.0.txt +0 -175
  430. data/doc/release_notes/4.9.0.txt +0 -190
  431. data/lib/sequel/adapters/cubrid.rb +0 -142
  432. data/lib/sequel/adapters/do.rb +0 -156
  433. data/lib/sequel/adapters/do/mysql.rb +0 -64
  434. data/lib/sequel/adapters/do/postgres.rb +0 -42
  435. data/lib/sequel/adapters/do/sqlite3.rb +0 -40
  436. data/lib/sequel/adapters/jdbc/as400.rb +0 -82
  437. data/lib/sequel/adapters/jdbc/cubrid.rb +0 -62
  438. data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -34
  439. data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -31
  440. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -31
  441. data/lib/sequel/adapters/odbc/progress.rb +0 -8
  442. data/lib/sequel/adapters/shared/cubrid.rb +0 -243
  443. data/lib/sequel/adapters/shared/firebird.rb +0 -245
  444. data/lib/sequel/adapters/shared/informix.rb +0 -52
  445. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +0 -150
  446. data/lib/sequel/adapters/shared/progress.rb +0 -38
  447. data/lib/sequel/adapters/swift.rb +0 -158
  448. data/lib/sequel/adapters/swift/mysql.rb +0 -47
  449. data/lib/sequel/adapters/swift/postgres.rb +0 -45
  450. data/lib/sequel/adapters/swift/sqlite.rb +0 -47
  451. data/lib/sequel/adapters/utils/pg_types.rb +0 -68
  452. data/lib/sequel/dataset/mutation.rb +0 -109
  453. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +0 -3
  454. data/lib/sequel/extensions/filter_having.rb +0 -59
  455. data/lib/sequel/extensions/hash_aliases.rb +0 -45
  456. data/lib/sequel/extensions/meta_def.rb +0 -31
  457. data/lib/sequel/extensions/query_literals.rb +0 -80
  458. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +0 -22
  459. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +0 -118
  460. data/lib/sequel/extensions/set_overrides.rb +0 -72
  461. data/lib/sequel/no_core_ext.rb +0 -1
  462. data/lib/sequel/plugins/association_autoreloading.rb +0 -7
  463. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +0 -7
  464. data/lib/sequel/plugins/pg_typecast_on_load.rb +0 -78
  465. data/lib/sequel/plugins/prepared_statements_associations.rb +0 -117
  466. data/lib/sequel/plugins/prepared_statements_with_pk.rb +0 -59
  467. data/lib/sequel/plugins/schema.rb +0 -80
  468. data/lib/sequel/plugins/scissors.rb +0 -33
  469. data/spec/adapters/db2_spec.rb +0 -160
  470. data/spec/adapters/firebird_spec.rb +0 -411
  471. data/spec/adapters/informix_spec.rb +0 -100
  472. data/spec/adapters/mssql_spec.rb +0 -706
  473. data/spec/adapters/mysql_spec.rb +0 -1287
  474. data/spec/adapters/oracle_spec.rb +0 -313
  475. data/spec/adapters/postgres_spec.rb +0 -3725
  476. data/spec/adapters/spec_helper.rb +0 -43
  477. data/spec/adapters/sqlanywhere_spec.rb +0 -170
  478. data/spec/adapters/sqlite_spec.rb +0 -653
  479. data/spec/bin_spec.rb +0 -254
  480. data/spec/core/connection_pool_spec.rb +0 -1016
  481. data/spec/core/database_spec.rb +0 -2531
  482. data/spec/core/dataset_spec.rb +0 -5098
  483. data/spec/core/deprecated_spec.rb +0 -70
  484. data/spec/core/expression_filters_spec.rb +0 -1243
  485. data/spec/core/mock_adapter_spec.rb +0 -462
  486. data/spec/core/object_graph_spec.rb +0 -303
  487. data/spec/core/placeholder_literalizer_spec.rb +0 -163
  488. data/spec/core/schema_generator_spec.rb +0 -179
  489. data/spec/core/schema_spec.rb +0 -1659
  490. data/spec/core/spec_helper.rb +0 -34
  491. data/spec/core/version_spec.rb +0 -7
  492. data/spec/core_extensions_spec.rb +0 -699
  493. data/spec/extensions/accessed_columns_spec.rb +0 -51
  494. data/spec/extensions/active_model_spec.rb +0 -123
  495. data/spec/extensions/after_initialize_spec.rb +0 -24
  496. data/spec/extensions/arbitrary_servers_spec.rb +0 -109
  497. data/spec/extensions/association_dependencies_spec.rb +0 -117
  498. data/spec/extensions/association_pks_spec.rb +0 -365
  499. data/spec/extensions/association_proxies_spec.rb +0 -86
  500. data/spec/extensions/auto_validations_spec.rb +0 -192
  501. data/spec/extensions/blacklist_security_spec.rb +0 -88
  502. data/spec/extensions/blank_spec.rb +0 -69
  503. data/spec/extensions/boolean_readers_spec.rb +0 -93
  504. data/spec/extensions/caching_spec.rb +0 -270
  505. data/spec/extensions/class_table_inheritance_spec.rb +0 -420
  506. data/spec/extensions/column_conflicts_spec.rb +0 -60
  507. data/spec/extensions/column_select_spec.rb +0 -108
  508. data/spec/extensions/columns_introspection_spec.rb +0 -91
  509. data/spec/extensions/composition_spec.rb +0 -242
  510. data/spec/extensions/connection_validator_spec.rb +0 -120
  511. data/spec/extensions/constraint_validations_plugin_spec.rb +0 -274
  512. data/spec/extensions/constraint_validations_spec.rb +0 -325
  513. data/spec/extensions/core_refinements_spec.rb +0 -519
  514. data/spec/extensions/csv_serializer_spec.rb +0 -173
  515. data/spec/extensions/current_datetime_timestamp_spec.rb +0 -27
  516. data/spec/extensions/dataset_associations_spec.rb +0 -311
  517. data/spec/extensions/dataset_source_alias_spec.rb +0 -51
  518. data/spec/extensions/date_arithmetic_spec.rb +0 -150
  519. data/spec/extensions/defaults_setter_spec.rb +0 -101
  520. data/spec/extensions/delay_add_association_spec.rb +0 -52
  521. data/spec/extensions/dirty_spec.rb +0 -180
  522. data/spec/extensions/eager_each_spec.rb +0 -42
  523. data/spec/extensions/empty_array_consider_nulls_spec.rb +0 -24
  524. data/spec/extensions/error_splitter_spec.rb +0 -18
  525. data/spec/extensions/error_sql_spec.rb +0 -20
  526. data/spec/extensions/eval_inspect_spec.rb +0 -73
  527. data/spec/extensions/filter_having_spec.rb +0 -40
  528. data/spec/extensions/force_encoding_spec.rb +0 -114
  529. data/spec/extensions/from_block_spec.rb +0 -21
  530. data/spec/extensions/graph_each_spec.rb +0 -109
  531. data/spec/extensions/hash_aliases_spec.rb +0 -24
  532. data/spec/extensions/hook_class_methods_spec.rb +0 -429
  533. data/spec/extensions/inflector_spec.rb +0 -183
  534. data/spec/extensions/input_transformer_spec.rb +0 -54
  535. data/spec/extensions/insert_returning_select_spec.rb +0 -46
  536. data/spec/extensions/instance_filters_spec.rb +0 -79
  537. data/spec/extensions/instance_hooks_spec.rb +0 -276
  538. data/spec/extensions/inverted_subsets_spec.rb +0 -33
  539. data/spec/extensions/json_serializer_spec.rb +0 -291
  540. data/spec/extensions/lazy_attributes_spec.rb +0 -170
  541. data/spec/extensions/list_spec.rb +0 -267
  542. data/spec/extensions/looser_typecasting_spec.rb +0 -43
  543. data/spec/extensions/many_through_many_spec.rb +0 -2172
  544. data/spec/extensions/meta_def_spec.rb +0 -21
  545. data/spec/extensions/migration_spec.rb +0 -712
  546. data/spec/extensions/modification_detection_spec.rb +0 -80
  547. data/spec/extensions/mssql_optimistic_locking_spec.rb +0 -91
  548. data/spec/extensions/named_timezones_spec.rb +0 -108
  549. data/spec/extensions/nested_attributes_spec.rb +0 -697
  550. data/spec/extensions/null_dataset_spec.rb +0 -85
  551. data/spec/extensions/optimistic_locking_spec.rb +0 -128
  552. data/spec/extensions/pagination_spec.rb +0 -118
  553. data/spec/extensions/pg_array_associations_spec.rb +0 -736
  554. data/spec/extensions/pg_array_ops_spec.rb +0 -143
  555. data/spec/extensions/pg_array_spec.rb +0 -395
  556. data/spec/extensions/pg_enum_spec.rb +0 -92
  557. data/spec/extensions/pg_hstore_ops_spec.rb +0 -236
  558. data/spec/extensions/pg_hstore_spec.rb +0 -206
  559. data/spec/extensions/pg_inet_ops_spec.rb +0 -101
  560. data/spec/extensions/pg_inet_spec.rb +0 -52
  561. data/spec/extensions/pg_interval_spec.rb +0 -76
  562. data/spec/extensions/pg_json_ops_spec.rb +0 -229
  563. data/spec/extensions/pg_json_spec.rb +0 -218
  564. data/spec/extensions/pg_loose_count_spec.rb +0 -17
  565. data/spec/extensions/pg_range_ops_spec.rb +0 -58
  566. data/spec/extensions/pg_range_spec.rb +0 -404
  567. data/spec/extensions/pg_row_ops_spec.rb +0 -60
  568. data/spec/extensions/pg_row_plugin_spec.rb +0 -62
  569. data/spec/extensions/pg_row_spec.rb +0 -360
  570. data/spec/extensions/pg_static_cache_updater_spec.rb +0 -92
  571. data/spec/extensions/pg_typecast_on_load_spec.rb +0 -63
  572. data/spec/extensions/prepared_statements_associations_spec.rb +0 -159
  573. data/spec/extensions/prepared_statements_safe_spec.rb +0 -61
  574. data/spec/extensions/prepared_statements_spec.rb +0 -103
  575. data/spec/extensions/prepared_statements_with_pk_spec.rb +0 -31
  576. data/spec/extensions/pretty_table_spec.rb +0 -92
  577. data/spec/extensions/query_literals_spec.rb +0 -183
  578. data/spec/extensions/query_spec.rb +0 -102
  579. data/spec/extensions/rcte_tree_spec.rb +0 -392
  580. data/spec/extensions/round_timestamps_spec.rb +0 -43
  581. data/spec/extensions/schema_caching_spec.rb +0 -41
  582. data/spec/extensions/schema_dumper_spec.rb +0 -789
  583. data/spec/extensions/schema_spec.rb +0 -117
  584. data/spec/extensions/scissors_spec.rb +0 -26
  585. data/spec/extensions/select_remove_spec.rb +0 -38
  586. data/spec/extensions/sequel_3_dataset_methods_spec.rb +0 -101
  587. data/spec/extensions/serialization_modification_detection_spec.rb +0 -98
  588. data/spec/extensions/serialization_spec.rb +0 -362
  589. data/spec/extensions/server_block_spec.rb +0 -90
  590. data/spec/extensions/set_overrides_spec.rb +0 -61
  591. data/spec/extensions/sharding_spec.rb +0 -198
  592. data/spec/extensions/shared_caching_spec.rb +0 -175
  593. data/spec/extensions/single_table_inheritance_spec.rb +0 -297
  594. data/spec/extensions/singular_table_names_spec.rb +0 -22
  595. data/spec/extensions/skip_create_refresh_spec.rb +0 -17
  596. data/spec/extensions/spec_helper.rb +0 -71
  597. data/spec/extensions/split_array_nil_spec.rb +0 -24
  598. data/spec/extensions/split_values_spec.rb +0 -22
  599. data/spec/extensions/sql_expr_spec.rb +0 -60
  600. data/spec/extensions/static_cache_spec.rb +0 -361
  601. data/spec/extensions/string_date_time_spec.rb +0 -95
  602. data/spec/extensions/string_stripper_spec.rb +0 -68
  603. data/spec/extensions/subclasses_spec.rb +0 -66
  604. data/spec/extensions/table_select_spec.rb +0 -71
  605. data/spec/extensions/tactical_eager_loading_spec.rb +0 -82
  606. data/spec/extensions/thread_local_timezones_spec.rb +0 -67
  607. data/spec/extensions/timestamps_spec.rb +0 -175
  608. data/spec/extensions/to_dot_spec.rb +0 -154
  609. data/spec/extensions/touch_spec.rb +0 -203
  610. data/spec/extensions/tree_spec.rb +0 -274
  611. data/spec/extensions/typecast_on_load_spec.rb +0 -80
  612. data/spec/extensions/unlimited_update_spec.rb +0 -20
  613. data/spec/extensions/update_or_create_spec.rb +0 -87
  614. data/spec/extensions/update_primary_key_spec.rb +0 -100
  615. data/spec/extensions/update_refresh_spec.rb +0 -53
  616. data/spec/extensions/validate_associated_spec.rb +0 -52
  617. data/spec/extensions/validation_class_methods_spec.rb +0 -1027
  618. data/spec/extensions/validation_helpers_spec.rb +0 -541
  619. data/spec/extensions/xml_serializer_spec.rb +0 -207
  620. data/spec/files/bad_down_migration/001_create_alt_basic.rb +0 -4
  621. data/spec/files/bad_down_migration/002_create_alt_advanced.rb +0 -4
  622. data/spec/files/bad_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  623. data/spec/files/bad_timestamped_migrations/1273253851_create_nodes.rb +0 -9
  624. data/spec/files/bad_timestamped_migrations/1273253853_3_create_users.rb +0 -3
  625. data/spec/files/bad_up_migration/001_create_alt_basic.rb +0 -4
  626. data/spec/files/bad_up_migration/002_create_alt_advanced.rb +0 -3
  627. data/spec/files/convert_to_timestamp_migrations/001_create_sessions.rb +0 -9
  628. data/spec/files/convert_to_timestamp_migrations/002_create_nodes.rb +0 -9
  629. data/spec/files/convert_to_timestamp_migrations/003_3_create_users.rb +0 -4
  630. data/spec/files/convert_to_timestamp_migrations/1273253850_create_artists.rb +0 -9
  631. data/spec/files/convert_to_timestamp_migrations/1273253852_create_albums.rb +0 -9
  632. data/spec/files/duplicate_integer_migrations/001_create_alt_advanced.rb +0 -4
  633. data/spec/files/duplicate_integer_migrations/001_create_alt_basic.rb +0 -4
  634. data/spec/files/duplicate_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  635. data/spec/files/duplicate_timestamped_migrations/1273253853_create_nodes.rb +0 -9
  636. data/spec/files/duplicate_timestamped_migrations/1273253853_create_users.rb +0 -4
  637. data/spec/files/integer_migrations/001_create_sessions.rb +0 -9
  638. data/spec/files/integer_migrations/002_create_nodes.rb +0 -9
  639. data/spec/files/integer_migrations/003_3_create_users.rb +0 -4
  640. data/spec/files/interleaved_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  641. data/spec/files/interleaved_timestamped_migrations/1273253850_create_artists.rb +0 -9
  642. data/spec/files/interleaved_timestamped_migrations/1273253851_create_nodes.rb +0 -9
  643. data/spec/files/interleaved_timestamped_migrations/1273253852_create_albums.rb +0 -9
  644. data/spec/files/interleaved_timestamped_migrations/1273253853_3_create_users.rb +0 -4
  645. data/spec/files/missing_integer_migrations/001_create_alt_basic.rb +0 -4
  646. data/spec/files/missing_integer_migrations/003_create_alt_advanced.rb +0 -4
  647. data/spec/files/missing_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  648. data/spec/files/missing_timestamped_migrations/1273253853_3_create_users.rb +0 -4
  649. data/spec/files/reversible_migrations/001_reversible.rb +0 -5
  650. data/spec/files/reversible_migrations/002_reversible.rb +0 -5
  651. data/spec/files/reversible_migrations/003_reversible.rb +0 -5
  652. data/spec/files/reversible_migrations/004_reversible.rb +0 -5
  653. data/spec/files/reversible_migrations/005_reversible.rb +0 -10
  654. data/spec/files/timestamped_migrations/1273253849_create_sessions.rb +0 -9
  655. data/spec/files/timestamped_migrations/1273253851_create_nodes.rb +0 -9
  656. data/spec/files/timestamped_migrations/1273253853_3_create_users.rb +0 -4
  657. data/spec/files/transaction_specified_migrations/001_create_alt_basic.rb +0 -4
  658. data/spec/files/transaction_specified_migrations/002_create_basic.rb +0 -4
  659. data/spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb +0 -3
  660. data/spec/files/transaction_unspecified_migrations/002_create_basic.rb +0 -3
  661. data/spec/files/uppercase_timestamped_migrations/1273253849_CREATE_SESSIONS.RB +0 -9
  662. data/spec/files/uppercase_timestamped_migrations/1273253851_CREATE_NODES.RB +0 -9
  663. data/spec/files/uppercase_timestamped_migrations/1273253853_3_CREATE_USERS.RB +0 -4
  664. data/spec/guards_helper.rb +0 -55
  665. data/spec/integration/associations_test.rb +0 -2454
  666. data/spec/integration/database_test.rb +0 -113
  667. data/spec/integration/dataset_test.rb +0 -1808
  668. data/spec/integration/eager_loader_test.rb +0 -687
  669. data/spec/integration/migrator_test.rb +0 -240
  670. data/spec/integration/model_test.rb +0 -226
  671. data/spec/integration/plugin_test.rb +0 -2240
  672. data/spec/integration/prepared_statement_test.rb +0 -467
  673. data/spec/integration/schema_test.rb +0 -817
  674. data/spec/integration/spec_helper.rb +0 -48
  675. data/spec/integration/timezone_test.rb +0 -86
  676. data/spec/integration/transaction_test.rb +0 -374
  677. data/spec/integration/type_test.rb +0 -133
  678. data/spec/model/association_reflection_spec.rb +0 -525
  679. data/spec/model/associations_spec.rb +0 -4426
  680. data/spec/model/base_spec.rb +0 -759
  681. data/spec/model/class_dataset_methods_spec.rb +0 -146
  682. data/spec/model/dataset_methods_spec.rb +0 -149
  683. data/spec/model/eager_loading_spec.rb +0 -2137
  684. data/spec/model/hooks_spec.rb +0 -604
  685. data/spec/model/inflector_spec.rb +0 -26
  686. data/spec/model/model_spec.rb +0 -982
  687. data/spec/model/plugins_spec.rb +0 -299
  688. data/spec/model/record_spec.rb +0 -2147
  689. data/spec/model/spec_helper.rb +0 -46
  690. data/spec/model/validations_spec.rb +0 -193
  691. data/spec/sequel_coverage.rb +0 -15
  692. data/spec/spec_config.rb +0 -10
data/Rakefile DELETED
@@ -1,165 +0,0 @@
1
- require "rake"
2
- require "rake/clean"
3
-
4
- NAME = 'sequel'
5
- VERS = lambda do
6
- require File.expand_path("../lib/sequel/version", __FILE__)
7
- Sequel.version
8
- end
9
- CLEAN.include ["**/.*.sw?", "sequel-*.gem", ".config", "rdoc", "coverage", "www/public/*.html", "www/public/rdoc*", '**/*.rbc']
10
-
11
- # Gem Packaging and Release
12
-
13
- desc "Build sequel gem"
14
- task :package=>[:clean] do |p|
15
- sh %{#{FileUtils::RUBY} -S gem build sequel.gemspec}
16
- end
17
-
18
- desc "Publish sequel gem to rubygems.org"
19
- task :release=>[:package] do
20
- sh %{#{FileUtils::RUBY} -S gem push ./#{NAME}-#{VERS.call}.gem}
21
- end
22
-
23
- ### Website
24
-
25
- desc "Make local version of website"
26
- task :website do
27
- sh %{#{FileUtils::RUBY} www/make_www.rb}
28
- end
29
-
30
- ### RDoc
31
-
32
- RDOC_DEFAULT_OPTS = ["--line-numbers", "--inline-source", '--title', 'Sequel: The Database Toolkit for Ruby']
33
-
34
- begin
35
- # Sequel uses hanna-nouveau for the website RDoc.
36
- gem 'hanna-nouveau'
37
- RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
38
- rescue Gem::LoadError
39
- end
40
-
41
- rdoc_task_class = begin
42
- require "rdoc/task"
43
- RDoc::Task
44
- rescue LoadError
45
- begin
46
- require "rake/rdoctask"
47
- Rake::RDocTask
48
- rescue LoadError, StandardError
49
- end
50
- end
51
-
52
- if rdoc_task_class
53
- RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
54
-
55
- rdoc_task_class.new do |rdoc|
56
- rdoc.rdoc_dir = "rdoc"
57
- rdoc.options += RDOC_OPTS
58
- rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb doc/*.rdoc doc/release_notes/*.txt"
59
- end
60
-
61
- desc "Make rdoc for website"
62
- task :website_rdoc=>[:website_rdoc_main, :website_rdoc_adapters, :website_rdoc_plugins]
63
-
64
- rdoc_task_class.new(:website_rdoc_main) do |rdoc|
65
- rdoc.rdoc_dir = "www/public/rdoc"
66
- rdoc.options += RDOC_OPTS + %w'--no-ignore-invalid'
67
- rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/*.rb lib/sequel/*.rb lib/sequel/{connection_pool,dataset,database,model}/*.rb doc/*.rdoc doc/release_notes/*.txt lib/sequel/extensions/migration.rb"
68
- end
69
-
70
- rdoc_task_class.new(:website_rdoc_adapters) do |rdoc|
71
- rdoc.rdoc_dir = "www/public/rdoc-adapters"
72
- rdoc.options += RDOC_DEFAULT_OPTS + %w'--main Sequel --no-ignore-invalid'
73
- rdoc.rdoc_files.add %w"lib/sequel/adapters/**/*.rb"
74
- end
75
-
76
- rdoc_task_class.new(:website_rdoc_plugins) do |rdoc|
77
- rdoc.rdoc_dir = "www/public/rdoc-plugins"
78
- rdoc.options += RDOC_DEFAULT_OPTS + %w'--main Sequel --no-ignore-invalid'
79
- rdoc.rdoc_files.add %w"lib/sequel/{extensions,plugins}/**/*.rb doc/core_*"
80
- end
81
- end
82
-
83
- ### Specs
84
-
85
- run_spec = proc do |patterns|
86
- lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
87
- rubylib = ENV['RUBYLIB']
88
- ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
89
- if RUBY_PLATFORM =~ /mingw32/ || RUBY_DESCRIPTION =~ /windows/i
90
- patterns = patterns.split.map{|pat| Dir[pat].to_a}.flatten.join(' ')
91
- end
92
- sh "#{FileUtils::RUBY} -e \"ARGV.each{|f| require f}\" #{patterns}"
93
- ENV['RUBYLIB'] = rubylib
94
- end
95
-
96
- spec_task = proc do |description, name, files|
97
- desc description
98
- task name do
99
- run_spec.call(files)
100
- end
101
-
102
- desc "#{description} with warnings, some warnings filtered"
103
- task :"#{name}_w" do
104
- ENV['RUBYOPT'] ? (ENV['RUBYOPT'] += " -w") : (ENV['RUBYOPT'] = '-w')
105
- rake = ENV['RAKE'] || "#{FileUtils::RUBY} -S rake"
106
- sh "#{rake} #{name} 2>&1 | egrep -v \"(: warning: instance variable @.* not initialized|: warning: method redefined; discarding old|: warning: previous definition of)\""
107
- end
108
-
109
- desc "#{description} with coverage"
110
- task :"#{name}_cov" do
111
- ENV['COVERAGE'] = '1'
112
- run_spec.call(files)
113
- ENV.delete('COVERAGE')
114
- end
115
- end
116
-
117
- desc "Run the core, model, and extension/plugin specs"
118
- task :default => :spec
119
- desc "Run the core, model, and extension/plugin specs"
120
- task :spec => [:spec_core, :spec_model, :spec_plugin]
121
-
122
- spec_task.call("Run core and model specs together", :spec_core_model, './spec/core/*_spec.rb ./spec/model/*_spec.rb')
123
- spec_task.call("Run core specs", :spec_core, './spec/core/*_spec.rb')
124
- spec_task.call("Run model specs", :spec_model, './spec/model/*_spec.rb')
125
- spec_task.call("Run plugin/extension specs", :spec_plugin, './spec/extensions/*_spec.rb')
126
- spec_task.call("Run bin/sequel specs", :spec_bin, './spec/bin_spec.rb')
127
- spec_task.call("Run core extensions specs", :spec_core_ext, './spec/core_extensions_spec.rb')
128
- spec_task.call("Run integration tests", :spec_integration, './spec/integration/*_test.rb')
129
-
130
- %w'postgres sqlite mysql informix oracle firebird mssql db2 sqlanywhere'.each do |adapter|
131
- spec_task.call("Run #{adapter} tests", :"spec_#{adapter}", "./spec/adapters/#{adapter}_spec.rb ./spec/integration/*_test.rb")
132
- end
133
-
134
- spec_task.call("Run model specs without the associations code", :_spec_model_no_assoc, Dir["./spec/model/*_spec.rb"].delete_if{|f| f =~ /association|eager_loading/}.join(' '))
135
- desc "Run model specs without the associations code"
136
- task :spec_model_no_assoc do
137
- ENV['SEQUEL_NO_ASSOCIATIONS'] = '1'
138
- Rake::Task['_spec_model_no_assoc'].invoke
139
- end
140
-
141
- task :spec_travis=>[:spec_core, :spec_model, :spec_plugin, :spec_core_ext] do
142
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
143
- ENV['SEQUEL_SQLITE_URL'] = "jdbc:sqlite::memory:"
144
- ENV['SEQUEL_POSTGRES_URL'] = "jdbc:postgresql://localhost/sequel_test?user=postgres"
145
- ENV['SEQUEL_MYSQL_URL'] = "jdbc:mysql://localhost/sequel_test?user=root"
146
- else
147
- ENV['SEQUEL_SQLITE_URL'] = "sqlite:/"
148
- ENV['SEQUEL_POSTGRES_URL'] = "postgres://localhost/sequel_test?user=postgres"
149
- ENV['SEQUEL_MYSQL_URL'] = "mysql2://localhost/sequel_test?user=root"
150
- end
151
-
152
- Rake::Task['spec_sqlite'].invoke
153
- Rake::Task['spec_postgres'].invoke
154
- Rake::Task['spec_mysql'].invoke
155
- end
156
-
157
- desc "Print Sequel version"
158
- task :version do
159
- puts VERS.call
160
- end
161
-
162
- desc "Check syntax of all .rb files"
163
- task :check_syntax do
164
- Dir['**/*.rb'].each{|file| print `#{FileUtils::RUBY} -c #{file} | fgrep -v "Syntax OK"`}
165
- end
@@ -1,912 +0,0 @@
1
- = Sequel for ActiveRecord Users
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 a newer ActiveRecord version, the transition should be even easier.
4
-
5
- == Introduction
6
-
7
- Both Sequel and ActiveRecord use the active record pattern of database access, where model instances are objects that wrap a row in a database table or view, encapsulating the database access, and adding domain logic on that data. Just like ActiveRecord, Sequel supports both associations and inheritance, though Sequel does so in a more flexible manner than ActiveRecord.
8
-
9
- Let's quickly run through the ActiveRecord README and show how it applies to Sequel.
10
-
11
- == Automatic Mapping
12
-
13
- Just like ActiveRecord, Sequel maps classes to tables and automatically creates accessor methods for the columns in the table, so if you have an albums table with a primary key named "id" and a string/varchar column named "name", the minimal model class is:
14
-
15
- class Album < Sequel::Model
16
- end
17
-
18
- Sequel will autogenerate the column accessors, so you can do:
19
-
20
- album = Album.new
21
- album.name = 'RF'
22
-
23
- If the table name for the class doesn't match the default one Sequel will choose, you can specify it manually:
24
-
25
- class Album < Sequel::Model(:records)
26
- end
27
-
28
- == Associations
29
-
30
- Sequel supports most of the same association types as ActiveRecord, but it uses names that reflect the database relationships instead of ones that imply ownership:
31
-
32
- class Album < Sequel::Model
33
- many_to_one :artist
34
- one_to_many :tracks
35
- many_to_many :tags
36
- end
37
-
38
- == Compositions
39
-
40
- Sequel's +composition+ plugin allows you to easily create accessor methods that are composed of one or more of the database's columns, similar to ActiveRecord's +composed_of+:
41
-
42
- class Artist < Sequel::Model
43
- plugin :composition
44
- composition :address, :mapping=>[:street, :city, :state, :zip]
45
- end
46
-
47
- == Validations
48
-
49
- Sequel's +validation_class_methods+ plugin is modeled directly on ActiveRecord's validations, but the recommended approach is to use the +validation_helpers+ plugin inside a +validate+ instance method:
50
-
51
- class Album < Sequel::Model
52
- plugin :validation_helpers
53
-
54
- def validate
55
- super
56
- validates_presence [:name, :copies_sold]
57
- validates_unique [:name, :artist_id]
58
- end
59
- end
60
-
61
- == Hooks/Callbacks
62
-
63
- Sequel's +hook_class_methods+ plugin is modeled directly on ActiveRecord's callbacks, but the recommended approach is to define your hooks/callbacks as instance methods:
64
-
65
- class Album < Sequel::Model
66
- def before_create
67
- self.copies_sold ||= 0
68
- super
69
- end
70
-
71
- def after_update
72
- super
73
- AuditLog.create(:log=>"Updated Album #{id}")
74
- end
75
- end
76
-
77
- Observers can be implemented completely by hooks, so Sequel doesn't offer a separate observer class.
78
-
79
- == Inheritance
80
-
81
- Sequel supports both single table inheritance and class table inheritance using plugins:
82
-
83
- class Employee < Sequel::Model
84
- plugin :single_table_inheritance, :class_name_column
85
- # or
86
- plugin :class_table_inheritance
87
- end
88
-
89
- class Staff < Employee
90
- end
91
-
92
- class Manager < Employee
93
- end
94
-
95
- class Executive < Manager
96
- end
97
-
98
- == Transactions
99
-
100
- Sequel supports transactions via the Database object (we recommend using the DB constant for single database applications):
101
-
102
- DB.transaction do
103
- album.artist.num_albums -= 1
104
- album.artist.save
105
- album.delete
106
- end
107
-
108
- For model classes, you can always access the database via +db+:
109
-
110
- Album.db.transaction do
111
- album.artist.num_albums -= 1
112
- album.artist.save
113
- album.delete
114
- end
115
-
116
- == Reflection
117
-
118
- Just like ActiveRecord, Sequel has full reflection support for columns, associations, and many other things:
119
-
120
- Album.columns # => [:id, :name, :artist_id, :copies_sold]
121
- reflection = Album.association_reflection(:artist)
122
- reflection[:type] == :many_to_one
123
-
124
- == Direct Manipulation
125
-
126
- Just like ActiveRecord, Sequel doesn't use sessions, it lets you modify objects and have them be saved inside the call to +save+:
127
-
128
- album = Album[1234]
129
- # modify album
130
- album.save
131
-
132
- == Database Abstraction
133
-
134
- Sequel supports far more database abstractions than ActiveRecord, and setting up the database connection is easy:
135
-
136
- DB = Sequel.sqlite # memory database
137
- DB = Sequel.connect('postgres://user:pass@host/database') # connection string
138
- DB = Sequel.connect(:adapter=>'postgres', :user=>'?', :password=>'?',
139
- :host=>'?', :database=>'?') # option hash
140
-
141
- == Logging
142
-
143
- Sequel supports logging of all database queries by allowing multiple loggers for each database:
144
-
145
- DB.loggers << Logger.new($stdout)
146
-
147
- == Migrations
148
-
149
- Sequel supports migrations and has a migrator similar to ActiveRecord:
150
-
151
- Sequel.migration do
152
- change do
153
- create_table(:albums) do
154
- primary_key :id
155
- String :name
156
- end
157
- end
158
- end
159
-
160
- == Differences
161
-
162
- By now, you should have the idea that Sequel supports most things that ActiveRecord supports. The rest of this guide is going to go over how Sequel differs from ActiveRecord in terms of operation.
163
-
164
- === Method Chaining
165
-
166
- Unlike ActiveRecord 2 (and similar to ActiveRecord 3+), Sequel uses method chains on datasets for retrieving objects, so instead of:
167
-
168
- Album.find(:all, :conditions=>['name > ? AND artist_id = ?', 'RF', 1],
169
- :order=>'copies_sold', :select=>'id, name')
170
-
171
- Sequel uses:
172
-
173
- Album.where{name > 'RF'}.where(:artist_id=>1).order(:copies_sold).
174
- select(:id, :name).all
175
-
176
- Note that the records aren't retrieved until +all+ is called.
177
-
178
- ActiveRecord 3 adopts this method chaining approach, so if you are familiar with it, it should be even easier to transition to Sequel.
179
-
180
- === No Need for SQL String Fragments
181
-
182
- Like the example above, most ActiveRecord code uses SQL string fragments. With Sequel, you rarely need to. Sequel's DSL allows you to create complex queries without ever specifying SQL string fragments (called literal strings in Sequel).
183
-
184
- If you want to use SQL string fragments, Sequel makes it easy by using the <tt>Sequel.lit</tt> method:
185
-
186
- Album.select(Sequel.lit('id, name'))
187
-
188
- This usage is not encouraged, though. The recommended way is to use symbols to represent the columns:
189
-
190
- Album.select(:id, :name)
191
-
192
- Sequel keeps datasets in an abstract format, allowing for powerful capabilities. For example, let's say you wanted to join to the artists table. Sequel can automatically qualify all references in the current dataset, so that it can be safely joined:
193
-
194
- Album.select(:id, :name).qualify.join(:artists, :id=>:artist_id)
195
-
196
- This isn't possible when you use an SQL string fragment. Another case where using an SQL string fragment hurts you is when the SQL syntax cannot handle all cases:
197
-
198
- Album.filter('id NOT IN ?', ids_array)
199
-
200
- That will work fine if +ids_array+ is not empty, but will not work correctly if it is empty. With Sequel, you do:
201
-
202
- Album.exclude(:id=>ids_array)
203
-
204
- That will handle cases where +ids_array+ is empty correctly.
205
-
206
- A third reason to not use SQL string fragments is database independence. For example, if you want a case insensitive search that works on both PostgreSQL and MySQL, the following won't work:
207
-
208
- Album.filter('name LIKE ?', 'A%')
209
-
210
- This is because LIKE is case sensitive on PostgreSQL, but case insensitive on MySQL. With Sequel, you would do:
211
-
212
- Album.filter(Sequel.ilike(:name, 'A%'))
213
-
214
- This will do a case insensitive search on both databases. If you want a case sensitive search on both, you can use +like+ instead of +ilike+.
215
-
216
- String concatenation is a similar area, where MySQL and PostgreSQL handle things differently. With Sequel, the same code can work on both databases:
217
-
218
- Album.select(Sequel.join([:name, ' - Name']))
219
-
220
- == Flexible Overriding
221
-
222
- Unlike ActiveRecord 2, which forces you to alias methods if you want to override them, with Sequel you just override the methods and call super:
223
-
224
- class Sequel::Model
225
- def after_update
226
- super
227
- AuditLog.create(:log=>"#{model.name} with primary key #{pk} updated")
228
- end
229
- end
230
-
231
- With that code, you have enabled auditing for all model object updates.
232
-
233
- Let's say you want to override accessor methods. In Sequel, instead of using +read_attribute+ and +write_attribute+, you can just call super:
234
-
235
- class Track < Sequel::Model
236
- # database holds length in integer seconds,
237
- # but you want it in minutes as a float
238
-
239
- def length=(minutes)
240
- super((minutes*60).to_i)
241
- end
242
-
243
- def length
244
- super/60.0
245
- end
246
- end
247
-
248
- You can override almost all model class or instance methods this way, just remember to call +super+.
249
-
250
- == +method_missing+ Missing
251
-
252
- Sequel does not use +method_missing+ unless it's required that the object respond to potentially any method. Neither <tt>Sequel::Model</tt> nor <tt>Sequel::Dataset</tt> nor <tt>Sequel::Database</tt> implement +method_missing+ at either a class or instance level. So if you call +methods+, you can see which methods are available, and if they aren't listed, then the object won't respond to them. Among other things, this means Sequel does not support dynamic finders. So instead of:
253
-
254
- Album.find_or_create_by_name("RF")
255
-
256
- You just use:
257
-
258
- Album.find_or_create(:name=>"RF")
259
-
260
- At the instance level, this means that if you select columns that aren't in the models table, you need to use <tt>Model#[]</tt> to access them:
261
-
262
- album = Album.join(:artist, :id=>:artist_id).
263
- select(:albums__id, :albums__name, :artists__name___artist).first
264
- # SELECT albums.id, albums.name, artists.name AS artist
265
-
266
- album.artist # Error!
267
- album[:artist] # Works
268
-
269
- == Associations
270
-
271
- Sequel associations are similar to ActiveRecord associations in some ways, and much different in others. Sequel provides four association creation methods that map to ActiveRecord's associations:
272
-
273
- ActiveRecord :: Sequel
274
- +belongs_to+ :: +many_to_one+
275
- +has_one+ :: +one_to_one+
276
- +has_many+ :: +one_to_many+
277
- +has_and_belongs_to_many+ :: +many_to_many+
278
-
279
- Like ActiveRecord, when you create an association in Sequel, it creates an instance method with the same name that returns either the matching object or nil for the <tt>*_to_one</tt> associations, or an array of matching objects for the <tt>*_to_many</tt> associations.
280
-
281
- Updating <tt>*_to_many</tt> associations is very different, however. ActiveRecord makes the association method returns an association proxy that looks like an array, but has a bunch of added methods to manipulate the associated records. Sequel uses instance methods on the object instead of a proxy to modify the association. Here's a basic example:
282
-
283
- Artist.one_to_many :albums
284
- Album.many_to_one :artist
285
-
286
- artist = Artist[1]
287
- album = Album[1]
288
-
289
- artist.albums # array of albums
290
- album.artist # Artist instance or nil
291
-
292
- artist.add_album(album) # associate album to artist
293
- artist.remove_album(album) # disassociate album from artist
294
- artist.remove_all_albums # disassociate all albums from artist
295
-
296
- Sequel doesn't have a <tt>has_many :through</tt> association, instead you can use a +many_to_many+ association in most cases. Sequel ships with a +many_through_many+ plugin that allows you to set up a many to many relationship through an arbitrary number of join tables.
297
-
298
- Sequel doesn't come with support for polymorphic associations. Using polymorphic associations is generally bad from a database design perspective, as it violates referential integrity. If you have an old database and must have polymorphic associations, there is an external +sequel_polymorphic+ plugin that can handle them, just by using the standard association options provided by Sequel.
299
-
300
- Sequel doesn't directly support creating a bunch of associated objects and delaying saving them to the database until the main object is saved, like you can with the <tt>association.build</tt> methods in ActiveRecord. You can use +before_save or +after_save+ hooks, or the +nested_attributes+ or +instance_hooks+ plugins to get similar support.
301
-
302
- Sequel supports the same basic association hooks/callbacks as ActiveRecord. It also supports <tt>:after_load</tt>, which is run after the associated objects are loaded. For <tt>*_to_one</tt> associations, it supports +before_set+ and +after_set+ hooks, since a setter method is used instead of an add/remove method pair.
303
-
304
- If you pass a block to an association method, it's used to return a modified dataset used for the association, instead of to create an association extension:
305
-
306
- Artist.one_to_many :gold_albums, :class=>:Album do |ds|
307
- ds.where{copies_sold > 500000}
308
- end
309
-
310
- If you want to create an association extension, you can use the <tt>:extend</tt> association option with a module, which ActiveRecord also supports. In Sequel, the extensions are applied to the association dataset, not to the array of associated objects. You can access the association dataset using the +association_dataset+ method:
311
-
312
- artist.albums_dataset
313
- album.artist_dataset
314
-
315
- Association datasets are just like any other Sequel dataset, in that you can filter them and manipulate them further:
316
-
317
- gold_albums = artist.albums_dataset.where{copies_sold > 500000}.order(:name).all
318
-
319
- Sequel caches associated objects similarly to ActiveRecord, and you can skip the cache by passing +true+ to the association method, just like ActiveRecord.
320
-
321
- === Eager Loading
322
-
323
- ActiveRecord 2 tries to guess whether to use preloading or JOINs for eager loading by scanning the SQL string fragments you provide for table names. This is error prone and Sequel avoids it by giving you separate methods. In Sequel, +eager+ is used for preloading and +eager_graph+ is used for JOINs. Both have the same API:
324
-
325
- Artist.eager(:albums=>[:tags, :tracks])
326
- Album.eager_graph(:artist, :tracks)
327
-
328
- With either way of eager loading, you must call +all+ to retrieve all records at once. You cannot use +each+, +map+, or one of the other Enumerable methods. Just like +each+, +all+ takes a block that iterates over the records:
329
-
330
- Artist.eager(:albums=>[:tags, :tracks]).each{|a| } # No cookie
331
- Artist.eager(:albums=>[:tags, :tracks]).all{|a| } # Cookie
332
-
333
- Like ActiveRecord, Sequel supports cascading of eager loading for both methods of eager loading.
334
-
335
- Unlike ActiveRecord, Sequel allows you to eager load custom associations using the <tt>:eager_loader</tt> and <tt>:eager_grapher</tt> association options. See the {Advanced Associations guide}[rdoc-ref:doc/advanced_associations.rdoc] for more details.
336
-
337
- Table aliasing when eager loading via +eager_graph+ is different in Sequel than ActiveRecord. Sequel will always attempt to use the association name, not the table name, for any associations. If the association name has already been used, Sequel will append _N to it, where N starts at 0 and increases by 1. For example, for a self referential association:
338
-
339
- class Node < Sequel::Model
340
- many_to_one :parent, :class=>self
341
- one_to_many :children, :class=>self, :key=>:parent_id
342
- end
343
-
344
- Node.eager_graph(:parent=>:parent, :children=>{:children=>:children}).all
345
-
346
- # SELECT nodes.id, nodes.parent_id, -- main table
347
- # parent.id AS parent_id_0, parent.parent_id AS parent_parent_id, -- parent
348
- # parent_0.id AS parent_0_id, parent_0.parent_id AS parent_0_parent_id, -- grandparent
349
- # children.id AS children_id, children.parent_id AS children_parent_id, -- children
350
- # children_0.id AS children_0_id, children_0.parent_id AS children_0_parent_id, -- grandchildren
351
- # children_1.id AS children_1_id, children_1.parent_id AS children_1_parent_id -- great grandchidren
352
- # FROM nodes -- main table
353
- # LEFT OUTER JOIN nodes AS parent ON (parent.id = nodes.parent_id) -- parent
354
- # LEFT OUTER JOIN nodes AS parent_0 ON (parent_0.id = parent.parent_id) -- grandparent
355
- # LEFT OUTER JOIN nodes AS children ON (children.parent_id = nodes.id) -- children
356
- # LEFT OUTER JOIN nodes AS children_0 ON (children_0.parent_id = children.id) -- grandchildren
357
- # LEFT OUTER JOIN nodes AS children_1 ON (children_1.parent_id = children_0.id) -- great grandchildren
358
-
359
- You can specify aliases on a per join basis, too:
360
-
361
- Node.eager_graph(:parent=>Sequel.as(:parent, :grandparent),
362
- :children=>{Sequel.as(:children, :grandchildren)=>Sequel.as(:children, :great_grandchildren)}).all
363
-
364
- # SELECT nodes.id, nodes.parent_id,
365
- # parent.id AS parent_id_0, parent.parent_id AS parent_parent_id,
366
- # grandparent.id AS grandparent_id, grandparent.parent_id AS grandparent_parent_id,
367
- # children.id AS children_id, children.parent_id AS children_parent_id,
368
- # grandchildren.id AS grandchildren_id, grandchildren.parent_id AS grandchildren_parent_id,
369
- # great_grandchildren.id AS great_grandchildren_id, great_grandchildren.parent_id AS great_grandchildren_parent_id
370
- # FROM nodes
371
- # LEFT OUTER JOIN nodes AS parent ON (parent.id = nodes.parent_id)
372
- # LEFT OUTER JOIN nodes AS grandparent ON (grandparent.id = parent.parent_id)
373
- # LEFT OUTER JOIN nodes AS children ON (children.parent_id = nodes.id)
374
- # LEFT OUTER JOIN nodes AS grandchildren ON (grandchildren.parent_id = children.id)
375
- # LEFT OUTER JOIN nodes AS great_grandchildren ON (great_grandchildren.parent_id = grandchildren.id)
376
-
377
- === Options
378
-
379
- Sequel supports many more association options than ActiveRecord, but here's a mapping of ActiveRecord association options to Sequel association options. Note that when you specify columns in Sequel, you use symbols, not strings. Where ActiveRecord would use an SQL string fragment with embedded commas for multiple columns, Sequel would use an array of column symbols.
380
-
381
- === Shared options
382
-
383
- These options are shared by more than one ActiveRecord association.
384
-
385
- ActiveRecord option :: Sequel option
386
- <tt>:class_name</tt> :: <tt>:class</tt>
387
- <tt>:conditions</tt> :: <tt>:conditions</tt>
388
- <tt>:select</tt> :: <tt>:select</tt>
389
- <tt>:order</tt> :: <tt>:order</tt>
390
- <tt>:extend</tt> :: <tt>:extend</tt>
391
- <tt>:limit</tt> :: <tt>:limit</tt>
392
- <tt>:offset</tt> :: <tt>:limit</tt> with an array with the second element being the offset
393
- <tt>:uniq</tt> :: <tt>:uniq</tt>
394
- <tt>:validate</tt> :: <tt>:validate</tt>
395
- <tt>:dependent</tt> :: The +associations_dependencies+ plugin
396
- <tt>:polymorphic</tt>, <tt>:as</tt>, <tt>:source_type</tt> :: The +sequel_polymorphic+ external plugin
397
- <tt>:include</tt> :: <tt>:eager</tt>, <tt>:eager_graph</tt>
398
- <tt>:readonly</tt> :: No equivalent, the Sequel <tt>:read_only</tt> option just means the modification methods are not created (it makes the association read only, not records retrieved through the association)
399
- <tt>:through</tt>, <tt>:source</tt> :: Use a +many_to_many+ or +one_through_one+ association, or the +many_through_many+ plugin
400
- <tt>:touch</tt> :: The +touch+ plugin
401
- <tt>:autosave</tt> :: A +before_save+ or +after_save+ hook
402
- <tt>:finder_sql</tt> :: <tt>:dataset</tt> to set a custom dataset
403
- <tt>:counter_sql</tt> :: No direct equivalent, but a count on the dataset will use the custom dataset specified by <tt>:dataset</tt>
404
- <tt>:group</tt> :: Use the association block to add the group to the dataset
405
- <tt>:having</tt> :: Use the association block to add the having to the dataset
406
-
407
- === +belongs_to+
408
-
409
- +belongs_to+ option :: +many_to_one+ option
410
- <tt>:foreign_key</tt> :: <tt>:key</tt>
411
- <tt>:primary_key</tt> :: <tt>:primary_key</tt>
412
- <tt>:counter_cache</tt> :: No equivalent
413
-
414
- === +has_one+, +has_many+
415
-
416
- +has_one+, +has_many+ option :: +one_to_one+, +one_to_many+ option
417
- <tt>:foreign_key</tt> :: <tt>:key</tt>
418
-
419
- === +has_and_belongs_to_many+
420
-
421
- +has_and_belongs_to_many+ option :: +many_to_many+ option
422
- <tt>:foreign_key</tt> :: <tt>:left_key</tt>
423
- <tt>:association_foreign_key</tt> :: <tt>:right_key</tt>
424
- <tt>:join_table</tt> :: <tt>:join_table</tt>
425
- <tt>:delete_sql</tt> :: <tt>:remover</tt>
426
- <tt>:insert_sql</tt> :: <tt>:adder</tt>
427
-
428
- == Validation Errors
429
-
430
- If there are errors when validating an object in Sequel, they are stored in a <tt>Sequel::Model::Errors</tt> instance. It's mostly similar to <tt>ActiveRecord::Errors</tt>, so this section will just go over the differences.
431
-
432
- <tt>Sequel::Model::Errors</tt> is a hash subclass where keys are usually column symbols (not required), and values are arrays of error messages. So if you have two error messages on the same column, +each+ will only yield once, not twice.
433
-
434
- The +add_on_blank+, +add_on_empty+, +add_to_base+, +each_full+, +generate_message+, <tt>invalid?</tt>, +on_base+, and +to_xml+ methods don't exist. <tt>[]</tt> should not be used directly, instead you should use +on+.
435
-
436
- You can think of <tt>Sequel::Model::Errors</tt> as a subset of <tt>ActiveRecord::Errors</tt> if you stick to +on+, +add+, and +full_messages+.
437
-
438
- == Sequel Configuration Flags
439
-
440
- Unlike ActiveRecord, Sequel's behavior depends on how you configure it. In Sequel, you can set flags at the global, class, and instance level that change the behavior of Sequel. Here's a brief description of the flags:
441
-
442
- +raise_on_save_failure+ :: Whether to raise an error instead of returning nil on a failure to save/create/save_changes/etc due to a validation failure or a before_* hook returning false. By default, an error is raised, when this is set to false, nil is returned instead.
443
- +raise_on_typecast_failure+ :: Whether to raise an error when unable to typecast data for a column (default: true). This should be set to false if you want to use validations to display nice error messages to the user (e.g. most web applications). You can use the +validates_schema_types+ validation in connection with this option to check for typecast failures.
444
- +require_modification+ :: Whether to raise an error if an UPDATE or DELETE query related to a model instance does not modify exactly 1 row. If set to false, Sequel will not check the number of rows modified (default: true if the database supports it).
445
- +strict_param_setting+ :: Whether new/set/update and their variants should raise an error if an invalid key is used. A key is invalid if no setter method exists for that key or the access to the setter method is restricted (e.g. due to it being a primary key field). If set to false, silently skip any key where the setter method doesn't exist or access to it is restricted.
446
- +typecast_empty_string_to_nil+ :: Whether to typecast the empty string ('') to nil for columns that are not string or blob. In most cases the empty string would be the way to specify a NULL SQL value in string form (nil.to_s == ''), and an empty string would not usually be typecast correctly for other types, so the default is true.
447
- +typecast_on_assignment+ :: Whether to typecast attribute values on assignment (default: true). If set to false, no typecasting is done, so it will be left up to the database to typecast the value correctly.
448
- +use_transactions+ :: Whether to use a transaction by default when saving/deleting records (default: true). If you are sending database queries in before or after hooks, you shouldn't change the default setting without a good reason.
449
-
450
- == ActiveRecord Method to Sequel Method Mapping
451
-
452
- This part of the guide will list Sequel equivalents for ActiveRecord methods, hopefully allowing you to convert your existing ActiveRecord code to Sequel code more easily.
453
-
454
- === Class Methods with Significantly Different Behavior
455
-
456
- ==== +abstract_class+, <tt>abstract_class=</tt>, <tt>abstract_class?</tt>
457
-
458
- With Sequel, these methods don't exist because it doesn't default to using single table inheritance in subclasses. ActiveRecord assumes that subclasses of Model classes use single table inheritance, and you have to set <tt>abstract_class = true</tt> to use an abstract class. In Sequel, you must use the +single_table_inheritance+ or +class_table_inheritance+ plugin to configure inheritance in the database.
459
-
460
- ==== +all+
461
-
462
- In both Sequel and ActiveRecord, calling +all+ will give you an array of all records. However, while in ActiveRecord you pass options to +all+ to filter or order the results, in Sequel you call dataset methods to filter or order the results, and then end the method chain with a call to +all+ to return the records.
463
-
464
- ==== +column_names+
465
-
466
- Sequel uses symbols for columns, so the +columns+ method returns an array of symbols. If you want an array of strings:
467
-
468
- Album.columns.map{|x| x.to_s}
469
-
470
- ==== +columns+
471
-
472
- <tt>Sequel::Model.columns</tt> returns an array of column name symbols. The closest similar thing would be to get the database schema hash for each column:
473
-
474
- Album.columns.map{|x| Album.db_schema[x]}
475
-
476
- ==== +composed_of+
477
-
478
- As mentioned earlier, Sequel uses the +composition+ plugin for this:
479
-
480
- class Artist < Sequel::Model
481
- plugin :composition
482
- composition :address, :mapping=>[:street, :city, :state, :zip]
483
- end
484
-
485
- ==== <tt>connected?</tt>
486
-
487
- <tt>Sequel::Model</tt> raises an exception if you haven't instantiated a <tt>Sequel::Database</tt> object before loading the model class. However, if you want to test the connection to the database:
488
-
489
- Sequel::Model.db.test_connection
490
-
491
- Note that +test_connection+ will return true if a connection can be made, but will probably raise an exception if it cannot be made.
492
-
493
- ==== +connection+
494
-
495
- Sequel only uses connections for the minimum amount of time necessary, checking them out to do a query, and returning them as soon as the query finishes. If you do want direct access to the connection object:
496
-
497
- Sequel::Model.db.synchronize do |connection|
498
- # ...
499
- end
500
-
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.
502
-
503
- ==== +count_by_sql+
504
-
505
- You can call +with_sql+ to set the SQL to use, and the +single_value+ to retrieve the result.
506
-
507
- Album.with_sql("SELECT COUNT(*) ...").single_value
508
-
509
- ==== +delete+, +delete_all+
510
-
511
- You probably want to filter first, then call +delete+:
512
-
513
- Album.where(:id=>id).delete
514
- Album.where("artist_id = ?", 5).delete
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
-
520
- ==== +destroy+, +destroy_all+
521
-
522
- Similar to +delete+, you filter first, then +destroy+:
523
-
524
- Album.where(:id=>id).destroy
525
- Album.where("artist_id = ?", 5).destroy
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
-
531
- ==== +establish_connection+
532
-
533
- If you want to use a specific <tt>Sequel::Database</tt> object, you can use <tt>db=</tt>:
534
-
535
- BACKUP_DB = Sequel.connect('postgres://...')
536
- Album.db = BACKUP_DB
537
-
538
- If you want a specific dataset in that database, you can use +set_dataset+ or <tt>dataset=</tt>:
539
-
540
- Album.set_dataset BACKUP_DB[:albums]
541
- Album.dataset = BACKUP_DB[:albums]
542
-
543
- ==== <tt>exists?</tt>
544
-
545
- You need to filter the dataset first, then call <tt>empty?</tt> and invert the result:
546
-
547
- !Album.where(:id=>1).empty?
548
-
549
- ==== +find+
550
-
551
- ActiveRecord's +find+ can be used for a lot of different things. If you are trying to find a single object given a primary key:
552
-
553
- Album[1]
554
-
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)
559
-
560
- If you want to find multiple objects using an array of primary keys:
561
-
562
- Album.where(:id=>[1, 2, 3]).all
563
-
564
- If you are using <tt>find(:first, ...)</tt>, you use a method chain instead of passing the options, and end it with +first+:
565
-
566
- Album.where(:artist_id=>1).order(:name).first
567
-
568
- If you are using <tt>find(:last, ...)</tt>, you need to specify an order in Sequel, but the same method chain approach is used, which you end with +last+:
569
-
570
- Album.where(:artist_id=>1).order(:name).last
571
- # You could also do:
572
- Album.where(:artist_id=>1).reverse_order(:name).first
573
-
574
- If you are using <tt>find(:all, ...)</tt>, you use a method chain instead of passing the options, and end it with +all+:
575
-
576
- Album.where(:artist_id=>1).order(:name).all
577
-
578
- Here's a mapping of ActiveRecord +find+ options to <tt>Sequel::Dataset</tt> methods:
579
-
580
- :conditions :: filter, where
581
- :order :: order
582
- :group :: group
583
- :limit :: limit
584
- :offset :: offset
585
- :joins :: join, left_join, etc. # many other join methods
586
- :include :: eager, eager_graph # eager does preloading, eager_graph does JOINs
587
- :select :: select
588
- :from :: from
589
- :read_only :: # No Sequel equivalent
590
- :lock :: for_update, lock_style
591
-
592
- ==== +find_by_sql+
593
-
594
- Similar to +count_by_sql+, you use +with_sql+, followed by +all+:
595
-
596
- Album.with_sql("SELECT * FROM albums WHERE ...").all
597
-
598
- ==== +first+
599
-
600
- Just like with <tt>find(:first, ...)</tt>, you use a method chain instead of passing the options, and end it with +first+:
601
-
602
- Album.where(:artist_id=>1).order(:name).first
603
-
604
- ==== +last+
605
-
606
- Just like with <tt>find(:last, ...)</tt>, you use a method chain instead of passing the options, make sure it includes an order, and end it with +last+:
607
-
608
- Album.where(:artist_id=>1).order(:name).last
609
-
610
- ==== +named_scope+
611
-
612
- For a pure filter, you can use +subset+:
613
-
614
- Album.subset(:debut, :position => 1)
615
- Album.subset(:gold){copies_sold > 500000}
616
-
617
- For anything more complex, you can use +dataset_module+:
618
-
619
- Album.dataset_module do
620
- def by_artist(artist_id)
621
- where(:artist_id=>artist_id)
622
- end
623
-
624
- def by_release_date
625
- order(:release_date)
626
- end
627
- end
628
-
629
- ==== +reset_column_information+
630
-
631
- If you want to completely reload the schema for the table:
632
-
633
- Album.instance_variable_set(:@db_schema, nil)
634
- Album.send(:get_db_schema, true)
635
-
636
- ==== +serialize+, +seralized_attributes+
637
-
638
- Sequel ships with a +serialization+ plugin that you can use.
639
-
640
- class Album < Sequel::Model
641
- plugin :serialization, :json, :permissions
642
- end
643
-
644
- For +serialized_attributes+, you can use +serialization_map+, which is also a hash, but keys are column symbols and values are callable objects used to serialize the values.
645
-
646
- ==== +set_inheritance_column+
647
-
648
- This is something that must be specified when you are loading the +single_table_inheritance+ plugin:
649
-
650
- class Album < Sequel::Model
651
- plugin :single_table_inheritance, :column
652
- end
653
-
654
- ==== +set_sequence_name+
655
-
656
- Sequel will usually auto discover the sequence to use. However, on Oracle this should be specified by making sure the model's dataset includes a sequence:
657
-
658
- class Album < Sequel::Model(ORACLE_DB[:albums].sequence('albums_seq'))
659
- end
660
-
661
- ==== <tt>table_exists?</tt>
662
-
663
- This is a <tt>Sequel::Database</tt> method:
664
-
665
- Album.db.table_exists?(Album.table_name)
666
-
667
- With the +schema+ plugin, you can use it directly:
668
-
669
- Album.plugin :schema
670
- Album.table_exists?
671
-
672
- ==== +transaction+
673
-
674
- As mentioned earlier, +transaction+ is a database method in Sequel, which you can access via the +db+ method:
675
-
676
- Album.db.transaction{}
677
-
678
- ==== +update+, +update_all+
679
-
680
- Just like +delete+ and +destroy+, you filter first, then +update+:
681
-
682
- Album.where(:id=>id).update(:name=>'RF')
683
- Album.where("artist_id = ?", 5).update(:copies_sold=>0)
684
-
685
- Likewise, to update all rows in the model:
686
-
687
- Album.dataset.update(:name=>'RF')
688
-
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:
690
-
691
- Album[id].update(:name=>'RF')
692
- Album.where("artist_id = ?", 5).all{|a| a.update(:copies_sold=>0)}
693
-
694
- ==== +with_scope+
695
-
696
- Sequel works a little differently than with_scope. Instead of using nested blocks, you just use a cleaner method chain. +with_scope+ is often used as an around_filter or similar construct, where in Sequel, you would just need to assign to a dataset in a before filter, and use that dataset in the action.
697
-
698
- === Class Methods with Roughly the Same Behavior
699
-
700
- Note that Sequel uses symbols almost everywhere to represent columns, while ActiveRecord often returns columns as strings.
701
-
702
- ActiveRecord Method :: Sequel Method
703
- +attr_accessible+ :: +set_allowed_columns+
704
- +attr_protected+ :: +set_restricted_columns+
705
- +average+ :: +avg+
706
- +belongs_to+ :: +many_to_one+
707
- +columns_hash+ :: +db_schema+
708
- +count+ :: +count+
709
- +changed+ :: +changed_columns+
710
- +create+ :: +create+
711
- +has_and_belongs_to_many+ :: +many_to_many+
712
- +has_one+ :: +one_to_one+
713
- +has_many+ :: +one_to_many+
714
- +inheritance_column+ :: +sti_key+
715
- +inspect+ :: +inspect+
716
- +maximum+ :: +max+
717
- +minimum+ :: +min+
718
- +new+ :: +new+
719
- +primary_key+ :: +primary_key+
720
- <tt>respond_to?</tt> :: <tt>respond_to?</tt>
721
- +set_primary_key+ :: +set_primary_key+
722
- +sum+ :: +sum+
723
- +table_name+ :: +table_name+
724
- +unscoped+ :: +unfiltered+
725
-
726
- === Class Methods without an Equivalent
727
-
728
- ActiveRecord Method :: Notes, Workarounds
729
- +accepts_nested_attributes_for+ :: Use the +nested_attributes+ plugin
730
- +attr_readonly+ :: Don't update the columns (duh!), or add a before_update hook that deletes them from the values hash
731
- +attribute_method_suffix+ :: No equivalent
732
- +alias_attribute_with_dirty+ :: No equivalent
733
- +base_class+ :: Not needed internally, you can probably use <tt>sti_dataset.model</tt> if you are using single table inheritance
734
- +benchmark+ :: Just use the +benchmark+ library from ruby's stdlib
735
- +calculate+ :: No direct equivalent, just build the query manually and execute it
736
- +cache+ :: No equivalent
737
- <tt>cache_attribute?</tt> :: No equivalent
738
- +cache_attributes+ :: No equivalent
739
- +cached_attributes+ :: No equivalent
740
- <tt>changed?</tt> :: <tt>changed_columns.include?(column)</tt>
741
- +changes+ :: No equivalent
742
- <tt>clear_active_connections!</tt> :: Sequel doesn't leak connections like ActiveRecord, so you don't need to worry about this
743
- <tt>clear_reloadable_connections!</tt> :: Sequel doesn't leak connections like ActiveRecord, so you don't need to worry about this
744
- +content_columns+ :: Not needed internally, you can probably do <tt>Album.columns.map{|x| x.to_s}.delete_if{|x| x == Album.primary_key || x =~ /_(id|count)\z/}</tt>
745
- +decrement_counter+ :: <tt>Album.where(:id=>:id).update(:counter_name=>Sequel.-(:counter_name, 1))</tt>
746
- +define_attribute_methods+, +define_read_methods+ :: <tt>def_column_accessor(*columns)</tt>, a private method
747
- <tt>descends_from_active_record?</tt> :: Not needed internally, if using single table inheritance, <tt>Album.sti_dataset.model == Album</tt>
748
- +find_each+, +find_in_batches+ :: Use the +pagination+ extension
749
- <tt>generated_methods?</tt> :: No equivalent
750
- +increment_counter+ :: <tt>Album.where(:id=>:id).update(:counter_name=>Sequel.+(:counter_name, 1))</tt>
751
- <tt>instance_method_already_implemented?</tt> :: No equivalent, Sequel does not create column accessors that override other methods, it just skips them.
752
- <tt>match_attribute_method?</tt> :: No equivalent
753
- +readonly_attributes+ :: No equivalent
754
- +remove_connection+ :: Not necessary in Sequel. If you want to disconnect an existing connection: <tt>Album.db.disconnect</tt>
755
- +require_mysql+ :: A public method, really?
756
- +silence+ :: No equivalent. Because the logger is handled at the <tt>Sequel::Database</tt> level, there is no thread-safe way to turn it off for specific blocks.
757
- +scopes+ :: No equivalent
758
- +sti_name+ :: No equivalent.
759
- +update_counters+ :: <tt>Album.where(:id=>:id).update(:counter_name=>Sequel.+(:counter_name, 1), :other_counter=>Sequel.-(:other_counter, 1))</tt>
760
- +uncached+ :: No equivalent
761
-
762
- === Instance Methods with Significantly Different Behavior
763
-
764
- ==== +attribute_names+
765
-
766
- +keys+ returns the columns as unsorted symbols, so:
767
-
768
- album.keys.map{|x| x.to_s}.sort
769
-
770
- ==== +becomes+
771
-
772
- Assuming the record already exists in the database:
773
-
774
- gold_album = GoldAlbum[1]
775
- album = Album.load(gold_album.values)
776
-
777
- If it is a new record:
778
-
779
- gold_album = GoldAlbum.new(:name=>'a')
780
- album = Album.new
781
- album.send(:set_values, gold_album.values)
782
-
783
- ==== +column_for_attribute+
784
-
785
- You can access this through the +db_schema+ hash:
786
-
787
- album.db_schema[:column]
788
-
789
- ==== +connection+
790
-
791
- Just like in the class method, you have to access it through the database:
792
-
793
- album.db.synchronize do |connection|
794
- end
795
-
796
- ==== +decrement+, +increment+
797
-
798
- You can just modify the values hash directly:
799
-
800
- album.values[:column] ||= 0
801
- album.values[:column] -= 1 # or += 1 for increment
802
-
803
- ==== <tt>decrement!</tt>, <tt>increment!</tt>
804
-
805
- Assuming you want the full behavior of saving just one column without validating:
806
-
807
- album.values[:column] ||= 0
808
- album.values[:column] -= 1 # or += 1 for increment!
809
- album.save(:columns=>[:column], :validate=>false)
810
-
811
- ==== <tt>has_attribute?</tt>
812
-
813
- You have to check the values hash:
814
-
815
- album.values.has_key?(:column)
816
-
817
- ==== <tt>invalid?</tt>
818
-
819
- You can use <tt>unless valid?</tt> or <tt>!valid?</tt>.
820
-
821
- ==== +save+, <tt>save!</tt>, +save_with_validation+, <tt>save_with_validation!</tt>
822
-
823
- Sequel defaults to raising exceptions when +save+ fails, but this is configurable behavior by setting the +raise_on_save_failure+ flag on the class or instance:
824
-
825
- album.raise_on_save_failure = true
826
- album.save # raise exception if failure
827
- album.raise_on_save_failure = false
828
- album.save # return nil if failure
829
-
830
- You can pass the <tt>:validate=>false</tt> option to not validate the object when saving.
831
-
832
- ==== +toggle+, <tt>toggle</tt>
833
-
834
- No equivalent, but very easy to add:
835
-
836
- album.column = !album.column
837
-
838
- If you want to save just that column:
839
-
840
- album.save(:columns=>[:column], :validate=>false)
841
-
842
- ==== +transaction+
843
-
844
- Just like in the class, you can access the transaction method through the +db+:
845
-
846
- album.db.transaction{}
847
-
848
- ==== +update_attribute+
849
-
850
- To only set and save a specific column:
851
-
852
- album.set(:column => value)
853
- album.save(:columns=>[:column], :validate=>false)
854
-
855
- ==== +update_attributes+, <tt>update_attributes!</tt>
856
-
857
- These would both use +update+, but see the notes on the +raise_on_save_failure+ flag:
858
-
859
- album.update(:column1=>value1, :column2=>value2)
860
-
861
- === Instance Methods with Roughly the Same Behavior
862
-
863
- Note that Sequel uses symbols almost everywhere to represent columns, while ActiveRecord often returns columns as strings.
864
-
865
- ActiveRecord Method :: Sequel Method
866
- <tt>==</tt> :: <tt>===</tt>, <tt>==</tt> compares by all values, not just id
867
- <tt>[]</tt> :: <tt>[]</tt>
868
- <tt>[]=</tt> :: <tt>[]=</tt>
869
- +after_create+ :: +after_create+
870
- +after_destroy+ :: +after_destroy+
871
- +after_save+ :: +after_save+
872
- +after_update+ :: +after_update+
873
- +after_validation+ :: +after_validation+
874
- +attributes+ :: +values+
875
- <tt>attributes=</tt> :: +set+
876
- +before_create+ :: +before_create+
877
- +before_destroy+ :: +before_destroy+
878
- +before_save+ :: +before_save+
879
- +before_update+ :: +before_update+
880
- +before_validation+ :: +before_validation+
881
- +cache_key+ :: +cache_key+, if using the +caching+ plugin
882
- +destroy+ :: +destroy+
883
- <tt>eql?</tt> :: <tt>===</tt>
884
- +errors+ :: +errors+
885
- +freeze+ :: +freeze+
886
- <tt>frozen?</tt> :: <tt>frozen?</tt>
887
- +hash+ :: +hash+
888
- +id+ :: +pk+
889
- +inspect+ :: +inspect+
890
- <tt>lock!</tt> :: <tt>lock!</tt>
891
- <tt>new_record?</tt> :: <tt>new?</tt>
892
- +reload_with_autosave_associations+ :: +reload+
893
- +to_param+ :: +to_param+, if using the +active_model+ plugin
894
- +touch+ :: +touch+, if using the +touch+ plugin
895
- <tt>valid?</tt> :: <tt>valid?</tt>
896
-
897
- === Instance Methods without an Equivalent
898
-
899
- ActiveRecord Method :: Notes, Workarounds
900
- +after_validation_on_create+, +after_validation_on_update+ :: Use +after_validation+ and <tt>if new?</tt> or <tt>unless new?</tt>
901
- +as_json+, +from_json+, +to_json+ :: Use the +json_serializer+ plugin
902
- +from_xml+, +to_xml+ :: Use the +xml_serializer+ plugin
903
- +attribute_for_inspect+ :: <tt>album[:column].inspect</tt>
904
- <tt>attribute_present?</tt> :: <tt>!album[:column].blank?</tt> if using the +blank+ extension
905
- +attributes_before_type_cast+ :: Sequel typecasts at a low level, so model objects never see values before they are type cast
906
- +before_validation_on_create+, +before_validation_on_update+ :: Use +before_validation+ and <tt>if new?</tt> or <tt>unless new?</tt>
907
- <tt>id=</tt> :: Sequel doesn't have a special primary key setter method, but you can use: <tt>album.send("#{Album.primary_key}=", value)</tt>
908
- +mark_for_destruction+, <tt>marked_for_destruction?</tt> :: Use a +before_save+ or +after_save+ hook or the +instance_hooks+ plugin
909
- <tt>readonly!</tt> :: No equivalent
910
- <tt>readonly?</tt> :: No equivalent
911
- <tt>rollback_active_record_state!</tt> :: No equivalent
912
- +with_transaction_returning_status+ :: No equivalent