sequel 4.49.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (477) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +70 -0
  3. data/README.rdoc +195 -136
  4. data/Rakefile +26 -42
  5. data/bin/sequel +3 -5
  6. data/doc/advanced_associations.rdoc +86 -163
  7. data/doc/association_basics.rdoc +197 -274
  8. data/doc/bin_sequel.rdoc +5 -3
  9. data/doc/cheat_sheet.rdoc +66 -43
  10. data/doc/code_order.rdoc +1 -8
  11. data/doc/core_extensions.rdoc +81 -56
  12. data/doc/dataset_basics.rdoc +8 -17
  13. data/doc/dataset_filtering.rdoc +81 -86
  14. data/doc/extensions.rdoc +3 -10
  15. data/doc/mass_assignment.rdoc +73 -30
  16. data/doc/migration.rdoc +19 -36
  17. data/doc/model_dataset_method_design.rdoc +14 -17
  18. data/doc/model_hooks.rdoc +15 -25
  19. data/doc/model_plugins.rdoc +10 -10
  20. data/doc/mssql_stored_procedures.rdoc +3 -3
  21. data/doc/object_model.rdoc +52 -70
  22. data/doc/opening_databases.rdoc +39 -32
  23. data/doc/postgresql.rdoc +48 -38
  24. data/doc/prepared_statements.rdoc +27 -22
  25. data/doc/querying.rdoc +173 -150
  26. data/doc/reflection.rdoc +5 -6
  27. data/doc/release_notes/5.0.0.txt +159 -0
  28. data/doc/schema_modification.rdoc +63 -60
  29. data/doc/security.rdoc +97 -88
  30. data/doc/sharding.rdoc +43 -30
  31. data/doc/sql.rdoc +53 -65
  32. data/doc/testing.rdoc +3 -5
  33. data/doc/thread_safety.rdoc +2 -4
  34. data/doc/transactions.rdoc +18 -17
  35. data/doc/validations.rdoc +48 -45
  36. data/doc/virtual_rows.rdoc +87 -115
  37. data/lib/sequel.rb +1 -1
  38. data/lib/sequel/adapters/ado.rb +9 -25
  39. data/lib/sequel/adapters/ado/access.rb +7 -13
  40. data/lib/sequel/adapters/ado/mssql.rb +2 -9
  41. data/lib/sequel/adapters/amalgalite.rb +3 -18
  42. data/lib/sequel/adapters/ibmdb.rb +9 -45
  43. data/lib/sequel/adapters/jdbc.rb +13 -73
  44. data/lib/sequel/adapters/jdbc/db2.rb +8 -37
  45. data/lib/sequel/adapters/jdbc/derby.rb +4 -50
  46. data/lib/sequel/adapters/jdbc/h2.rb +4 -25
  47. data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -26
  48. data/lib/sequel/adapters/jdbc/jtds.rb +2 -9
  49. data/lib/sequel/adapters/jdbc/mssql.rb +1 -11
  50. data/lib/sequel/adapters/jdbc/mysql.rb +1 -15
  51. data/lib/sequel/adapters/jdbc/oracle.rb +4 -26
  52. data/lib/sequel/adapters/jdbc/postgresql.rb +2 -31
  53. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +4 -17
  54. data/lib/sequel/adapters/jdbc/sqlite.rb +1 -7
  55. data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -13
  56. data/lib/sequel/adapters/jdbc/transactions.rb +1 -14
  57. data/lib/sequel/adapters/mock.rb +4 -30
  58. data/lib/sequel/adapters/mysql.rb +7 -44
  59. data/lib/sequel/adapters/mysql2.rb +5 -23
  60. data/lib/sequel/adapters/odbc.rb +0 -19
  61. data/lib/sequel/adapters/odbc/db2.rb +1 -1
  62. data/lib/sequel/adapters/odbc/mssql.rb +4 -12
  63. data/lib/sequel/adapters/odbc/oracle.rb +1 -1
  64. data/lib/sequel/adapters/oracle.rb +7 -13
  65. data/lib/sequel/adapters/postgres.rb +13 -57
  66. data/lib/sequel/adapters/postgresql.rb +1 -1
  67. data/lib/sequel/adapters/shared/access.rb +11 -51
  68. data/lib/sequel/adapters/shared/db2.rb +3 -61
  69. data/lib/sequel/adapters/shared/mssql.rb +21 -157
  70. data/lib/sequel/adapters/shared/mysql.rb +23 -224
  71. data/lib/sequel/adapters/shared/oracle.rb +13 -41
  72. data/lib/sequel/adapters/shared/postgres.rb +44 -259
  73. data/lib/sequel/adapters/shared/sqlanywhere.rb +4 -96
  74. data/lib/sequel/adapters/shared/sqlite.rb +12 -101
  75. data/lib/sequel/adapters/sqlanywhere.rb +4 -23
  76. data/lib/sequel/adapters/sqlite.rb +2 -19
  77. data/lib/sequel/adapters/tinytds.rb +5 -15
  78. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +1 -1
  79. data/lib/sequel/adapters/utils/mysql_mysql2.rb +2 -4
  80. data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +3 -6
  81. data/lib/sequel/adapters/utils/replace.rb +0 -5
  82. data/lib/sequel/adapters/utils/stored_procedures.rb +0 -2
  83. data/lib/sequel/adapters/utils/unmodified_identifiers.rb +2 -0
  84. data/lib/sequel/ast_transformer.rb +3 -94
  85. data/lib/sequel/connection_pool.rb +26 -28
  86. data/lib/sequel/connection_pool/sharded_single.rb +1 -4
  87. data/lib/sequel/connection_pool/sharded_threaded.rb +97 -95
  88. data/lib/sequel/connection_pool/single.rb +0 -2
  89. data/lib/sequel/connection_pool/threaded.rb +94 -110
  90. data/lib/sequel/core.rb +42 -101
  91. data/lib/sequel/database.rb +12 -2
  92. data/lib/sequel/database/connecting.rb +23 -60
  93. data/lib/sequel/database/dataset.rb +6 -9
  94. data/lib/sequel/database/dataset_defaults.rb +4 -48
  95. data/lib/sequel/database/features.rb +5 -4
  96. data/lib/sequel/database/logging.rb +2 -9
  97. data/lib/sequel/database/misc.rb +23 -55
  98. data/lib/sequel/database/query.rb +8 -13
  99. data/lib/sequel/database/schema_generator.rb +89 -64
  100. data/lib/sequel/database/schema_methods.rb +61 -79
  101. data/lib/sequel/database/transactions.rb +4 -24
  102. data/lib/sequel/dataset.rb +18 -10
  103. data/lib/sequel/dataset/actions.rb +53 -107
  104. data/lib/sequel/dataset/dataset_module.rb +3 -15
  105. data/lib/sequel/dataset/features.rb +30 -30
  106. data/lib/sequel/dataset/graph.rb +40 -49
  107. data/lib/sequel/dataset/misc.rb +12 -37
  108. data/lib/sequel/dataset/placeholder_literalizer.rb +4 -4
  109. data/lib/sequel/dataset/prepared_statements.rb +23 -51
  110. data/lib/sequel/dataset/query.rb +71 -155
  111. data/lib/sequel/dataset/sql.rb +30 -225
  112. data/lib/sequel/deprecated.rb +18 -27
  113. data/lib/sequel/exceptions.rb +1 -17
  114. data/lib/sequel/extensions/_model_pg_row.rb +0 -7
  115. data/lib/sequel/extensions/_pretty_table.rb +1 -3
  116. data/lib/sequel/extensions/arbitrary_servers.rb +10 -10
  117. data/lib/sequel/extensions/connection_expiration.rb +1 -1
  118. data/lib/sequel/extensions/connection_validator.rb +1 -1
  119. data/lib/sequel/extensions/constraint_validations.rb +11 -11
  120. data/lib/sequel/extensions/core_extensions.rb +39 -49
  121. data/lib/sequel/extensions/core_refinements.rb +39 -45
  122. data/lib/sequel/extensions/current_datetime_timestamp.rb +0 -4
  123. data/lib/sequel/extensions/date_arithmetic.rb +7 -7
  124. data/lib/sequel/extensions/duplicate_columns_handler.rb +12 -9
  125. data/lib/sequel/extensions/empty_array_consider_nulls.rb +2 -2
  126. data/lib/sequel/extensions/eval_inspect.rb +4 -11
  127. data/lib/sequel/extensions/freeze_datasets.rb +1 -69
  128. data/lib/sequel/extensions/from_block.rb +1 -35
  129. data/lib/sequel/extensions/graph_each.rb +2 -2
  130. data/lib/sequel/extensions/identifier_mangling.rb +9 -19
  131. data/lib/sequel/extensions/implicit_subquery.rb +2 -2
  132. data/lib/sequel/extensions/inflector.rb +4 -4
  133. data/lib/sequel/extensions/migration.rb +23 -40
  134. data/lib/sequel/extensions/no_auto_literal_strings.rb +2 -84
  135. data/lib/sequel/extensions/null_dataset.rb +2 -8
  136. data/lib/sequel/extensions/pagination.rb +1 -17
  137. data/lib/sequel/extensions/pg_array.rb +20 -189
  138. data/lib/sequel/extensions/pg_hstore.rb +11 -50
  139. data/lib/sequel/extensions/pg_hstore_ops.rb +2 -2
  140. data/lib/sequel/extensions/pg_inet.rb +2 -15
  141. data/lib/sequel/extensions/pg_interval.rb +1 -20
  142. data/lib/sequel/extensions/pg_json.rb +7 -27
  143. data/lib/sequel/extensions/pg_loose_count.rb +1 -1
  144. data/lib/sequel/extensions/pg_range.rb +6 -121
  145. data/lib/sequel/extensions/pg_range_ops.rb +1 -3
  146. data/lib/sequel/extensions/pg_row.rb +5 -77
  147. data/lib/sequel/extensions/pg_row_ops.rb +2 -13
  148. data/lib/sequel/extensions/query.rb +3 -4
  149. data/lib/sequel/extensions/round_timestamps.rb +0 -6
  150. data/lib/sequel/extensions/schema_dumper.rb +13 -13
  151. data/lib/sequel/extensions/select_remove.rb +3 -3
  152. data/lib/sequel/extensions/split_array_nil.rb +2 -2
  153. data/lib/sequel/extensions/sql_comments.rb +2 -2
  154. data/lib/sequel/extensions/string_agg.rb +11 -8
  155. data/lib/sequel/extensions/symbol_aref.rb +6 -20
  156. data/lib/sequel/model.rb +27 -62
  157. data/lib/sequel/model/associations.rb +128 -131
  158. data/lib/sequel/model/base.rb +171 -711
  159. data/lib/sequel/model/default_inflections.rb +1 -1
  160. data/lib/sequel/model/errors.rb +0 -3
  161. data/lib/sequel/model/exceptions.rb +2 -6
  162. data/lib/sequel/model/inflections.rb +1 -26
  163. data/lib/sequel/model/plugins.rb +1 -0
  164. data/lib/sequel/plugins/active_model.rb +2 -5
  165. data/lib/sequel/plugins/association_dependencies.rb +15 -15
  166. data/lib/sequel/plugins/association_pks.rb +14 -28
  167. data/lib/sequel/plugins/association_proxies.rb +6 -7
  168. data/lib/sequel/plugins/auto_validations.rb +4 -4
  169. data/lib/sequel/plugins/before_after_save.rb +0 -43
  170. data/lib/sequel/plugins/blacklist_security.rb +9 -8
  171. data/lib/sequel/plugins/boolean_readers.rb +3 -3
  172. data/lib/sequel/plugins/boolean_subsets.rb +2 -2
  173. data/lib/sequel/plugins/caching.rb +5 -5
  174. data/lib/sequel/plugins/class_table_inheritance.rb +71 -102
  175. data/lib/sequel/plugins/column_conflicts.rb +2 -2
  176. data/lib/sequel/plugins/column_select.rb +2 -2
  177. data/lib/sequel/plugins/composition.rb +15 -24
  178. data/lib/sequel/plugins/constraint_validations.rb +4 -3
  179. data/lib/sequel/plugins/csv_serializer.rb +13 -20
  180. data/lib/sequel/plugins/dataset_associations.rb +2 -2
  181. data/lib/sequel/plugins/def_dataset_method.rb +5 -5
  182. data/lib/sequel/plugins/defaults_setter.rb +1 -1
  183. data/lib/sequel/plugins/delay_add_association.rb +1 -1
  184. data/lib/sequel/plugins/finder.rb +16 -10
  185. data/lib/sequel/plugins/force_encoding.rb +1 -7
  186. data/lib/sequel/plugins/hook_class_methods.rb +4 -106
  187. data/lib/sequel/plugins/input_transformer.rb +10 -11
  188. data/lib/sequel/plugins/insert_returning_select.rb +1 -9
  189. data/lib/sequel/plugins/instance_filters.rb +5 -5
  190. data/lib/sequel/plugins/instance_hooks.rb +7 -52
  191. data/lib/sequel/plugins/inverted_subsets.rb +3 -1
  192. data/lib/sequel/plugins/json_serializer.rb +19 -19
  193. data/lib/sequel/plugins/lazy_attributes.rb +1 -10
  194. data/lib/sequel/plugins/list.rb +6 -6
  195. data/lib/sequel/plugins/many_through_many.rb +11 -8
  196. data/lib/sequel/plugins/mssql_optimistic_locking.rb +3 -3
  197. data/lib/sequel/plugins/nested_attributes.rb +18 -31
  198. data/lib/sequel/plugins/optimistic_locking.rb +3 -3
  199. data/lib/sequel/plugins/pg_array_associations.rb +8 -2
  200. data/lib/sequel/plugins/pg_row.rb +2 -11
  201. data/lib/sequel/plugins/prepared_statements.rb +13 -66
  202. data/lib/sequel/plugins/prepared_statements_safe.rb +1 -1
  203. data/lib/sequel/plugins/rcte_tree.rb +7 -7
  204. data/lib/sequel/plugins/serialization.rb +15 -33
  205. data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
  206. data/lib/sequel/plugins/sharding.rb +2 -8
  207. data/lib/sequel/plugins/single_table_inheritance.rb +10 -13
  208. data/lib/sequel/plugins/skip_create_refresh.rb +3 -3
  209. data/lib/sequel/plugins/static_cache.rb +8 -9
  210. data/lib/sequel/plugins/string_stripper.rb +3 -3
  211. data/lib/sequel/plugins/subclasses.rb +1 -1
  212. data/lib/sequel/plugins/subset_conditions.rb +2 -2
  213. data/lib/sequel/plugins/table_select.rb +2 -2
  214. data/lib/sequel/plugins/tactical_eager_loading.rb +4 -4
  215. data/lib/sequel/plugins/timestamps.rb +6 -7
  216. data/lib/sequel/plugins/touch.rb +4 -8
  217. data/lib/sequel/plugins/tree.rb +3 -3
  218. data/lib/sequel/plugins/typecast_on_load.rb +2 -2
  219. data/lib/sequel/plugins/unlimited_update.rb +1 -7
  220. data/lib/sequel/plugins/update_or_create.rb +3 -3
  221. data/lib/sequel/plugins/update_refresh.rb +3 -3
  222. data/lib/sequel/plugins/uuid.rb +7 -11
  223. data/lib/sequel/plugins/validation_class_methods.rb +10 -9
  224. data/lib/sequel/plugins/validation_contexts.rb +4 -4
  225. data/lib/sequel/plugins/validation_helpers.rb +26 -25
  226. data/lib/sequel/plugins/whitelist_security.rb +13 -9
  227. data/lib/sequel/plugins/xml_serializer.rb +24 -25
  228. data/lib/sequel/sql.rb +145 -276
  229. data/lib/sequel/timezones.rb +8 -22
  230. data/lib/sequel/version.rb +2 -2
  231. data/spec/adapter_spec.rb +1 -1
  232. data/spec/adapters/db2_spec.rb +2 -103
  233. data/spec/adapters/mssql_spec.rb +89 -68
  234. data/spec/adapters/mysql_spec.rb +101 -480
  235. data/spec/adapters/oracle_spec.rb +1 -9
  236. data/spec/adapters/postgres_spec.rb +312 -565
  237. data/spec/adapters/spec_helper.rb +12 -31
  238. data/spec/adapters/sqlanywhere_spec.rb +2 -77
  239. data/spec/adapters/sqlite_spec.rb +8 -146
  240. data/spec/bin_spec.rb +11 -16
  241. data/spec/core/connection_pool_spec.rb +173 -74
  242. data/spec/core/database_spec.rb +64 -244
  243. data/spec/core/dataset_spec.rb +81 -415
  244. data/spec/core/deprecated_spec.rb +3 -3
  245. data/spec/core/expression_filters_spec.rb +37 -144
  246. data/spec/core/mock_adapter_spec.rb +176 -4
  247. data/spec/core/object_graph_spec.rb +11 -60
  248. data/spec/core/placeholder_literalizer_spec.rb +1 -14
  249. data/spec/core/schema_generator_spec.rb +51 -40
  250. data/spec/core/schema_spec.rb +74 -77
  251. data/spec/core/spec_helper.rb +6 -24
  252. data/spec/core/version_spec.rb +1 -1
  253. data/spec/core_extensions_spec.rb +7 -83
  254. data/spec/core_model_spec.rb +2 -2
  255. data/spec/deprecation_helper.rb +2 -14
  256. data/spec/extensions/accessed_columns_spec.rb +1 -1
  257. data/spec/extensions/active_model_spec.rb +3 -3
  258. data/spec/extensions/after_initialize_spec.rb +1 -1
  259. data/spec/extensions/arbitrary_servers_spec.rb +2 -2
  260. data/spec/extensions/association_dependencies_spec.rb +1 -1
  261. data/spec/extensions/association_pks_spec.rb +4 -59
  262. data/spec/extensions/association_proxies_spec.rb +1 -1
  263. data/spec/extensions/auto_literal_strings_spec.rb +1 -12
  264. data/spec/extensions/auto_validations_spec.rb +1 -1
  265. data/spec/extensions/blacklist_security_spec.rb +1 -1
  266. data/spec/extensions/blank_spec.rb +1 -1
  267. data/spec/extensions/boolean_readers_spec.rb +1 -1
  268. data/spec/extensions/boolean_subsets_spec.rb +1 -1
  269. data/spec/extensions/caching_spec.rb +1 -1
  270. data/spec/extensions/class_table_inheritance_spec.rb +35 -1086
  271. data/spec/extensions/column_conflicts_spec.rb +1 -1
  272. data/spec/extensions/column_select_spec.rb +4 -4
  273. data/spec/extensions/columns_introspection_spec.rb +1 -1
  274. data/spec/extensions/columns_updated_spec.rb +1 -1
  275. data/spec/extensions/composition_spec.rb +1 -7
  276. data/spec/extensions/connection_expiration_spec.rb +3 -3
  277. data/spec/extensions/connection_validator_spec.rb +3 -3
  278. data/spec/extensions/constraint_validations_plugin_spec.rb +1 -1
  279. data/spec/extensions/constraint_validations_spec.rb +1 -1
  280. data/spec/extensions/core_refinements_spec.rb +1 -3
  281. data/spec/extensions/csv_serializer_spec.rb +4 -9
  282. data/spec/extensions/current_datetime_timestamp_spec.rb +1 -1
  283. data/spec/extensions/dataset_associations_spec.rb +2 -1
  284. data/spec/extensions/dataset_source_alias_spec.rb +1 -1
  285. data/spec/extensions/date_arithmetic_spec.rb +3 -3
  286. data/spec/extensions/def_dataset_method_spec.rb +1 -1
  287. data/spec/extensions/defaults_setter_spec.rb +2 -2
  288. data/spec/extensions/delay_add_association_spec.rb +8 -9
  289. data/spec/extensions/dirty_spec.rb +1 -1
  290. data/spec/extensions/duplicate_columns_handler_spec.rb +1 -1
  291. data/spec/extensions/eager_each_spec.rb +2 -2
  292. data/spec/extensions/empty_array_consider_nulls_spec.rb +1 -1
  293. data/spec/extensions/error_splitter_spec.rb +1 -1
  294. data/spec/extensions/error_sql_spec.rb +1 -1
  295. data/spec/extensions/eval_inspect_spec.rb +1 -1
  296. data/spec/extensions/finder_spec.rb +1 -1
  297. data/spec/extensions/force_encoding_spec.rb +2 -5
  298. data/spec/extensions/freeze_datasets_spec.rb +1 -1
  299. data/spec/extensions/graph_each_spec.rb +5 -5
  300. data/spec/extensions/hook_class_methods_spec.rb +1 -194
  301. data/spec/extensions/identifier_mangling_spec.rb +17 -170
  302. data/spec/extensions/implicit_subquery_spec.rb +1 -5
  303. data/spec/extensions/inflector_spec.rb +1 -1
  304. data/spec/extensions/input_transformer_spec.rb +7 -2
  305. data/spec/extensions/insert_returning_select_spec.rb +1 -1
  306. data/spec/extensions/instance_filters_spec.rb +1 -1
  307. data/spec/extensions/instance_hooks_spec.rb +1 -95
  308. data/spec/extensions/inverted_subsets_spec.rb +1 -1
  309. data/spec/extensions/json_serializer_spec.rb +1 -1
  310. data/spec/extensions/lazy_attributes_spec.rb +1 -7
  311. data/spec/extensions/list_spec.rb +1 -1
  312. data/spec/extensions/looser_typecasting_spec.rb +1 -1
  313. data/spec/extensions/many_through_many_spec.rb +1 -1
  314. data/spec/extensions/migration_spec.rb +2 -2
  315. data/spec/extensions/modification_detection_spec.rb +1 -1
  316. data/spec/extensions/mssql_optimistic_locking_spec.rb +1 -1
  317. data/spec/extensions/named_timezones_spec.rb +3 -3
  318. data/spec/extensions/nested_attributes_spec.rb +1 -29
  319. data/spec/extensions/null_dataset_spec.rb +1 -11
  320. data/spec/extensions/optimistic_locking_spec.rb +1 -1
  321. data/spec/extensions/pagination_spec.rb +1 -1
  322. data/spec/extensions/pg_array_associations_spec.rb +4 -1
  323. data/spec/extensions/pg_array_ops_spec.rb +1 -1
  324. data/spec/extensions/pg_array_spec.rb +3 -48
  325. data/spec/extensions/pg_enum_spec.rb +1 -1
  326. data/spec/extensions/pg_hstore_ops_spec.rb +1 -1
  327. data/spec/extensions/pg_hstore_spec.rb +23 -32
  328. data/spec/extensions/pg_inet_ops_spec.rb +1 -1
  329. data/spec/extensions/pg_inet_spec.rb +1 -14
  330. data/spec/extensions/pg_interval_spec.rb +3 -13
  331. data/spec/extensions/pg_json_ops_spec.rb +1 -1
  332. data/spec/extensions/pg_json_spec.rb +1 -13
  333. data/spec/extensions/pg_loose_count_spec.rb +1 -1
  334. data/spec/extensions/pg_range_ops_spec.rb +1 -1
  335. data/spec/extensions/pg_range_spec.rb +3 -88
  336. data/spec/extensions/pg_row_ops_spec.rb +1 -1
  337. data/spec/extensions/pg_row_plugin_spec.rb +1 -1
  338. data/spec/extensions/pg_row_spec.rb +1 -44
  339. data/spec/extensions/pg_static_cache_updater_spec.rb +1 -1
  340. data/spec/extensions/prepared_statements_safe_spec.rb +1 -1
  341. data/spec/extensions/prepared_statements_spec.rb +13 -48
  342. data/spec/extensions/pretty_table_spec.rb +1 -1
  343. data/spec/extensions/query_spec.rb +1 -12
  344. data/spec/extensions/rcte_tree_spec.rb +1 -1
  345. data/spec/extensions/round_timestamps_spec.rb +1 -5
  346. data/spec/extensions/s_spec.rb +1 -1
  347. data/spec/extensions/schema_caching_spec.rb +1 -1
  348. data/spec/extensions/schema_dumper_spec.rb +1 -1
  349. data/spec/extensions/select_remove_spec.rb +1 -1
  350. data/spec/extensions/sequel_4_dataset_methods_spec.rb +1 -1
  351. data/spec/extensions/serialization_modification_detection_spec.rb +1 -1
  352. data/spec/extensions/serialization_spec.rb +2 -14
  353. data/spec/extensions/server_block_spec.rb +1 -1
  354. data/spec/extensions/server_logging_spec.rb +2 -2
  355. data/spec/extensions/sharding_spec.rb +1 -1
  356. data/spec/extensions/shared_caching_spec.rb +1 -28
  357. data/spec/extensions/single_table_inheritance_spec.rb +2 -5
  358. data/spec/extensions/singular_table_names_spec.rb +1 -1
  359. data/spec/extensions/skip_create_refresh_spec.rb +1 -1
  360. data/spec/extensions/spec_helper.rb +5 -27
  361. data/spec/extensions/split_array_nil_spec.rb +1 -1
  362. data/spec/extensions/split_values_spec.rb +1 -1
  363. data/spec/extensions/sql_comments_spec.rb +1 -1
  364. data/spec/extensions/sql_expr_spec.rb +1 -1
  365. data/spec/extensions/static_cache_spec.rb +1 -1
  366. data/spec/extensions/string_agg_spec.rb +2 -2
  367. data/spec/extensions/string_date_time_spec.rb +1 -1
  368. data/spec/extensions/string_stripper_spec.rb +1 -1
  369. data/spec/extensions/subclasses_spec.rb +1 -1
  370. data/spec/extensions/subset_conditions_spec.rb +1 -1
  371. data/spec/extensions/symbol_aref_refinement_spec.rb +1 -1
  372. data/spec/extensions/symbol_as_refinement_spec.rb +1 -1
  373. data/spec/extensions/table_select_spec.rb +4 -4
  374. data/spec/extensions/tactical_eager_loading_spec.rb +1 -6
  375. data/spec/extensions/thread_local_timezones_spec.rb +1 -1
  376. data/spec/extensions/timestamps_spec.rb +3 -3
  377. data/spec/extensions/to_dot_spec.rb +1 -1
  378. data/spec/extensions/touch_spec.rb +1 -1
  379. data/spec/extensions/tree_spec.rb +1 -1
  380. data/spec/extensions/typecast_on_load_spec.rb +1 -1
  381. data/spec/extensions/unlimited_update_spec.rb +1 -1
  382. data/spec/extensions/update_or_create_spec.rb +1 -1
  383. data/spec/extensions/update_primary_key_spec.rb +4 -3
  384. data/spec/extensions/update_refresh_spec.rb +1 -1
  385. data/spec/extensions/uuid_spec.rb +10 -12
  386. data/spec/extensions/validate_associated_spec.rb +1 -1
  387. data/spec/extensions/validation_class_methods_spec.rb +3 -3
  388. data/spec/extensions/validation_contexts_spec.rb +1 -1
  389. data/spec/extensions/validation_helpers_spec.rb +10 -44
  390. data/spec/extensions/whitelist_security_spec.rb +5 -5
  391. data/spec/extensions/xml_serializer_spec.rb +3 -3
  392. data/spec/guards_helper.rb +2 -1
  393. data/spec/integration/associations_test.rb +1 -23
  394. data/spec/integration/database_test.rb +7 -7
  395. data/spec/integration/dataset_test.rb +5 -47
  396. data/spec/integration/eager_loader_test.rb +1 -1
  397. data/spec/integration/migrator_test.rb +1 -1
  398. data/spec/integration/model_test.rb +4 -82
  399. data/spec/integration/plugin_test.rb +6 -22
  400. data/spec/integration/prepared_statement_test.rb +8 -88
  401. data/spec/integration/schema_test.rb +6 -6
  402. data/spec/integration/spec_helper.rb +13 -21
  403. data/spec/integration/timezone_test.rb +5 -5
  404. data/spec/integration/transaction_test.rb +3 -55
  405. data/spec/integration/type_test.rb +9 -9
  406. data/spec/model/association_reflection_spec.rb +24 -9
  407. data/spec/model/associations_spec.rb +124 -303
  408. data/spec/model/base_spec.rb +18 -137
  409. data/spec/model/class_dataset_methods_spec.rb +2 -20
  410. data/spec/model/dataset_methods_spec.rb +1 -20
  411. data/spec/model/eager_loading_spec.rb +17 -11
  412. data/spec/model/hooks_spec.rb +5 -300
  413. data/spec/model/inflector_spec.rb +1 -1
  414. data/spec/model/model_spec.rb +15 -320
  415. data/spec/model/plugins_spec.rb +2 -16
  416. data/spec/model/record_spec.rb +29 -121
  417. data/spec/model/spec_helper.rb +5 -15
  418. data/spec/model/validations_spec.rb +1 -1
  419. data/spec/sequel_warning.rb +1 -12
  420. metadata +8 -64
  421. data/doc/active_record.rdoc +0 -927
  422. data/lib/sequel/adapters/cubrid.rb +0 -160
  423. data/lib/sequel/adapters/do.rb +0 -166
  424. data/lib/sequel/adapters/do/mysql.rb +0 -69
  425. data/lib/sequel/adapters/do/postgres.rb +0 -46
  426. data/lib/sequel/adapters/do/sqlite3.rb +0 -41
  427. data/lib/sequel/adapters/jdbc/as400.rb +0 -92
  428. data/lib/sequel/adapters/jdbc/cubrid.rb +0 -65
  429. data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -37
  430. data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -34
  431. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -34
  432. data/lib/sequel/adapters/odbc/progress.rb +0 -12
  433. data/lib/sequel/adapters/shared/cubrid.rb +0 -245
  434. data/lib/sequel/adapters/shared/firebird.rb +0 -261
  435. data/lib/sequel/adapters/shared/informix.rb +0 -63
  436. data/lib/sequel/adapters/shared/progress.rb +0 -40
  437. data/lib/sequel/adapters/swift.rb +0 -169
  438. data/lib/sequel/adapters/swift/mysql.rb +0 -50
  439. data/lib/sequel/adapters/swift/postgres.rb +0 -49
  440. data/lib/sequel/adapters/swift/sqlite.rb +0 -48
  441. data/lib/sequel/adapters/utils/pg_types.rb +0 -4
  442. data/lib/sequel/dataset/mutation.rb +0 -98
  443. data/lib/sequel/extensions/_deprecated_identifier_mangling.rb +0 -117
  444. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +0 -8
  445. data/lib/sequel/extensions/filter_having.rb +0 -65
  446. data/lib/sequel/extensions/hash_aliases.rb +0 -51
  447. data/lib/sequel/extensions/meta_def.rb +0 -37
  448. data/lib/sequel/extensions/query_literals.rb +0 -86
  449. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +0 -26
  450. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +0 -133
  451. data/lib/sequel/extensions/set_overrides.rb +0 -82
  452. data/lib/sequel/no_core_ext.rb +0 -4
  453. data/lib/sequel/plugins/association_autoreloading.rb +0 -11
  454. data/lib/sequel/plugins/identifier_columns.rb +0 -49
  455. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +0 -11
  456. data/lib/sequel/plugins/pg_typecast_on_load.rb +0 -90
  457. data/lib/sequel/plugins/prepared_statements_associations.rb +0 -137
  458. data/lib/sequel/plugins/prepared_statements_with_pk.rb +0 -71
  459. data/lib/sequel/plugins/schema.rb +0 -84
  460. data/lib/sequel/plugins/scissors.rb +0 -37
  461. data/spec/core/dataset_mutation_spec.rb +0 -253
  462. data/spec/extensions/_deprecated_identifier_mangling_spec.rb +0 -314
  463. data/spec/extensions/before_after_save_spec.rb +0 -40
  464. data/spec/extensions/filter_having_spec.rb +0 -42
  465. data/spec/extensions/from_block_spec.rb +0 -21
  466. data/spec/extensions/hash_aliases_spec.rb +0 -26
  467. data/spec/extensions/identifier_columns_spec.rb +0 -19
  468. data/spec/extensions/meta_def_spec.rb +0 -35
  469. data/spec/extensions/no_auto_literal_strings_spec.rb +0 -69
  470. data/spec/extensions/pg_typecast_on_load_spec.rb +0 -70
  471. data/spec/extensions/prepared_statements_associations_spec.rb +0 -212
  472. data/spec/extensions/prepared_statements_with_pk_spec.rb +0 -40
  473. data/spec/extensions/query_literals_spec.rb +0 -185
  474. data/spec/extensions/schema_spec.rb +0 -123
  475. data/spec/extensions/scissors_spec.rb +0 -27
  476. data/spec/extensions/sequel_3_dataset_methods_spec.rb +0 -118
  477. data/spec/extensions/set_overrides_spec.rb +0 -75
@@ -7,28 +7,16 @@ many Sequel::Dataset methods that take virtual row blocks.
7
7
 
8
8
  == Why Virtual Rows
9
9
 
10
- Virtual Rows were created to work around the issue that some parts of
11
- Sequel's standard DSL could not be used on ruby 1.9. For example, the
12
- following Sequel code historically worked on ruby 1.8, but not ruby 1.9:
13
-
14
- dataset.where(:a > :b[:c])
15
- # WHERE a > b(c)
16
-
17
- This code does not work on ruby 1.9 for two reasons. First, Symbol#>
18
- (like other inequality methods) is already defined in ruby 1.9, so Sequel
19
- does not override it to return an SQL inequality expression. Second, Symbol#[]
20
- is already defined on ruby 1.9, so Sequel does not override it to return an
21
- SQL function expression.
22
-
23
- It's possible to use Sequel's DSL to represent such expressions, but it is a
24
- little verbose:
10
+ Virtual rows offer a less verbose way to express many queries. For example,
11
+ by default if you want to express an inequality filter in Sequel, you can do:
25
12
 
26
13
  dataset.where(Sequel[:a] > Sequel.function(:b, :c))
27
- # WHERE a > b(c)
14
+ # WHERE (a > b(c))
28
15
 
29
- The virtual row DSL makes such code more concise:
16
+ With virtual rows, you can use the less verbose:
30
17
 
31
18
  dataset.where{a > b(c)}
19
+ # WHERE (a > b(c))
32
20
 
33
21
  == Regular Procs vs Instance Evaled Procs
34
22
 
@@ -38,96 +26,101 @@ of Sequel::SQL::VirtualRow. If it does not accept an argument, it is
38
26
  evaluated in the context of an instance of Sequel::SQL::VirtualRow.
39
27
 
40
28
  ds = DB[:items]
41
- # Regular proc
29
+ # Regular block
42
30
  ds.where{|o| o.column > 1}
43
- # WHERE column > 1
31
+ # WHERE (column > 1)
44
32
 
45
- # Instance-evaled proc
33
+ # Instance-evaled block
46
34
  ds.where{column > 1}
47
- # WHERE column > 1
35
+ # WHERE (column > 1)
48
36
 
49
37
  If you aren't familiar with the difference between regular blocks and instance
50
- evaled blocks, you should probably consult a general ruby reference, but briefly,
51
- with regular procs, methods called without an explicit receiver inside the
52
- proc call the method on the receiver in the surrounding scope, while instance
53
- evaled procs call the method on the receiver of the instance_eval call. However,
38
+ evaled blocks, inside regular blocks methods called without an explicit receiver call
39
+ the method on the receiver in the surrounding scope, while instance
40
+ evaled blocks call the method on the receiver of the instance_eval call (the
41
+ Sequel::SQL::VirtualRow instance in this case).
42
+
54
43
  in both cases, local variables available in the surrounding scope will be available
55
- inside the proc. If that doesn't make sense, maybe this example will help:
44
+ inside the block. However, instance variables in the surrounding scope will not
45
+ be available inside the block if using an instance evaled block, and methods called
46
+ without an explicit receiver inside an instance evaled block will not call
47
+ methods in the surrounding scope. For example:
56
48
 
57
49
  def self.a
58
50
  42
59
51
  end
60
52
  b = 32
53
+ @d = 100
61
54
 
62
- # Regular proc
63
- ds.where{|o| o.c > a - b}
64
- # WHERE c > 10
55
+ # Regular block
56
+ ds.where{|o| o.c > a - b + @d}
57
+ # WHERE (c > 100)
65
58
 
66
- # Instance-evaled proc
67
- ds.where{c > a - b}
68
- # WHERE c > (a - 32)
59
+ # Instance-evaled block
60
+ ds.where{c > a - b + @d}
61
+ # WHERE (c > ((a - 32) + NULL))
69
62
 
70
- There are two related differences here. First is the usage of <tt>o.c</tt> vs +c+,
71
- and second is the difference between the use of +a+. In the regular proc,
72
- you couldn't call +c+ without an explicit receiver in the proc, unless the self of the
73
- surrounding scope responded to it. For +a+, note how ruby calls the method on
74
- the receiver of the surrounding scope in the regular proc, which returns an integer,
63
+ There are three related differences here:
64
+
65
+ * Regular blocks use +o.c+ instead of just +c+
66
+ * +a+ results in 42 in the regular block, but creates an expression object in the instance evaled block
67
+ * @d results in 100 in the regular block, but nil in the instance evaled block
68
+
69
+ In the regular block, you need to call +c+ with an explicit receiver (the virtual
70
+ row block argument), while in the instance evaled block +c+ can be called directly,
71
+ as the default receiver has changed inside the block.
72
+
73
+ For +a+, note how ruby calls the method on
74
+ the receiver of the surrounding scope in the regular block, which returns an integer,
75
75
  and does the subtraction before Sequel gets access to it. In the instance evaled
76
- proc, calling +a+ without a receiver calls the a method on the VirtualRow instance.
76
+ block, calling +a+ without a receiver calls the a method on the VirtualRow instance.
77
+ For @d, note that in a regular block, the value hasn't changed, but in the instance evaled
78
+ block, instance variable access returns nil.
77
79
  For +b+, note that it operates the same in both cases, as it is a local variable.
78
80
 
79
- Basically, the choice for whether to use a regular proc or an instance evaled proc is
80
- completely up to you. The same things can be accomplished with both.
81
- Instance evaled procs tend to produce shorter code, but by modifying the scope
82
- can be more difficult for a new user to understand. That being said, I usually
83
- use instance evaled procs unless I need to call methods on the receiver of the
84
- surrounding scope inside the proc.
81
+ The choice for whether to use a regular block or an instance evaled block is
82
+ up to you. The same things can be accomplished with both.
83
+ Instance evaled block tend to produce shorter code, but by modifying the scope
84
+ can be more difficult to understand.
85
+
86
+ If you are not sure which to use, use instance evaled blocks unless you need to
87
+ call methods or access instance variables of the surrounding scope inside the block.
85
88
 
86
89
  == Local Variables vs Method Calls
87
90
 
88
91
  If you have a method that accepts 0 arguments and has the same name as a local
89
92
  variable, you can call it with () to differentiate the method call from the
90
- local variable access. This is mostly useful in instance_evaled procs:
93
+ local variable access. This is mostly useful in instance evaled blocks:
91
94
 
92
95
  b = 32
93
96
  ds.where{b() > b}
94
97
  # WHERE b > 32
95
98
 
99
+ It's also possible to use an explicit self receiver in instance evaled blocks:
100
+
101
+ b = 32
102
+ ds.where{self.b > b}
103
+ # WHERE b > 32
104
+
105
+
96
106
  == VirtualRow Methods
97
107
 
98
- VirtualRow is a class that returns SQL::Identifiers, SQL::QualifiedIdentifiers, or
99
- SQL::Functions depending on how it is called.
108
+ VirtualRow is a class that returns SQL::Identifiers or SQL::Functions depending
109
+ on how it is called.
100
110
 
101
111
  == SQL::Identifiers - Regular columns
102
112
 
103
113
  SQL::Identifiers can be thought of as regular column references in SQL,
104
114
  not qualified by any table. You get an SQL::Identifier if the method is called
105
- without a block or arguments, and doesn't have a double underscore in the method
106
- name:
115
+ without arguments:
107
116
 
108
117
  ds.where{|o| o.column > 1}
109
118
  ds.where{column > 1}
110
- # WHERE column > 1
119
+ # WHERE (column > 1)
111
120
 
112
121
  == SQL::QualifiedIdentifiers - Qualified columns
113
122
 
114
- SQL::QualifiedIdentifiers can be thought of as column references in SQL that
115
- are qualified to a specific table. You get an SQL::QualifiedIdentifier if
116
- the method is called without a block or arguments, and has a double underscore
117
- in the method name:
118
-
119
- ds.where{|o| o.table__column > 1}
120
- ds.where{table__column > 1}
121
- # WHERE table.column > 1
122
-
123
- Using the double underscore for SQL::QualifiedIdentifiers was done to make
124
- usage very similar to using symbols, which by default also translate the
125
- double underscore into a qualified column.
126
-
127
- Note that when <tt>Sequel.split_symbols = false</tt> is used, then virtual
128
- rows do not split symbols either. If you need to create qualified identifers
129
- when disabling symbol splitting, it is easy to do by calling #[] on the
130
- SQL::Identifiers returned by regular methods calls:
123
+ You can qualified identifiers by calling #[] on an identifier:
131
124
 
132
125
  ds.where{|o| o.table[:column] > 1}
133
126
  ds.where{table[:column] > 1}
@@ -136,7 +129,7 @@ SQL::Identifiers returned by regular methods calls:
136
129
  == SQL::Functions - SQL function calls
137
130
 
138
131
  SQL::Functions can be thought of as function calls in SQL. You get a simple
139
- function call if you call a method with arguments and without a block:
132
+ function call if you call a method with arguments:
140
133
 
141
134
  ds.where{|o| o.function(1) > 1}
142
135
  ds.where{function(1) > 1}
@@ -176,8 +169,7 @@ distinct method on the returned Function:
176
169
 
177
170
  == SQL::Functions with windows - SQL window function calls
178
171
 
179
- Not all databases support window functions, but they are very helpful for certain types of
180
- queries. To use them, you should just call the over method on the Function
172
+ To create a window function call, just call the over method on the Function
181
173
  object returned, with the options for the window:
182
174
 
183
175
  ds.select{|o| o.rank.function.over}
@@ -188,19 +180,18 @@ object returned, with the options for the window:
188
180
  ds.select{count.function.*.over}
189
181
  # SELECT count(*) OVER ()
190
182
 
191
- ds.select{|o| o.sum(o.col1).over(:partition=>o.col2, :order=>o.col3)}
192
- ds.select{sum(col1).over(:partition=>col2, :order=>col3)}
183
+ ds.select{|o| o.sum(o.col1).over(partition: o.col2, order: o.col3)}
184
+ ds.select{sum(col1).over(partition: col2, order: col3)}
193
185
  # SELECT sum(col1) OVER (PARTITION BY col2 ORDER BY col3)
194
186
 
195
187
  == Operators
196
188
 
197
189
  VirtualRows use method_missing to handle almost all method calls. Since the
198
- objects given by method_missing are SQL::Identifiers, SQL::QualifiedIdentifiers
199
- or SQL::Functions, you can use all operators that they provide (see
190
+ objects given by method_missing are SQL::Identifiers or SQL::Functions, you can use all operators that they provide (see
200
191
  DatasetFiltering[http://sequel.jeremyevans.net/rdoc/files/doc/dataset_filtering_rdoc.html#label-Filtering+using+expressions]):
201
192
 
202
193
  ds.select{|o| o.price - 100}
203
- ds.select{o.price - 100}
194
+ ds.select{price - 100}
204
195
  # SELECT (price - 100)
205
196
 
206
197
  ds.where{|o| (o.price < 200) & (o.tax * 100 >= 23)}
@@ -222,14 +213,14 @@ The standard +, -, *, and / mathematical operators are defined:
222
213
 
223
214
  The & and | methods are defined to use AND and OR:
224
215
 
225
- ds.where{|o| o.&({:a=>:b}, :c)}
226
- ds.where{self.&({:a=>:b}, :c)}
216
+ ds.where{|o| o.&({a: :b}, :c)}
217
+ ds.where{self.&({a: :b}, :c)}
227
218
  # WHERE ((a = b) AND c)
228
219
 
229
220
  The ~ method is defined to do inversion:
230
221
 
231
- ds.where{|o| o.~({:a=>1, :b=>2})}
232
- ds.where{self.~({:a=>1, :b=>2})}
222
+ ds.where{|o| o.~({a: 1, b: 2})}
223
+ ds.where{self.~({a: 1, b: 2})}
233
224
  # WHERE ((a != 1) OR (b != 2))
234
225
 
235
226
  === Inequality Operators
@@ -240,19 +231,6 @@ The standard >, <, >=, and <= inequality operators are defined:
240
231
  ds.where{self.>(1, :c)}
241
232
  # WHERE (1 > c)
242
233
 
243
- == Literal Strings
244
-
245
- The backtick operator can be used inside an instance-evaled
246
- virtual row block to create a literal string:
247
-
248
- ds.where{a > `some SQL`}
249
- # WHERE (a > some SQL)
250
-
251
- You can use this on a regular virtual row block too, but it
252
- doesn't look as nice:
253
-
254
- ds.where{|o| o.>(:a, o.`('some SQL'))}
255
-
256
234
  == Returning multiple values
257
235
 
258
236
  It's common when using select and order virtual row blocks to want to
@@ -268,26 +246,20 @@ Note that if you forget the array brackets, you'll end up with a syntax error:
268
246
  # Invalid ruby syntax
269
247
  ds.select{|o| o.column1, o.sum(o.column2).as(o.sum)}
270
248
  ds.select{column1, sum(column2).as(sum)}
271
-
272
- == Alternative Description of the VirtualRow method call rules
273
-
274
- * If a block is given:
275
- * The block is currently not called. This may change in a future version.
276
- * If there are no arguments, an SQL::Function with the name of
277
- method used, and no arguments.
278
- * If the first argument is :*, an SQL::Function is created with a single
279
- wildcard argument (*).
280
- * If the first argument is :distinct, an SQL::Function is created with
281
- the keyword DISTINCT prefacing all remaining arguments.
282
- * If the first argument is :over, the second argument if provided should
283
- be a hash of options to pass to SQL::Window. The options hash can also
284
- contain :*=>true to use a wildcard argument as the function argument, or
285
- :args=>... to specify an array of arguments to use as the function arguments.
286
- * If a block is not given:
287
- * If there are arguments, an SQL::Function is returned with the
288
- name of the method used and the arguments given.
289
- * If there are no arguments and the method contains a double
290
- underscore, split on the double underscore and return an
291
- SQL::QualifiedIdentifier with the table and column.
292
- * Otherwise, create an SQL::Identifier with the name of the
293
- method.
249
+
250
+ == Split symbols
251
+
252
+ Note that if you turn on symbol splitting for backwards compatibility,
253
+ Sequel will split virtual row methods with double underscores and
254
+ return them as qualified identifiers:
255
+
256
+ Sequel.split_symbols = true
257
+ ds.where{|o| o.table__column}
258
+ ds.where{table__column}
259
+ WHERE table.column
260
+
261
+ It's not recommended that you rely on this, it's better to convert the calls
262
+ to the recommended form:
263
+
264
+ ds.where{|o| o.table[:column]}
265
+ ds.where{table[:column]}
@@ -1,3 +1,3 @@
1
1
  # frozen-string-literal: true
2
2
 
3
- require 'sequel/model'
3
+ require_relative 'sequel/model'
@@ -61,14 +61,8 @@ module Sequel
61
61
  Sequel.blob(v.pack('c*'))
62
62
  end
63
63
 
64
- if RUBY_VERSION >= '1.9'
65
- def cp.date(v)
66
- Date.new(v.year, v.month, v.day)
67
- end
68
- else
69
- def cp.date(v)
70
- Date.new(*v[0...10].split('/').map{|x| x.to_i})
71
- end
64
+ def cp.date(v)
65
+ Date.new(v.year, v.month, v.day)
72
66
  end
73
67
 
74
68
  CONVERSION_PROCS = {}
@@ -83,12 +77,9 @@ module Sequel
83
77
  CONVERSION_PROCS[i] = method
84
78
  end
85
79
  end
86
- # CONVERSION_PROCS.freeze # SEQUEL5
80
+ CONVERSION_PROCS.freeze
87
81
 
88
82
  class Database < Sequel::Database
89
- DISCONNECT_ERROR_RE = /Communication link failure/
90
- Sequel::Deprecation.deprecate_constant(self, :DISCONNECT_ERROR_RE)
91
-
92
83
  set_adapter_scheme :ado
93
84
 
94
85
  attr_reader :conversion_procs
@@ -99,7 +90,6 @@ module Sequel
99
90
  # :command_timeout :: Sets the time in seconds to wait while attempting
100
91
  # to execute a command before cancelling the attempt and generating
101
92
  # an error. Specifically, it sets the ADO CommandTimeout property.
102
- # If this property is not set, the default of 30 seconds is used.
103
93
  # :driver :: The driver to use in the ADO connection string. If not provided, a default
104
94
  # of "SQL Server" is used.
105
95
  # :conn_string :: The full ADO connection string. If this is provided,
@@ -111,8 +101,8 @@ module Sequel
111
101
  #
112
102
  # Pay special attention to the :provider option, as without specifying a provider,
113
103
  # many things will be broken. The SQLNCLI10 provider appears to work well if you
114
- # are connecting to Microsoft SQL Server, but it is not the default as that would
115
- # break backwards compatability.
104
+ # are connecting to Microsoft SQL Server, but it is not the default as that is not
105
+ # always available and would break backwards compatability.
116
106
  def connect(server)
117
107
  opts = server_opts(server)
118
108
  s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}"
@@ -184,14 +174,14 @@ module Sequel
184
174
  def adapter_initialize
185
175
  case @opts[:conn_string]
186
176
  when /Microsoft\.(Jet|ACE)\.OLEDB/io
187
- Sequel.require 'adapters/ado/access'
177
+ require_relative 'ado/access'
188
178
  extend Sequel::ADO::Access::DatabaseMethods
189
179
  self.dataset_class = ADO::Access::Dataset
190
180
  else
191
181
  @opts[:driver] ||= 'SQL Server'
192
182
  case @opts[:driver]
193
183
  when 'SQL Server'
194
- Sequel.require 'adapters/ado/mssql'
184
+ require_relative 'ado/mssql'
195
185
  extend Sequel::ADO::MSSQL::DatabaseMethods
196
186
  self.dataset_class = ADO::MSSQL::Dataset
197
187
  set_mssql_unicode_strings
@@ -232,9 +222,6 @@ module Sequel
232
222
  end
233
223
 
234
224
  class Dataset < Sequel::Dataset
235
- Database::DatasetClass = self
236
- Sequel::Deprecation.deprecate_constant(Database, :DatasetClass)
237
-
238
225
  def fetch_rows(sql)
239
226
  execute(sql) do |recordset|
240
227
  cols = []
@@ -245,7 +232,7 @@ module Sequel
245
232
  recordset.Fields.each do |field|
246
233
  type = field.Type
247
234
  cp = if type == AdDBTimeStamp
248
- ts_cp ||= if RUBY_VERSION >= '1.9'
235
+ ts_cp ||= begin
249
236
  nsec_div = 1000000000.0/(10**(timestamp_precision))
250
237
  nsec_mul = 10**(timestamp_precision+3)
251
238
  meth = db.method(:to_application_timestamp)
@@ -253,9 +240,6 @@ module Sequel
253
240
  # Fractional second handling is not correct on ruby <2.2
254
241
  meth.call([v.year, v.month, v.day, v.hour, v.min, v.sec, (v.nsec/nsec_div).round * nsec_mul])
255
242
  end
256
- else
257
- # Ruby 1.8 returns AdDBTimeStamp values as a string
258
- db.method(:to_application_timestamp)
259
243
  end
260
244
  else
261
245
  conversion_procs[type]
@@ -282,7 +266,7 @@ module Sequel
282
266
  end
283
267
  end
284
268
 
285
- # ADO returns nil for all for delete and update statements.
269
+ # ADO can return for for delete and update statements, depending on the provider.
286
270
  def provides_accurate_rows_matched?
287
271
  false
288
272
  end
@@ -1,7 +1,7 @@
1
1
  # frozen-string-literal: true
2
2
 
3
- Sequel.require 'adapters/shared/access'
4
- Sequel.require 'adapters/utils/split_alter_table'
3
+ require_relative '../shared/access'
4
+ require_relative '../utils/split_alter_table'
5
5
 
6
6
  module Sequel
7
7
  module ADO
@@ -15,7 +15,7 @@ module Sequel
15
15
  :tables => 20,
16
16
  :views => 23,
17
17
  :foreign_keys => 27
18
- }#.freeze # SEQUEL5
18
+ }.freeze
19
19
 
20
20
  attr_reader :type, :criteria
21
21
 
@@ -42,8 +42,8 @@ module Sequel
42
42
  131 => "DECIMAL",
43
43
  201 => "TEXT",
44
44
  205 => "IMAGE"
45
- }#.freeze # SEQUEL5
46
- #DATA_TYPE.each_value(&:freeze) # SEQUEL5
45
+ }.freeze
46
+ DATA_TYPE.each_value(&:freeze)
47
47
 
48
48
  def initialize(row)
49
49
  @row = row
@@ -90,11 +90,6 @@ module Sequel
90
90
  include Sequel::Access::DatabaseMethods
91
91
  include Sequel::Database::SplitAlterTable
92
92
 
93
- DECIMAL_TYPE_RE = /decimal/io
94
- Sequel::Deprecation.deprecate_constant(self, :DECIMAL_TYPE_RE)
95
- LAST_INSERT_ID = "SELECT @@IDENTITY".freeze
96
- Sequel::Deprecation.deprecate_constant(self, :LAST_INSERT_ID)
97
-
98
93
  # Remove cached schema after altering a table, since otherwise it can be cached
99
94
  # incorrectly in the rename column case.
100
95
  def alter_table(name, *)
@@ -134,7 +129,7 @@ module Sequel
134
129
  ado_schema_views.map {|tbl| m.call(tbl['TABLE_NAME'])}
135
130
  end
136
131
 
137
- # Note OpenSchema returns compound indexes as multiple rows
132
+ # OpenSchema returns compound indexes as multiple rows
138
133
  def indexes(table_name,opts=OPTS)
139
134
  m = output_identifier_meth
140
135
  idxs = ado_schema_indexes(table_name).inject({}) do |memo, idx|
@@ -149,7 +144,7 @@ module Sequel
149
144
  idxs
150
145
  end
151
146
 
152
- # Note OpenSchema returns compound foreign key relationships as multiple rows
147
+ # OpenSchema returns compound foreign key relationships as multiple rows
153
148
  def foreign_key_list(table, opts=OPTS)
154
149
  m = output_identifier_meth
155
150
  fks = ado_schema_foreign_keys(table).inject({}) do |memo, fk|
@@ -312,7 +307,6 @@ module Sequel
312
307
  # This is like execute() in that it yields an ADO RecordSet, except
313
308
  # instead of an SQL interface there's this OpenSchema call
314
309
  # cf. http://msdn.microsoft.com/en-us/library/ee275721(v=bts.10)
315
- #
316
310
  def execute_open_ado_schema(type, criteria=[])
317
311
  ado_schema = AdoSchema.new(type, criteria)
318
312
  synchronize(opts[:server]) do |conn|