sequel 4.36.0 → 5.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (760) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +548 -5749
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +265 -159
  5. data/bin/sequel +34 -12
  6. data/doc/advanced_associations.rdoc +228 -187
  7. data/doc/association_basics.rdoc +281 -291
  8. data/doc/bin_sequel.rdoc +5 -3
  9. data/doc/cheat_sheet.rdoc +86 -51
  10. data/doc/code_order.rdoc +25 -19
  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/fork_safety.rdoc +84 -0
  16. data/doc/mass_assignment.rdoc +74 -31
  17. data/doc/migration.rdoc +59 -51
  18. data/doc/model_dataset_method_design.rdoc +129 -0
  19. data/doc/model_hooks.rdoc +15 -25
  20. data/doc/model_plugins.rdoc +12 -12
  21. data/doc/mssql_stored_procedures.rdoc +3 -3
  22. data/doc/object_model.rdoc +58 -68
  23. data/doc/opening_databases.rdoc +85 -95
  24. data/doc/postgresql.rdoc +263 -38
  25. data/doc/prepared_statements.rdoc +29 -24
  26. data/doc/querying.rdoc +189 -167
  27. data/doc/reflection.rdoc +5 -6
  28. data/doc/release_notes/5.0.0.txt +159 -0
  29. data/doc/release_notes/5.1.0.txt +31 -0
  30. data/doc/release_notes/5.10.0.txt +84 -0
  31. data/doc/release_notes/5.11.0.txt +83 -0
  32. data/doc/release_notes/5.12.0.txt +141 -0
  33. data/doc/release_notes/5.13.0.txt +27 -0
  34. data/doc/release_notes/5.14.0.txt +63 -0
  35. data/doc/release_notes/5.15.0.txt +39 -0
  36. data/doc/release_notes/5.16.0.txt +110 -0
  37. data/doc/release_notes/5.17.0.txt +31 -0
  38. data/doc/release_notes/5.18.0.txt +69 -0
  39. data/doc/release_notes/5.19.0.txt +28 -0
  40. data/doc/release_notes/5.2.0.txt +33 -0
  41. data/doc/release_notes/5.20.0.txt +89 -0
  42. data/doc/release_notes/5.21.0.txt +87 -0
  43. data/doc/release_notes/5.22.0.txt +48 -0
  44. data/doc/release_notes/5.23.0.txt +56 -0
  45. data/doc/release_notes/5.24.0.txt +56 -0
  46. data/doc/release_notes/5.25.0.txt +32 -0
  47. data/doc/release_notes/5.26.0.txt +35 -0
  48. data/doc/release_notes/5.27.0.txt +21 -0
  49. data/doc/release_notes/5.28.0.txt +16 -0
  50. data/doc/release_notes/5.29.0.txt +22 -0
  51. data/doc/release_notes/5.3.0.txt +121 -0
  52. data/doc/release_notes/5.30.0.txt +20 -0
  53. data/doc/release_notes/5.31.0.txt +148 -0
  54. data/doc/release_notes/5.32.0.txt +46 -0
  55. data/doc/release_notes/5.33.0.txt +24 -0
  56. data/doc/release_notes/5.34.0.txt +40 -0
  57. data/doc/release_notes/5.35.0.txt +56 -0
  58. data/doc/release_notes/5.36.0.txt +60 -0
  59. data/doc/release_notes/5.37.0.txt +30 -0
  60. data/doc/release_notes/5.38.0.txt +28 -0
  61. data/doc/release_notes/5.39.0.txt +19 -0
  62. data/doc/release_notes/5.4.0.txt +80 -0
  63. data/doc/release_notes/5.40.0.txt +40 -0
  64. data/doc/release_notes/5.41.0.txt +25 -0
  65. data/doc/release_notes/5.42.0.txt +136 -0
  66. data/doc/release_notes/5.43.0.txt +98 -0
  67. data/doc/release_notes/5.44.0.txt +32 -0
  68. data/doc/release_notes/5.45.0.txt +34 -0
  69. data/doc/release_notes/5.46.0.txt +87 -0
  70. data/doc/release_notes/5.47.0.txt +59 -0
  71. data/doc/release_notes/5.48.0.txt +14 -0
  72. data/doc/release_notes/5.49.0.txt +59 -0
  73. data/doc/release_notes/5.5.0.txt +61 -0
  74. data/doc/release_notes/5.50.0.txt +78 -0
  75. data/doc/release_notes/5.51.0.txt +47 -0
  76. data/doc/release_notes/5.52.0.txt +87 -0
  77. data/doc/release_notes/5.53.0.txt +23 -0
  78. data/doc/release_notes/5.54.0.txt +27 -0
  79. data/doc/release_notes/5.55.0.txt +21 -0
  80. data/doc/release_notes/5.56.0.txt +51 -0
  81. data/doc/release_notes/5.57.0.txt +23 -0
  82. data/doc/release_notes/5.58.0.txt +31 -0
  83. data/doc/release_notes/5.59.0.txt +73 -0
  84. data/doc/release_notes/5.6.0.txt +31 -0
  85. data/doc/release_notes/5.60.0.txt +22 -0
  86. data/doc/release_notes/5.61.0.txt +43 -0
  87. data/doc/release_notes/5.7.0.txt +108 -0
  88. data/doc/release_notes/5.8.0.txt +170 -0
  89. data/doc/release_notes/5.9.0.txt +99 -0
  90. data/doc/schema_modification.rdoc +95 -75
  91. data/doc/security.rdoc +109 -80
  92. data/doc/sharding.rdoc +74 -47
  93. data/doc/sql.rdoc +147 -122
  94. data/doc/testing.rdoc +43 -20
  95. data/doc/thread_safety.rdoc +2 -4
  96. data/doc/transactions.rdoc +97 -18
  97. data/doc/validations.rdoc +52 -50
  98. data/doc/virtual_rows.rdoc +90 -109
  99. data/lib/sequel/adapters/ado/access.rb +15 -17
  100. data/lib/sequel/adapters/ado/mssql.rb +6 -15
  101. data/lib/sequel/adapters/ado.rb +150 -20
  102. data/lib/sequel/adapters/amalgalite.rb +11 -23
  103. data/lib/sequel/adapters/ibmdb.rb +47 -55
  104. data/lib/sequel/adapters/jdbc/db2.rb +29 -39
  105. data/lib/sequel/adapters/jdbc/derby.rb +58 -54
  106. data/lib/sequel/adapters/jdbc/h2.rb +93 -35
  107. data/lib/sequel/adapters/jdbc/hsqldb.rb +24 -31
  108. data/lib/sequel/adapters/jdbc/jtds.rb +2 -10
  109. data/lib/sequel/adapters/jdbc/mssql.rb +3 -11
  110. data/lib/sequel/adapters/jdbc/mysql.rb +17 -20
  111. data/lib/sequel/adapters/jdbc/oracle.rb +22 -18
  112. data/lib/sequel/adapters/jdbc/postgresql.rb +69 -71
  113. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +11 -23
  114. data/lib/sequel/adapters/jdbc/sqlite.rb +47 -11
  115. data/lib/sequel/adapters/jdbc/sqlserver.rb +34 -9
  116. data/lib/sequel/adapters/jdbc/transactions.rb +22 -38
  117. data/lib/sequel/adapters/jdbc.rb +145 -130
  118. data/lib/sequel/adapters/mock.rb +100 -111
  119. data/lib/sequel/adapters/mysql.rb +114 -122
  120. data/lib/sequel/adapters/mysql2.rb +147 -63
  121. data/lib/sequel/adapters/odbc/db2.rb +1 -1
  122. data/lib/sequel/adapters/odbc/mssql.rb +8 -14
  123. data/lib/sequel/adapters/odbc/oracle.rb +11 -0
  124. data/lib/sequel/adapters/odbc.rb +20 -25
  125. data/lib/sequel/adapters/oracle.rb +50 -56
  126. data/lib/sequel/adapters/postgres.rb +305 -327
  127. data/lib/sequel/adapters/postgresql.rb +1 -1
  128. data/lib/sequel/adapters/shared/access.rb +74 -78
  129. data/lib/sequel/adapters/shared/db2.rb +118 -71
  130. data/lib/sequel/adapters/shared/mssql.rb +301 -220
  131. data/lib/sequel/adapters/shared/mysql.rb +299 -217
  132. data/lib/sequel/adapters/shared/oracle.rb +226 -65
  133. data/lib/sequel/adapters/shared/postgres.rb +935 -395
  134. data/lib/sequel/adapters/shared/sqlanywhere.rb +105 -126
  135. data/lib/sequel/adapters/shared/sqlite.rb +447 -173
  136. data/lib/sequel/adapters/sqlanywhere.rb +48 -35
  137. data/lib/sequel/adapters/sqlite.rb +156 -111
  138. data/lib/sequel/adapters/tinytds.rb +30 -38
  139. data/lib/sequel/adapters/utils/columns_limit_1.rb +22 -0
  140. data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +3 -6
  141. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +2 -2
  142. data/lib/sequel/adapters/utils/mysql_mysql2.rb +87 -0
  143. data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +56 -0
  144. data/lib/sequel/adapters/utils/replace.rb +1 -4
  145. data/lib/sequel/adapters/utils/stored_procedures.rb +7 -22
  146. data/lib/sequel/adapters/utils/unmodified_identifiers.rb +28 -0
  147. data/lib/sequel/ast_transformer.rb +17 -89
  148. data/lib/sequel/connection_pool/sharded_single.rb +18 -15
  149. data/lib/sequel/connection_pool/sharded_threaded.rb +130 -111
  150. data/lib/sequel/connection_pool/single.rb +18 -13
  151. data/lib/sequel/connection_pool/threaded.rb +121 -120
  152. data/lib/sequel/connection_pool.rb +48 -29
  153. data/lib/sequel/core.rb +351 -301
  154. data/lib/sequel/database/connecting.rb +69 -57
  155. data/lib/sequel/database/dataset.rb +13 -5
  156. data/lib/sequel/database/dataset_defaults.rb +18 -102
  157. data/lib/sequel/database/features.rb +18 -4
  158. data/lib/sequel/database/logging.rb +12 -11
  159. data/lib/sequel/database/misc.rb +180 -122
  160. data/lib/sequel/database/query.rb +47 -27
  161. data/lib/sequel/database/schema_generator.rb +178 -84
  162. data/lib/sequel/database/schema_methods.rb +172 -97
  163. data/lib/sequel/database/transactions.rb +205 -44
  164. data/lib/sequel/database.rb +17 -2
  165. data/lib/sequel/dataset/actions.rb +339 -155
  166. data/lib/sequel/dataset/dataset_module.rb +46 -0
  167. data/lib/sequel/dataset/features.rb +90 -35
  168. data/lib/sequel/dataset/graph.rb +80 -58
  169. data/lib/sequel/dataset/misc.rb +137 -47
  170. data/lib/sequel/dataset/placeholder_literalizer.rb +63 -25
  171. data/lib/sequel/dataset/prepared_statements.rb +188 -85
  172. data/lib/sequel/dataset/query.rb +530 -222
  173. data/lib/sequel/dataset/sql.rb +590 -368
  174. data/lib/sequel/dataset.rb +26 -16
  175. data/lib/sequel/deprecated.rb +12 -2
  176. data/lib/sequel/exceptions.rb +46 -16
  177. data/lib/sequel/extensions/_model_constraint_validations.rb +16 -0
  178. data/lib/sequel/extensions/_model_pg_row.rb +43 -0
  179. data/lib/sequel/extensions/_pretty_table.rb +2 -5
  180. data/lib/sequel/extensions/any_not_empty.rb +45 -0
  181. data/lib/sequel/extensions/arbitrary_servers.rb +10 -10
  182. data/lib/sequel/extensions/async_thread_pool.rb +438 -0
  183. data/lib/sequel/extensions/auto_literal_strings.rb +74 -0
  184. data/lib/sequel/extensions/blank.rb +8 -0
  185. data/lib/sequel/extensions/caller_logging.rb +79 -0
  186. data/lib/sequel/extensions/columns_introspection.rb +4 -3
  187. data/lib/sequel/extensions/connection_expiration.rb +20 -10
  188. data/lib/sequel/extensions/connection_validator.rb +11 -10
  189. data/lib/sequel/extensions/constant_sql_override.rb +65 -0
  190. data/lib/sequel/extensions/constraint_validations.rb +62 -39
  191. data/lib/sequel/extensions/core_extensions.rb +42 -48
  192. data/lib/sequel/extensions/core_refinements.rb +80 -59
  193. data/lib/sequel/extensions/current_datetime_timestamp.rb +1 -4
  194. data/lib/sequel/extensions/date_arithmetic.rb +98 -39
  195. data/lib/sequel/extensions/date_parse_input_handler.rb +67 -0
  196. data/lib/sequel/extensions/datetime_parse_to_time.rb +41 -0
  197. data/lib/sequel/extensions/duplicate_columns_handler.rb +21 -14
  198. data/lib/sequel/extensions/empty_array_consider_nulls.rb +2 -2
  199. data/lib/sequel/extensions/escaped_like.rb +100 -0
  200. data/lib/sequel/extensions/eval_inspect.rb +12 -15
  201. data/lib/sequel/extensions/exclude_or_null.rb +68 -0
  202. data/lib/sequel/extensions/fiber_concurrency.rb +24 -0
  203. data/lib/sequel/extensions/freeze_datasets.rb +3 -0
  204. data/lib/sequel/extensions/from_block.rb +1 -34
  205. data/lib/sequel/extensions/graph_each.rb +4 -4
  206. data/lib/sequel/extensions/identifier_mangling.rb +180 -0
  207. data/lib/sequel/extensions/implicit_subquery.rb +48 -0
  208. data/lib/sequel/extensions/index_caching.rb +109 -0
  209. data/lib/sequel/extensions/inflector.rb +13 -5
  210. data/lib/sequel/extensions/integer64.rb +32 -0
  211. data/lib/sequel/extensions/is_distinct_from.rb +141 -0
  212. data/lib/sequel/extensions/looser_typecasting.rb +17 -8
  213. data/lib/sequel/extensions/migration.rb +119 -78
  214. data/lib/sequel/extensions/named_timezones.rb +88 -23
  215. data/lib/sequel/extensions/no_auto_literal_strings.rb +2 -82
  216. data/lib/sequel/extensions/null_dataset.rb +8 -8
  217. data/lib/sequel/extensions/pagination.rb +32 -29
  218. data/lib/sequel/extensions/pg_array.rb +221 -287
  219. data/lib/sequel/extensions/pg_array_ops.rb +17 -9
  220. data/lib/sequel/extensions/pg_enum.rb +63 -23
  221. data/lib/sequel/extensions/pg_extended_date_support.rb +241 -0
  222. data/lib/sequel/extensions/pg_hstore.rb +45 -54
  223. data/lib/sequel/extensions/pg_hstore_ops.rb +58 -6
  224. data/lib/sequel/extensions/pg_inet.rb +31 -12
  225. data/lib/sequel/extensions/pg_inet_ops.rb +2 -2
  226. data/lib/sequel/extensions/pg_interval.rb +56 -29
  227. data/lib/sequel/extensions/pg_json.rb +417 -140
  228. data/lib/sequel/extensions/pg_json_ops.rb +270 -18
  229. data/lib/sequel/extensions/pg_loose_count.rb +4 -2
  230. data/lib/sequel/extensions/pg_multirange.rb +372 -0
  231. data/lib/sequel/extensions/pg_range.rb +131 -191
  232. data/lib/sequel/extensions/pg_range_ops.rb +42 -13
  233. data/lib/sequel/extensions/pg_row.rb +48 -81
  234. data/lib/sequel/extensions/pg_row_ops.rb +33 -14
  235. data/lib/sequel/extensions/pg_static_cache_updater.rb +2 -2
  236. data/lib/sequel/extensions/pg_timestamptz.rb +28 -0
  237. data/lib/sequel/extensions/query.rb +9 -7
  238. data/lib/sequel/extensions/round_timestamps.rb +0 -6
  239. data/lib/sequel/extensions/run_transaction_hooks.rb +72 -0
  240. data/lib/sequel/extensions/s.rb +60 -0
  241. data/lib/sequel/extensions/schema_caching.rb +10 -1
  242. data/lib/sequel/extensions/schema_dumper.rb +71 -48
  243. data/lib/sequel/extensions/select_remove.rb +4 -4
  244. data/lib/sequel/extensions/sequel_4_dataset_methods.rb +85 -0
  245. data/lib/sequel/extensions/server_block.rb +51 -27
  246. data/lib/sequel/extensions/split_array_nil.rb +4 -4
  247. data/lib/sequel/extensions/sql_comments.rb +119 -7
  248. data/lib/sequel/extensions/sql_expr.rb +2 -1
  249. data/lib/sequel/extensions/sql_log_normalizer.rb +108 -0
  250. data/lib/sequel/extensions/sqlite_json_ops.rb +255 -0
  251. data/lib/sequel/extensions/string_agg.rb +11 -8
  252. data/lib/sequel/extensions/string_date_time.rb +19 -23
  253. data/lib/sequel/extensions/symbol_aref.rb +55 -0
  254. data/lib/sequel/extensions/symbol_aref_refinement.rb +43 -0
  255. data/lib/sequel/extensions/symbol_as.rb +23 -0
  256. data/lib/sequel/extensions/symbol_as_refinement.rb +37 -0
  257. data/lib/sequel/extensions/synchronize_sql.rb +45 -0
  258. data/lib/sequel/extensions/to_dot.rb +10 -4
  259. data/lib/sequel/extensions/virtual_row_method_block.rb +44 -0
  260. data/lib/sequel/model/associations.rb +1006 -284
  261. data/lib/sequel/model/base.rb +560 -805
  262. data/lib/sequel/model/dataset_module.rb +11 -10
  263. data/lib/sequel/model/default_inflections.rb +1 -1
  264. data/lib/sequel/model/errors.rb +10 -3
  265. data/lib/sequel/model/exceptions.rb +8 -10
  266. data/lib/sequel/model/inflections.rb +7 -20
  267. data/lib/sequel/model/plugins.rb +114 -0
  268. data/lib/sequel/model.rb +32 -82
  269. data/lib/sequel/plugins/active_model.rb +30 -14
  270. data/lib/sequel/plugins/after_initialize.rb +1 -1
  271. data/lib/sequel/plugins/association_dependencies.rb +25 -18
  272. data/lib/sequel/plugins/association_lazy_eager_option.rb +66 -0
  273. data/lib/sequel/plugins/association_multi_add_remove.rb +85 -0
  274. data/lib/sequel/plugins/association_pks.rb +147 -70
  275. data/lib/sequel/plugins/association_proxies.rb +33 -9
  276. data/lib/sequel/plugins/async_thread_pool.rb +39 -0
  277. data/lib/sequel/plugins/auto_restrict_eager_graph.rb +62 -0
  278. data/lib/sequel/plugins/auto_validations.rb +95 -28
  279. data/lib/sequel/plugins/auto_validations_constraint_validations_presence_message.rb +68 -0
  280. data/lib/sequel/plugins/before_after_save.rb +0 -42
  281. data/lib/sequel/plugins/blacklist_security.rb +21 -12
  282. data/lib/sequel/plugins/boolean_readers.rb +5 -5
  283. data/lib/sequel/plugins/boolean_subsets.rb +13 -8
  284. data/lib/sequel/plugins/caching.rb +25 -16
  285. data/lib/sequel/plugins/class_table_inheritance.rb +179 -100
  286. data/lib/sequel/plugins/column_conflicts.rb +16 -3
  287. data/lib/sequel/plugins/column_encryption.rb +728 -0
  288. data/lib/sequel/plugins/column_select.rb +7 -5
  289. data/lib/sequel/plugins/columns_updated.rb +42 -0
  290. data/lib/sequel/plugins/composition.rb +42 -26
  291. data/lib/sequel/plugins/concurrent_eager_loading.rb +174 -0
  292. data/lib/sequel/plugins/constraint_validations.rb +20 -14
  293. data/lib/sequel/plugins/csv_serializer.rb +56 -35
  294. data/lib/sequel/plugins/dataset_associations.rb +40 -17
  295. data/lib/sequel/plugins/def_dataset_method.rb +90 -0
  296. data/lib/sequel/plugins/defaults_setter.rb +65 -10
  297. data/lib/sequel/plugins/delay_add_association.rb +1 -1
  298. data/lib/sequel/plugins/dirty.rb +62 -24
  299. data/lib/sequel/plugins/eager_each.rb +3 -3
  300. data/lib/sequel/plugins/eager_graph_eager.rb +139 -0
  301. data/lib/sequel/plugins/empty_failure_backtraces.rb +38 -0
  302. data/lib/sequel/plugins/enum.rb +124 -0
  303. data/lib/sequel/plugins/error_splitter.rb +17 -12
  304. data/lib/sequel/plugins/finder.rb +246 -0
  305. data/lib/sequel/plugins/forbid_lazy_load.rb +216 -0
  306. data/lib/sequel/plugins/force_encoding.rb +7 -12
  307. data/lib/sequel/plugins/hook_class_methods.rb +37 -54
  308. data/lib/sequel/plugins/input_transformer.rb +18 -10
  309. data/lib/sequel/plugins/insert_conflict.rb +76 -0
  310. data/lib/sequel/plugins/insert_returning_select.rb +2 -2
  311. data/lib/sequel/plugins/instance_filters.rb +10 -8
  312. data/lib/sequel/plugins/instance_hooks.rb +34 -17
  313. data/lib/sequel/plugins/instance_specific_default.rb +113 -0
  314. data/lib/sequel/plugins/inverted_subsets.rb +22 -13
  315. data/lib/sequel/plugins/json_serializer.rb +124 -64
  316. data/lib/sequel/plugins/lazy_attributes.rb +21 -14
  317. data/lib/sequel/plugins/list.rb +35 -21
  318. data/lib/sequel/plugins/many_through_many.rb +134 -21
  319. data/lib/sequel/plugins/modification_detection.rb +15 -5
  320. data/lib/sequel/plugins/mssql_optimistic_locking.rb +6 -5
  321. data/lib/sequel/plugins/nested_attributes.rb +61 -31
  322. data/lib/sequel/plugins/optimistic_locking.rb +3 -3
  323. data/lib/sequel/plugins/pg_array_associations.rb +103 -53
  324. data/lib/sequel/plugins/pg_auto_constraint_validations.rb +350 -0
  325. data/lib/sequel/plugins/pg_row.rb +5 -51
  326. data/lib/sequel/plugins/prepared_statements.rb +60 -72
  327. data/lib/sequel/plugins/prepared_statements_safe.rb +9 -4
  328. data/lib/sequel/plugins/rcte_tree.rb +68 -82
  329. data/lib/sequel/plugins/require_valid_schema.rb +67 -0
  330. data/lib/sequel/plugins/serialization.rb +43 -46
  331. data/lib/sequel/plugins/serialization_modification_detection.rb +3 -2
  332. data/lib/sequel/plugins/sharding.rb +15 -10
  333. data/lib/sequel/plugins/single_table_inheritance.rb +67 -28
  334. data/lib/sequel/plugins/skip_create_refresh.rb +3 -3
  335. data/lib/sequel/plugins/skip_saving_columns.rb +108 -0
  336. data/lib/sequel/plugins/split_values.rb +11 -6
  337. data/lib/sequel/plugins/sql_comments.rb +189 -0
  338. data/lib/sequel/plugins/static_cache.rb +77 -53
  339. data/lib/sequel/plugins/static_cache_cache.rb +53 -0
  340. data/lib/sequel/plugins/string_stripper.rb +3 -3
  341. data/lib/sequel/plugins/subclasses.rb +43 -10
  342. data/lib/sequel/plugins/subset_conditions.rb +15 -5
  343. data/lib/sequel/plugins/table_select.rb +2 -2
  344. data/lib/sequel/plugins/tactical_eager_loading.rb +96 -12
  345. data/lib/sequel/plugins/throw_failures.rb +110 -0
  346. data/lib/sequel/plugins/timestamps.rb +20 -8
  347. data/lib/sequel/plugins/touch.rb +19 -8
  348. data/lib/sequel/plugins/tree.rb +62 -32
  349. data/lib/sequel/plugins/typecast_on_load.rb +12 -4
  350. data/lib/sequel/plugins/unlimited_update.rb +1 -7
  351. data/lib/sequel/plugins/unused_associations.rb +521 -0
  352. data/lib/sequel/plugins/update_or_create.rb +4 -4
  353. data/lib/sequel/plugins/update_primary_key.rb +1 -1
  354. data/lib/sequel/plugins/update_refresh.rb +26 -15
  355. data/lib/sequel/plugins/uuid.rb +7 -11
  356. data/lib/sequel/plugins/validate_associated.rb +18 -0
  357. data/lib/sequel/plugins/validation_class_methods.rb +38 -19
  358. data/lib/sequel/plugins/validation_contexts.rb +49 -0
  359. data/lib/sequel/plugins/validation_helpers.rb +57 -41
  360. data/lib/sequel/plugins/whitelist_security.rb +122 -0
  361. data/lib/sequel/plugins/xml_serializer.rb +30 -31
  362. data/lib/sequel/sql.rb +471 -331
  363. data/lib/sequel/timezones.rb +78 -47
  364. data/lib/sequel/version.rb +7 -2
  365. data/lib/sequel.rb +1 -1
  366. metadata +217 -521
  367. data/Rakefile +0 -164
  368. data/doc/active_record.rdoc +0 -928
  369. data/doc/release_notes/1.0.txt +0 -38
  370. data/doc/release_notes/1.1.txt +0 -143
  371. data/doc/release_notes/1.3.txt +0 -101
  372. data/doc/release_notes/1.4.0.txt +0 -53
  373. data/doc/release_notes/1.5.0.txt +0 -155
  374. data/doc/release_notes/2.0.0.txt +0 -298
  375. data/doc/release_notes/2.1.0.txt +0 -271
  376. data/doc/release_notes/2.10.0.txt +0 -328
  377. data/doc/release_notes/2.11.0.txt +0 -215
  378. data/doc/release_notes/2.12.0.txt +0 -534
  379. data/doc/release_notes/2.2.0.txt +0 -253
  380. data/doc/release_notes/2.3.0.txt +0 -88
  381. data/doc/release_notes/2.4.0.txt +0 -106
  382. data/doc/release_notes/2.5.0.txt +0 -137
  383. data/doc/release_notes/2.6.0.txt +0 -157
  384. data/doc/release_notes/2.7.0.txt +0 -166
  385. data/doc/release_notes/2.8.0.txt +0 -171
  386. data/doc/release_notes/2.9.0.txt +0 -97
  387. data/doc/release_notes/3.0.0.txt +0 -221
  388. data/doc/release_notes/3.1.0.txt +0 -406
  389. data/doc/release_notes/3.10.0.txt +0 -286
  390. data/doc/release_notes/3.11.0.txt +0 -254
  391. data/doc/release_notes/3.12.0.txt +0 -304
  392. data/doc/release_notes/3.13.0.txt +0 -210
  393. data/doc/release_notes/3.14.0.txt +0 -118
  394. data/doc/release_notes/3.15.0.txt +0 -78
  395. data/doc/release_notes/3.16.0.txt +0 -45
  396. data/doc/release_notes/3.17.0.txt +0 -58
  397. data/doc/release_notes/3.18.0.txt +0 -120
  398. data/doc/release_notes/3.19.0.txt +0 -67
  399. data/doc/release_notes/3.2.0.txt +0 -268
  400. data/doc/release_notes/3.20.0.txt +0 -41
  401. data/doc/release_notes/3.21.0.txt +0 -87
  402. data/doc/release_notes/3.22.0.txt +0 -39
  403. data/doc/release_notes/3.23.0.txt +0 -172
  404. data/doc/release_notes/3.24.0.txt +0 -420
  405. data/doc/release_notes/3.25.0.txt +0 -88
  406. data/doc/release_notes/3.26.0.txt +0 -88
  407. data/doc/release_notes/3.27.0.txt +0 -82
  408. data/doc/release_notes/3.28.0.txt +0 -304
  409. data/doc/release_notes/3.29.0.txt +0 -459
  410. data/doc/release_notes/3.3.0.txt +0 -192
  411. data/doc/release_notes/3.30.0.txt +0 -135
  412. data/doc/release_notes/3.31.0.txt +0 -146
  413. data/doc/release_notes/3.32.0.txt +0 -202
  414. data/doc/release_notes/3.33.0.txt +0 -157
  415. data/doc/release_notes/3.34.0.txt +0 -671
  416. data/doc/release_notes/3.35.0.txt +0 -144
  417. data/doc/release_notes/3.36.0.txt +0 -245
  418. data/doc/release_notes/3.37.0.txt +0 -338
  419. data/doc/release_notes/3.38.0.txt +0 -234
  420. data/doc/release_notes/3.39.0.txt +0 -237
  421. data/doc/release_notes/3.4.0.txt +0 -325
  422. data/doc/release_notes/3.40.0.txt +0 -73
  423. data/doc/release_notes/3.41.0.txt +0 -155
  424. data/doc/release_notes/3.42.0.txt +0 -74
  425. data/doc/release_notes/3.43.0.txt +0 -105
  426. data/doc/release_notes/3.44.0.txt +0 -152
  427. data/doc/release_notes/3.45.0.txt +0 -179
  428. data/doc/release_notes/3.46.0.txt +0 -122
  429. data/doc/release_notes/3.47.0.txt +0 -270
  430. data/doc/release_notes/3.48.0.txt +0 -477
  431. data/doc/release_notes/3.5.0.txt +0 -510
  432. data/doc/release_notes/3.6.0.txt +0 -366
  433. data/doc/release_notes/3.7.0.txt +0 -179
  434. data/doc/release_notes/3.8.0.txt +0 -151
  435. data/doc/release_notes/3.9.0.txt +0 -233
  436. data/doc/release_notes/4.0.0.txt +0 -262
  437. data/doc/release_notes/4.1.0.txt +0 -85
  438. data/doc/release_notes/4.10.0.txt +0 -226
  439. data/doc/release_notes/4.11.0.txt +0 -147
  440. data/doc/release_notes/4.12.0.txt +0 -105
  441. data/doc/release_notes/4.13.0.txt +0 -169
  442. data/doc/release_notes/4.14.0.txt +0 -68
  443. data/doc/release_notes/4.15.0.txt +0 -56
  444. data/doc/release_notes/4.16.0.txt +0 -36
  445. data/doc/release_notes/4.17.0.txt +0 -38
  446. data/doc/release_notes/4.18.0.txt +0 -36
  447. data/doc/release_notes/4.19.0.txt +0 -45
  448. data/doc/release_notes/4.2.0.txt +0 -129
  449. data/doc/release_notes/4.20.0.txt +0 -79
  450. data/doc/release_notes/4.21.0.txt +0 -94
  451. data/doc/release_notes/4.22.0.txt +0 -72
  452. data/doc/release_notes/4.23.0.txt +0 -65
  453. data/doc/release_notes/4.24.0.txt +0 -99
  454. data/doc/release_notes/4.25.0.txt +0 -181
  455. data/doc/release_notes/4.26.0.txt +0 -44
  456. data/doc/release_notes/4.27.0.txt +0 -78
  457. data/doc/release_notes/4.28.0.txt +0 -57
  458. data/doc/release_notes/4.29.0.txt +0 -41
  459. data/doc/release_notes/4.3.0.txt +0 -40
  460. data/doc/release_notes/4.30.0.txt +0 -37
  461. data/doc/release_notes/4.31.0.txt +0 -57
  462. data/doc/release_notes/4.32.0.txt +0 -132
  463. data/doc/release_notes/4.33.0.txt +0 -88
  464. data/doc/release_notes/4.34.0.txt +0 -86
  465. data/doc/release_notes/4.35.0.txt +0 -130
  466. data/doc/release_notes/4.36.0.txt +0 -116
  467. data/doc/release_notes/4.4.0.txt +0 -92
  468. data/doc/release_notes/4.5.0.txt +0 -34
  469. data/doc/release_notes/4.6.0.txt +0 -30
  470. data/doc/release_notes/4.7.0.txt +0 -103
  471. data/doc/release_notes/4.8.0.txt +0 -175
  472. data/doc/release_notes/4.9.0.txt +0 -190
  473. data/lib/sequel/adapters/cubrid.rb +0 -144
  474. data/lib/sequel/adapters/do/mysql.rb +0 -66
  475. data/lib/sequel/adapters/do/postgres.rb +0 -44
  476. data/lib/sequel/adapters/do/sqlite3.rb +0 -42
  477. data/lib/sequel/adapters/do.rb +0 -158
  478. data/lib/sequel/adapters/jdbc/as400.rb +0 -84
  479. data/lib/sequel/adapters/jdbc/cubrid.rb +0 -64
  480. data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -36
  481. data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -33
  482. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -33
  483. data/lib/sequel/adapters/odbc/progress.rb +0 -10
  484. data/lib/sequel/adapters/shared/cubrid.rb +0 -245
  485. data/lib/sequel/adapters/shared/firebird.rb +0 -247
  486. data/lib/sequel/adapters/shared/informix.rb +0 -54
  487. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +0 -152
  488. data/lib/sequel/adapters/shared/progress.rb +0 -40
  489. data/lib/sequel/adapters/swift/mysql.rb +0 -49
  490. data/lib/sequel/adapters/swift/postgres.rb +0 -47
  491. data/lib/sequel/adapters/swift/sqlite.rb +0 -49
  492. data/lib/sequel/adapters/swift.rb +0 -160
  493. data/lib/sequel/adapters/utils/pg_types.rb +0 -70
  494. data/lib/sequel/dataset/mutation.rb +0 -111
  495. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +0 -5
  496. data/lib/sequel/extensions/filter_having.rb +0 -63
  497. data/lib/sequel/extensions/hash_aliases.rb +0 -49
  498. data/lib/sequel/extensions/meta_def.rb +0 -35
  499. data/lib/sequel/extensions/query_literals.rb +0 -84
  500. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +0 -24
  501. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +0 -122
  502. data/lib/sequel/extensions/set_overrides.rb +0 -76
  503. data/lib/sequel/no_core_ext.rb +0 -3
  504. data/lib/sequel/plugins/association_autoreloading.rb +0 -9
  505. data/lib/sequel/plugins/identifier_columns.rb +0 -47
  506. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +0 -9
  507. data/lib/sequel/plugins/pg_typecast_on_load.rb +0 -81
  508. data/lib/sequel/plugins/prepared_statements_associations.rb +0 -119
  509. data/lib/sequel/plugins/prepared_statements_with_pk.rb +0 -61
  510. data/lib/sequel/plugins/schema.rb +0 -82
  511. data/lib/sequel/plugins/scissors.rb +0 -35
  512. data/spec/adapter_spec.rb +0 -4
  513. data/spec/adapters/db2_spec.rb +0 -160
  514. data/spec/adapters/firebird_spec.rb +0 -411
  515. data/spec/adapters/informix_spec.rb +0 -100
  516. data/spec/adapters/mssql_spec.rb +0 -733
  517. data/spec/adapters/mysql_spec.rb +0 -1319
  518. data/spec/adapters/oracle_spec.rb +0 -313
  519. data/spec/adapters/postgres_spec.rb +0 -3790
  520. data/spec/adapters/spec_helper.rb +0 -49
  521. data/spec/adapters/sqlanywhere_spec.rb +0 -170
  522. data/spec/adapters/sqlite_spec.rb +0 -688
  523. data/spec/bin_spec.rb +0 -258
  524. data/spec/core/connection_pool_spec.rb +0 -1045
  525. data/spec/core/database_spec.rb +0 -2636
  526. data/spec/core/dataset_spec.rb +0 -5175
  527. data/spec/core/deprecated_spec.rb +0 -70
  528. data/spec/core/expression_filters_spec.rb +0 -1247
  529. data/spec/core/mock_adapter_spec.rb +0 -464
  530. data/spec/core/object_graph_spec.rb +0 -303
  531. data/spec/core/placeholder_literalizer_spec.rb +0 -163
  532. data/spec/core/schema_generator_spec.rb +0 -203
  533. data/spec/core/schema_spec.rb +0 -1676
  534. data/spec/core/spec_helper.rb +0 -34
  535. data/spec/core/version_spec.rb +0 -7
  536. data/spec/core_extensions_spec.rb +0 -699
  537. data/spec/core_model_spec.rb +0 -2
  538. data/spec/core_spec.rb +0 -1
  539. data/spec/extensions/accessed_columns_spec.rb +0 -51
  540. data/spec/extensions/active_model_spec.rb +0 -85
  541. data/spec/extensions/after_initialize_spec.rb +0 -24
  542. data/spec/extensions/arbitrary_servers_spec.rb +0 -109
  543. data/spec/extensions/association_dependencies_spec.rb +0 -117
  544. data/spec/extensions/association_pks_spec.rb +0 -405
  545. data/spec/extensions/association_proxies_spec.rb +0 -86
  546. data/spec/extensions/auto_validations_spec.rb +0 -192
  547. data/spec/extensions/before_after_save_spec.rb +0 -40
  548. data/spec/extensions/blacklist_security_spec.rb +0 -88
  549. data/spec/extensions/blank_spec.rb +0 -69
  550. data/spec/extensions/boolean_readers_spec.rb +0 -93
  551. data/spec/extensions/boolean_subsets_spec.rb +0 -47
  552. data/spec/extensions/caching_spec.rb +0 -270
  553. data/spec/extensions/class_table_inheritance_spec.rb +0 -444
  554. data/spec/extensions/column_conflicts_spec.rb +0 -60
  555. data/spec/extensions/column_select_spec.rb +0 -108
  556. data/spec/extensions/columns_introspection_spec.rb +0 -91
  557. data/spec/extensions/composition_spec.rb +0 -242
  558. data/spec/extensions/connection_expiration_spec.rb +0 -121
  559. data/spec/extensions/connection_validator_spec.rb +0 -127
  560. data/spec/extensions/constraint_validations_plugin_spec.rb +0 -288
  561. data/spec/extensions/constraint_validations_spec.rb +0 -389
  562. data/spec/extensions/core_refinements_spec.rb +0 -519
  563. data/spec/extensions/csv_serializer_spec.rb +0 -180
  564. data/spec/extensions/current_datetime_timestamp_spec.rb +0 -27
  565. data/spec/extensions/dataset_associations_spec.rb +0 -343
  566. data/spec/extensions/dataset_source_alias_spec.rb +0 -51
  567. data/spec/extensions/date_arithmetic_spec.rb +0 -167
  568. data/spec/extensions/defaults_setter_spec.rb +0 -102
  569. data/spec/extensions/delay_add_association_spec.rb +0 -74
  570. data/spec/extensions/dirty_spec.rb +0 -180
  571. data/spec/extensions/duplicate_columns_handler_spec.rb +0 -110
  572. data/spec/extensions/eager_each_spec.rb +0 -66
  573. data/spec/extensions/empty_array_consider_nulls_spec.rb +0 -24
  574. data/spec/extensions/error_splitter_spec.rb +0 -18
  575. data/spec/extensions/error_sql_spec.rb +0 -20
  576. data/spec/extensions/eval_inspect_spec.rb +0 -73
  577. data/spec/extensions/filter_having_spec.rb +0 -40
  578. data/spec/extensions/force_encoding_spec.rb +0 -114
  579. data/spec/extensions/from_block_spec.rb +0 -21
  580. data/spec/extensions/graph_each_spec.rb +0 -119
  581. data/spec/extensions/hash_aliases_spec.rb +0 -24
  582. data/spec/extensions/hook_class_methods_spec.rb +0 -429
  583. data/spec/extensions/identifier_columns_spec.rb +0 -17
  584. data/spec/extensions/inflector_spec.rb +0 -183
  585. data/spec/extensions/input_transformer_spec.rb +0 -54
  586. data/spec/extensions/insert_returning_select_spec.rb +0 -46
  587. data/spec/extensions/instance_filters_spec.rb +0 -79
  588. data/spec/extensions/instance_hooks_spec.rb +0 -276
  589. data/spec/extensions/inverted_subsets_spec.rb +0 -33
  590. data/spec/extensions/json_serializer_spec.rb +0 -304
  591. data/spec/extensions/lazy_attributes_spec.rb +0 -170
  592. data/spec/extensions/list_spec.rb +0 -278
  593. data/spec/extensions/looser_typecasting_spec.rb +0 -43
  594. data/spec/extensions/many_through_many_spec.rb +0 -2172
  595. data/spec/extensions/meta_def_spec.rb +0 -21
  596. data/spec/extensions/migration_spec.rb +0 -728
  597. data/spec/extensions/modification_detection_spec.rb +0 -80
  598. data/spec/extensions/mssql_optimistic_locking_spec.rb +0 -91
  599. data/spec/extensions/named_timezones_spec.rb +0 -108
  600. data/spec/extensions/nested_attributes_spec.rb +0 -697
  601. data/spec/extensions/no_auto_literal_strings_spec.rb +0 -65
  602. data/spec/extensions/null_dataset_spec.rb +0 -85
  603. data/spec/extensions/optimistic_locking_spec.rb +0 -128
  604. data/spec/extensions/pagination_spec.rb +0 -118
  605. data/spec/extensions/pg_array_associations_spec.rb +0 -736
  606. data/spec/extensions/pg_array_ops_spec.rb +0 -143
  607. data/spec/extensions/pg_array_spec.rb +0 -390
  608. data/spec/extensions/pg_enum_spec.rb +0 -92
  609. data/spec/extensions/pg_hstore_ops_spec.rb +0 -236
  610. data/spec/extensions/pg_hstore_spec.rb +0 -206
  611. data/spec/extensions/pg_inet_ops_spec.rb +0 -101
  612. data/spec/extensions/pg_inet_spec.rb +0 -52
  613. data/spec/extensions/pg_interval_spec.rb +0 -76
  614. data/spec/extensions/pg_json_ops_spec.rb +0 -275
  615. data/spec/extensions/pg_json_spec.rb +0 -218
  616. data/spec/extensions/pg_loose_count_spec.rb +0 -17
  617. data/spec/extensions/pg_range_ops_spec.rb +0 -58
  618. data/spec/extensions/pg_range_spec.rb +0 -473
  619. data/spec/extensions/pg_row_ops_spec.rb +0 -60
  620. data/spec/extensions/pg_row_plugin_spec.rb +0 -62
  621. data/spec/extensions/pg_row_spec.rb +0 -360
  622. data/spec/extensions/pg_static_cache_updater_spec.rb +0 -92
  623. data/spec/extensions/pg_typecast_on_load_spec.rb +0 -63
  624. data/spec/extensions/prepared_statements_associations_spec.rb +0 -159
  625. data/spec/extensions/prepared_statements_safe_spec.rb +0 -61
  626. data/spec/extensions/prepared_statements_spec.rb +0 -103
  627. data/spec/extensions/prepared_statements_with_pk_spec.rb +0 -31
  628. data/spec/extensions/pretty_table_spec.rb +0 -92
  629. data/spec/extensions/query_literals_spec.rb +0 -183
  630. data/spec/extensions/query_spec.rb +0 -102
  631. data/spec/extensions/rcte_tree_spec.rb +0 -392
  632. data/spec/extensions/round_timestamps_spec.rb +0 -43
  633. data/spec/extensions/schema_caching_spec.rb +0 -41
  634. data/spec/extensions/schema_dumper_spec.rb +0 -814
  635. data/spec/extensions/schema_spec.rb +0 -117
  636. data/spec/extensions/scissors_spec.rb +0 -26
  637. data/spec/extensions/select_remove_spec.rb +0 -38
  638. data/spec/extensions/sequel_3_dataset_methods_spec.rb +0 -101
  639. data/spec/extensions/serialization_modification_detection_spec.rb +0 -98
  640. data/spec/extensions/serialization_spec.rb +0 -362
  641. data/spec/extensions/server_block_spec.rb +0 -90
  642. data/spec/extensions/server_logging_spec.rb +0 -45
  643. data/spec/extensions/set_overrides_spec.rb +0 -61
  644. data/spec/extensions/sharding_spec.rb +0 -198
  645. data/spec/extensions/shared_caching_spec.rb +0 -175
  646. data/spec/extensions/single_table_inheritance_spec.rb +0 -297
  647. data/spec/extensions/singular_table_names_spec.rb +0 -22
  648. data/spec/extensions/skip_create_refresh_spec.rb +0 -17
  649. data/spec/extensions/spec_helper.rb +0 -71
  650. data/spec/extensions/split_array_nil_spec.rb +0 -24
  651. data/spec/extensions/split_values_spec.rb +0 -22
  652. data/spec/extensions/sql_comments_spec.rb +0 -27
  653. data/spec/extensions/sql_expr_spec.rb +0 -60
  654. data/spec/extensions/static_cache_spec.rb +0 -361
  655. data/spec/extensions/string_agg_spec.rb +0 -85
  656. data/spec/extensions/string_date_time_spec.rb +0 -95
  657. data/spec/extensions/string_stripper_spec.rb +0 -68
  658. data/spec/extensions/subclasses_spec.rb +0 -66
  659. data/spec/extensions/subset_conditions_spec.rb +0 -38
  660. data/spec/extensions/table_select_spec.rb +0 -71
  661. data/spec/extensions/tactical_eager_loading_spec.rb +0 -136
  662. data/spec/extensions/thread_local_timezones_spec.rb +0 -67
  663. data/spec/extensions/timestamps_spec.rb +0 -175
  664. data/spec/extensions/to_dot_spec.rb +0 -154
  665. data/spec/extensions/touch_spec.rb +0 -203
  666. data/spec/extensions/tree_spec.rb +0 -274
  667. data/spec/extensions/typecast_on_load_spec.rb +0 -80
  668. data/spec/extensions/unlimited_update_spec.rb +0 -20
  669. data/spec/extensions/update_or_create_spec.rb +0 -87
  670. data/spec/extensions/update_primary_key_spec.rb +0 -100
  671. data/spec/extensions/update_refresh_spec.rb +0 -53
  672. data/spec/extensions/uuid_spec.rb +0 -106
  673. data/spec/extensions/validate_associated_spec.rb +0 -52
  674. data/spec/extensions/validation_class_methods_spec.rb +0 -1027
  675. data/spec/extensions/validation_helpers_spec.rb +0 -554
  676. data/spec/extensions/xml_serializer_spec.rb +0 -207
  677. data/spec/files/bad_down_migration/001_create_alt_basic.rb +0 -4
  678. data/spec/files/bad_down_migration/002_create_alt_advanced.rb +0 -4
  679. data/spec/files/bad_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  680. data/spec/files/bad_timestamped_migrations/1273253851_create_nodes.rb +0 -9
  681. data/spec/files/bad_timestamped_migrations/1273253853_3_create_users.rb +0 -3
  682. data/spec/files/bad_up_migration/001_create_alt_basic.rb +0 -4
  683. data/spec/files/bad_up_migration/002_create_alt_advanced.rb +0 -3
  684. data/spec/files/convert_to_timestamp_migrations/001_create_sessions.rb +0 -9
  685. data/spec/files/convert_to_timestamp_migrations/002_create_nodes.rb +0 -9
  686. data/spec/files/convert_to_timestamp_migrations/003_3_create_users.rb +0 -4
  687. data/spec/files/convert_to_timestamp_migrations/1273253850_create_artists.rb +0 -9
  688. data/spec/files/convert_to_timestamp_migrations/1273253852_create_albums.rb +0 -9
  689. data/spec/files/double_migration/001_create_sessions.rb +0 -9
  690. data/spec/files/double_migration/002_create_nodes.rb +0 -19
  691. data/spec/files/double_migration/003_3_create_users.rb +0 -4
  692. data/spec/files/duplicate_integer_migrations/001_create_alt_advanced.rb +0 -4
  693. data/spec/files/duplicate_integer_migrations/001_create_alt_basic.rb +0 -4
  694. data/spec/files/duplicate_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  695. data/spec/files/duplicate_timestamped_migrations/1273253853_create_nodes.rb +0 -9
  696. data/spec/files/duplicate_timestamped_migrations/1273253853_create_users.rb +0 -4
  697. data/spec/files/empty_migration/001_create_sessions.rb +0 -9
  698. data/spec/files/empty_migration/002_create_nodes.rb +0 -0
  699. data/spec/files/empty_migration/003_3_create_users.rb +0 -4
  700. data/spec/files/integer_migrations/001_create_sessions.rb +0 -9
  701. data/spec/files/integer_migrations/002_create_nodes.rb +0 -9
  702. data/spec/files/integer_migrations/003_3_create_users.rb +0 -4
  703. data/spec/files/interleaved_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  704. data/spec/files/interleaved_timestamped_migrations/1273253850_create_artists.rb +0 -9
  705. data/spec/files/interleaved_timestamped_migrations/1273253851_create_nodes.rb +0 -9
  706. data/spec/files/interleaved_timestamped_migrations/1273253852_create_albums.rb +0 -9
  707. data/spec/files/interleaved_timestamped_migrations/1273253853_3_create_users.rb +0 -4
  708. data/spec/files/missing_integer_migrations/001_create_alt_basic.rb +0 -4
  709. data/spec/files/missing_integer_migrations/003_create_alt_advanced.rb +0 -4
  710. data/spec/files/missing_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  711. data/spec/files/missing_timestamped_migrations/1273253853_3_create_users.rb +0 -4
  712. data/spec/files/reversible_migrations/001_reversible.rb +0 -5
  713. data/spec/files/reversible_migrations/002_reversible.rb +0 -5
  714. data/spec/files/reversible_migrations/003_reversible.rb +0 -5
  715. data/spec/files/reversible_migrations/004_reversible.rb +0 -5
  716. data/spec/files/reversible_migrations/005_reversible.rb +0 -10
  717. data/spec/files/reversible_migrations/006_reversible.rb +0 -10
  718. data/spec/files/reversible_migrations/007_reversible.rb +0 -10
  719. data/spec/files/timestamped_migrations/1273253849_create_sessions.rb +0 -9
  720. data/spec/files/timestamped_migrations/1273253851_create_nodes.rb +0 -9
  721. data/spec/files/timestamped_migrations/1273253853_3_create_users.rb +0 -4
  722. data/spec/files/transaction_specified_migrations/001_create_alt_basic.rb +0 -4
  723. data/spec/files/transaction_specified_migrations/002_create_basic.rb +0 -4
  724. data/spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb +0 -3
  725. data/spec/files/transaction_unspecified_migrations/002_create_basic.rb +0 -3
  726. data/spec/files/uppercase_timestamped_migrations/1273253849_CREATE_SESSIONS.RB +0 -9
  727. data/spec/files/uppercase_timestamped_migrations/1273253851_CREATE_NODES.RB +0 -9
  728. data/spec/files/uppercase_timestamped_migrations/1273253853_3_CREATE_USERS.RB +0 -4
  729. data/spec/guards_helper.rb +0 -55
  730. data/spec/integration/associations_test.rb +0 -2506
  731. data/spec/integration/database_test.rb +0 -113
  732. data/spec/integration/dataset_test.rb +0 -1858
  733. data/spec/integration/eager_loader_test.rb +0 -687
  734. data/spec/integration/migrator_test.rb +0 -262
  735. data/spec/integration/model_test.rb +0 -230
  736. data/spec/integration/plugin_test.rb +0 -2297
  737. data/spec/integration/prepared_statement_test.rb +0 -467
  738. data/spec/integration/schema_test.rb +0 -815
  739. data/spec/integration/spec_helper.rb +0 -56
  740. data/spec/integration/timezone_test.rb +0 -86
  741. data/spec/integration/transaction_test.rb +0 -406
  742. data/spec/integration/type_test.rb +0 -133
  743. data/spec/model/association_reflection_spec.rb +0 -565
  744. data/spec/model/associations_spec.rb +0 -4589
  745. data/spec/model/base_spec.rb +0 -759
  746. data/spec/model/class_dataset_methods_spec.rb +0 -150
  747. data/spec/model/dataset_methods_spec.rb +0 -149
  748. data/spec/model/eager_loading_spec.rb +0 -2197
  749. data/spec/model/hooks_spec.rb +0 -604
  750. data/spec/model/inflector_spec.rb +0 -26
  751. data/spec/model/model_spec.rb +0 -1097
  752. data/spec/model/plugins_spec.rb +0 -299
  753. data/spec/model/record_spec.rb +0 -2162
  754. data/spec/model/spec_helper.rb +0 -46
  755. data/spec/model/validations_spec.rb +0 -193
  756. data/spec/model_no_assoc_spec.rb +0 -1
  757. data/spec/model_spec.rb +0 -1
  758. data/spec/plugin_spec.rb +0 -1
  759. data/spec/sequel_coverage.rb +0 -15
  760. data/spec/spec_config.rb +0 -10
@@ -1,928 +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
- === +none+
630
-
631
- If you want to return an empty dataset, but still preserve chaining, you can use the +null_dataset+ extension:
632
-
633
- DB.extension(:null_dataset)
634
-
635
- class User < Sequel::Model
636
- def self.nullify
637
- dataset.nullify
638
- end
639
- end
640
-
641
- user = User.create(name: 'John Doe')
642
- User.nullify.where(name: 'John Doe').all
643
- # => []
644
-
645
- ==== +reset_column_information+
646
-
647
- If you want to completely reload the schema for the table:
648
-
649
- Album.instance_variable_set(:@db_schema, nil)
650
- Album.send(:get_db_schema, true)
651
-
652
- ==== +serialize+, +seralized_attributes+
653
-
654
- Sequel ships with a +serialization+ plugin that you can use.
655
-
656
- class Album < Sequel::Model
657
- plugin :serialization, :json, :permissions
658
- end
659
-
660
- 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.
661
-
662
- ==== +set_inheritance_column+
663
-
664
- This is something that must be specified when you are loading the +single_table_inheritance+ plugin:
665
-
666
- class Album < Sequel::Model
667
- plugin :single_table_inheritance, :column
668
- end
669
-
670
- ==== +set_sequence_name+
671
-
672
- 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:
673
-
674
- class Album < Sequel::Model(ORACLE_DB[:albums].sequence('albums_seq'))
675
- end
676
-
677
- ==== <tt>table_exists?</tt>
678
-
679
- This is a <tt>Sequel::Database</tt> method:
680
-
681
- Album.db.table_exists?(Album.table_name)
682
-
683
- With the +schema+ plugin, you can use it directly:
684
-
685
- Album.plugin :schema
686
- Album.table_exists?
687
-
688
- ==== +transaction+
689
-
690
- As mentioned earlier, +transaction+ is a database method in Sequel, which you can access via the +db+ method:
691
-
692
- Album.db.transaction{}
693
-
694
- ==== +update+, +update_all+
695
-
696
- Just like +delete+ and +destroy+, you filter first, then +update+:
697
-
698
- Album.where(:id=>id).update(:name=>'RF')
699
- Album.where("artist_id = ?", 5).update(:copies_sold=>0)
700
-
701
- Likewise, to update all rows in the model:
702
-
703
- Album.dataset.update(:name=>'RF')
704
-
705
- 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:
706
-
707
- Album[id].update(:name=>'RF')
708
- Album.where("artist_id = ?", 5).all{|a| a.update(:copies_sold=>0)}
709
-
710
- ==== +with_scope+
711
-
712
- 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.
713
-
714
- === Class Methods with Roughly the Same Behavior
715
-
716
- Note that Sequel uses symbols almost everywhere to represent columns, while ActiveRecord often returns columns as strings.
717
-
718
- ActiveRecord Method :: Sequel Method
719
- +attr_accessible+ :: +set_allowed_columns+
720
- +attr_protected+ :: +set_restricted_columns+
721
- +average+ :: +avg+
722
- +belongs_to+ :: +many_to_one+
723
- +columns_hash+ :: +db_schema+
724
- +count+ :: +count+
725
- +changed+ :: +changed_columns+
726
- +create+ :: +create+
727
- +has_and_belongs_to_many+ :: +many_to_many+
728
- +has_one+ :: +one_to_one+
729
- +has_many+ :: +one_to_many+
730
- +inheritance_column+ :: +sti_key+
731
- +inspect+ :: +inspect+
732
- +maximum+ :: +max+
733
- +minimum+ :: +min+
734
- +new+ :: +new+
735
- +primary_key+ :: +primary_key+
736
- <tt>respond_to?</tt> :: <tt>respond_to?</tt>
737
- +set_primary_key+ :: +set_primary_key+
738
- +sum+ :: +sum+
739
- +table_name+ :: +table_name+
740
- +unscoped+ :: +unfiltered+
741
-
742
- === Class Methods without an Equivalent
743
-
744
- ActiveRecord Method :: Notes, Workarounds
745
- +accepts_nested_attributes_for+ :: Use the +nested_attributes+ plugin
746
- +attr_readonly+ :: Don't update the columns (duh!), or add a before_update hook that deletes them from the values hash
747
- +attribute_method_suffix+ :: No equivalent
748
- +alias_attribute_with_dirty+ :: No equivalent
749
- +base_class+ :: Not needed internally, you can probably use <tt>sti_dataset.model</tt> if you are using single table inheritance
750
- +benchmark+ :: Just use the +benchmark+ library from ruby's stdlib
751
- +calculate+ :: No direct equivalent, just build the query manually and execute it
752
- +cache+ :: No equivalent
753
- <tt>cache_attribute?</tt> :: No equivalent
754
- +cache_attributes+ :: No equivalent
755
- +cached_attributes+ :: No equivalent
756
- <tt>changed?</tt> :: <tt>changed_columns.include?(column)</tt>
757
- +changes+ :: No equivalent
758
- <tt>clear_active_connections!</tt> :: Sequel doesn't leak connections like ActiveRecord, so you don't need to worry about this
759
- <tt>clear_reloadable_connections!</tt> :: Sequel doesn't leak connections like ActiveRecord, so you don't need to worry about this
760
- +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>
761
- +decrement_counter+ :: <tt>Album.where(:id=>:id).update(:counter_name=>Sequel.-(:counter_name, 1))</tt>
762
- +define_attribute_methods+, +define_read_methods+ :: <tt>def_column_accessor(*columns)</tt>, a private method
763
- <tt>descends_from_active_record?</tt> :: Not needed internally, if using single table inheritance, <tt>Album.sti_dataset.model == Album</tt>
764
- +find_each+, +find_in_batches+ :: Use the +pagination+ extension
765
- <tt>generated_methods?</tt> :: No equivalent
766
- +increment_counter+ :: <tt>Album.where(:id=>:id).update(:counter_name=>Sequel.+(:counter_name, 1))</tt>
767
- <tt>instance_method_already_implemented?</tt> :: No equivalent, Sequel does not create column accessors that override other methods, it just skips them.
768
- <tt>match_attribute_method?</tt> :: No equivalent
769
- +readonly_attributes+ :: No equivalent
770
- +remove_connection+ :: Not necessary in Sequel. If you want to disconnect an existing connection: <tt>Album.db.disconnect</tt>
771
- +require_mysql+ :: A public method, really?
772
- +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.
773
- +scopes+ :: No equivalent
774
- +sti_name+ :: No equivalent.
775
- +update_counters+ :: <tt>Album.where(:id=>:id).update(:counter_name=>Sequel.+(:counter_name, 1), :other_counter=>Sequel.-(:other_counter, 1))</tt>
776
- +uncached+ :: No equivalent
777
-
778
- === Instance Methods with Significantly Different Behavior
779
-
780
- ==== +attribute_names+
781
-
782
- +keys+ returns the columns as unsorted symbols, so:
783
-
784
- album.keys.map{|x| x.to_s}.sort
785
-
786
- ==== +becomes+
787
-
788
- Assuming the record already exists in the database:
789
-
790
- gold_album = GoldAlbum[1]
791
- album = Album.load(gold_album.values)
792
-
793
- If it is a new record:
794
-
795
- gold_album = GoldAlbum.new(:name=>'a')
796
- album = Album.new
797
- album.send(:set_values, gold_album.values)
798
-
799
- ==== +column_for_attribute+
800
-
801
- You can access this through the +db_schema+ hash:
802
-
803
- album.db_schema[:column]
804
-
805
- ==== +connection+
806
-
807
- Just like in the class method, you have to access it through the database:
808
-
809
- album.db.synchronize do |connection|
810
- end
811
-
812
- ==== +decrement+, +increment+
813
-
814
- You can just modify the values hash directly:
815
-
816
- album.values[:column] ||= 0
817
- album.values[:column] -= 1 # or += 1 for increment
818
-
819
- ==== <tt>decrement!</tt>, <tt>increment!</tt>
820
-
821
- Assuming you want the full behavior of saving just one column without validating:
822
-
823
- album.values[:column] ||= 0
824
- album.values[:column] -= 1 # or += 1 for increment!
825
- album.save(:columns=>[:column], :validate=>false)
826
-
827
- ==== <tt>has_attribute?</tt>
828
-
829
- You have to check the values hash:
830
-
831
- album.values.has_key?(:column)
832
-
833
- ==== <tt>invalid?</tt>
834
-
835
- You can use <tt>unless valid?</tt> or <tt>!valid?</tt>.
836
-
837
- ==== +save+, <tt>save!</tt>, +save_with_validation+, <tt>save_with_validation!</tt>
838
-
839
- 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:
840
-
841
- album.raise_on_save_failure = true
842
- album.save # raise exception if failure
843
- album.raise_on_save_failure = false
844
- album.save # return nil if failure
845
-
846
- You can pass the <tt>:validate=>false</tt> option to not validate the object when saving.
847
-
848
- ==== +toggle+, <tt>toggle</tt>
849
-
850
- No equivalent, but very easy to add:
851
-
852
- album.column = !album.column
853
-
854
- If you want to save just that column:
855
-
856
- album.save(:columns=>[:column], :validate=>false)
857
-
858
- ==== +transaction+
859
-
860
- Just like in the class, you can access the transaction method through the +db+:
861
-
862
- album.db.transaction{}
863
-
864
- ==== +update_attribute+
865
-
866
- To only set and save a specific column:
867
-
868
- album.set(:column => value)
869
- album.save(:columns=>[:column], :validate=>false)
870
-
871
- ==== +update_attributes+, <tt>update_attributes!</tt>
872
-
873
- These would both use +update+, but see the notes on the +raise_on_save_failure+ flag:
874
-
875
- album.update(:column1=>value1, :column2=>value2)
876
-
877
- === Instance Methods with Roughly the Same Behavior
878
-
879
- Note that Sequel uses symbols almost everywhere to represent columns, while ActiveRecord often returns columns as strings.
880
-
881
- ActiveRecord Method :: Sequel Method
882
- <tt>==</tt> :: <tt>===</tt>, <tt>==</tt> compares by all values, not just id
883
- <tt>[]</tt> :: <tt>[]</tt>
884
- <tt>[]=</tt> :: <tt>[]=</tt>
885
- +after_create+ :: +after_create+
886
- +after_destroy+ :: +after_destroy+
887
- +after_save+ :: +after_save+
888
- +after_update+ :: +after_update+
889
- +after_validation+ :: +after_validation+
890
- +attributes+ :: +values+
891
- <tt>attributes=</tt> :: +set+
892
- +before_create+ :: +before_create+
893
- +before_destroy+ :: +before_destroy+
894
- +before_save+ :: +before_save+
895
- +before_update+ :: +before_update+
896
- +before_validation+ :: +before_validation+
897
- +cache_key+ :: +cache_key+, if using the +caching+ plugin
898
- +destroy+ :: +destroy+
899
- <tt>eql?</tt> :: <tt>===</tt>
900
- +errors+ :: +errors+
901
- +freeze+ :: +freeze+
902
- <tt>frozen?</tt> :: <tt>frozen?</tt>
903
- +hash+ :: +hash+
904
- +id+ :: +pk+
905
- +inspect+ :: +inspect+
906
- <tt>lock!</tt> :: <tt>lock!</tt>
907
- <tt>new_record?</tt> :: <tt>new?</tt>
908
- +reload_with_autosave_associations+ :: +reload+
909
- +to_param+ :: +to_param+, if using the +active_model+ plugin
910
- +touch+ :: +touch+, if using the +touch+ plugin
911
- <tt>valid?</tt> :: <tt>valid?</tt>
912
-
913
- === Instance Methods without an Equivalent
914
-
915
- ActiveRecord Method :: Notes, Workarounds
916
- +after_validation_on_create+, +after_validation_on_update+ :: Use +after_validation+ and <tt>if new?</tt> or <tt>unless new?</tt>
917
- +as_json+, +from_json+, +to_json+ :: Use the +json_serializer+ plugin
918
- +from_xml+, +to_xml+ :: Use the +xml_serializer+ plugin
919
- +attribute_for_inspect+ :: <tt>album[:column].inspect</tt>
920
- <tt>attribute_present?</tt> :: <tt>!album[:column].blank?</tt> if using the +blank+ extension
921
- +attributes_before_type_cast+ :: Sequel typecasts at a low level, so model objects never see values before they are type cast
922
- +before_validation_on_create+, +before_validation_on_update+ :: Use +before_validation+ and <tt>if new?</tt> or <tt>unless new?</tt>
923
- <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>
924
- +mark_for_destruction+, <tt>marked_for_destruction?</tt> :: Use a +before_save+ or +after_save+ hook or the +instance_hooks+ plugin
925
- <tt>readonly!</tt> :: No equivalent
926
- <tt>readonly?</tt> :: No equivalent
927
- <tt>rollback_active_record_state!</tt> :: No equivalent
928
- +with_transaction_returning_status+ :: No equivalent