sequel 4.49.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (484) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +130 -0
  3. data/README.rdoc +195 -136
  4. data/Rakefile +26 -42
  5. data/bin/sequel +6 -9
  6. data/doc/advanced_associations.rdoc +91 -168
  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/release_notes/5.1.0.txt +31 -0
  29. data/doc/release_notes/5.2.0.txt +33 -0
  30. data/doc/release_notes/5.3.0.txt +121 -0
  31. data/doc/schema_modification.rdoc +78 -64
  32. data/doc/security.rdoc +97 -88
  33. data/doc/sharding.rdoc +43 -30
  34. data/doc/sql.rdoc +53 -65
  35. data/doc/testing.rdoc +4 -5
  36. data/doc/thread_safety.rdoc +2 -4
  37. data/doc/transactions.rdoc +18 -17
  38. data/doc/validations.rdoc +48 -45
  39. data/doc/virtual_rows.rdoc +87 -115
  40. data/lib/sequel/adapters/ado/access.rb +7 -13
  41. data/lib/sequel/adapters/ado/mssql.rb +2 -9
  42. data/lib/sequel/adapters/ado.rb +9 -25
  43. data/lib/sequel/adapters/amalgalite.rb +3 -18
  44. data/lib/sequel/adapters/ibmdb.rb +9 -45
  45. data/lib/sequel/adapters/jdbc/db2.rb +8 -37
  46. data/lib/sequel/adapters/jdbc/derby.rb +4 -50
  47. data/lib/sequel/adapters/jdbc/h2.rb +6 -26
  48. data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -27
  49. data/lib/sequel/adapters/jdbc/jtds.rb +2 -9
  50. data/lib/sequel/adapters/jdbc/mssql.rb +1 -11
  51. data/lib/sequel/adapters/jdbc/mysql.rb +11 -15
  52. data/lib/sequel/adapters/jdbc/oracle.rb +4 -26
  53. data/lib/sequel/adapters/jdbc/postgresql.rb +23 -33
  54. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +4 -17
  55. data/lib/sequel/adapters/jdbc/sqlite.rb +1 -7
  56. data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -13
  57. data/lib/sequel/adapters/jdbc/transactions.rb +1 -14
  58. data/lib/sequel/adapters/jdbc.rb +18 -74
  59. data/lib/sequel/adapters/mock.rb +4 -30
  60. data/lib/sequel/adapters/mysql.rb +7 -44
  61. data/lib/sequel/adapters/mysql2.rb +5 -23
  62. data/lib/sequel/adapters/odbc/db2.rb +1 -1
  63. data/lib/sequel/adapters/odbc/mssql.rb +4 -12
  64. data/lib/sequel/adapters/odbc/oracle.rb +1 -1
  65. data/lib/sequel/adapters/odbc.rb +0 -19
  66. data/lib/sequel/adapters/oracle.rb +8 -13
  67. data/lib/sequel/adapters/postgres.rb +28 -150
  68. data/lib/sequel/adapters/postgresql.rb +1 -1
  69. data/lib/sequel/adapters/shared/access.rb +11 -51
  70. data/lib/sequel/adapters/shared/db2.rb +3 -61
  71. data/lib/sequel/adapters/shared/mssql.rb +21 -157
  72. data/lib/sequel/adapters/shared/mysql.rb +61 -227
  73. data/lib/sequel/adapters/shared/oracle.rb +13 -41
  74. data/lib/sequel/adapters/shared/postgres.rb +58 -264
  75. data/lib/sequel/adapters/shared/sqlanywhere.rb +4 -96
  76. data/lib/sequel/adapters/shared/sqlite.rb +22 -101
  77. data/lib/sequel/adapters/sqlanywhere.rb +4 -23
  78. data/lib/sequel/adapters/sqlite.rb +2 -19
  79. data/lib/sequel/adapters/tinytds.rb +5 -15
  80. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +1 -1
  81. data/lib/sequel/adapters/utils/mysql_mysql2.rb +4 -4
  82. data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +3 -6
  83. data/lib/sequel/adapters/utils/replace.rb +0 -5
  84. data/lib/sequel/adapters/utils/stored_procedures.rb +0 -2
  85. data/lib/sequel/adapters/utils/unmodified_identifiers.rb +2 -0
  86. data/lib/sequel/ast_transformer.rb +3 -94
  87. data/lib/sequel/connection_pool/sharded_single.rb +1 -4
  88. data/lib/sequel/connection_pool/sharded_threaded.rb +97 -95
  89. data/lib/sequel/connection_pool/single.rb +0 -2
  90. data/lib/sequel/connection_pool/threaded.rb +94 -110
  91. data/lib/sequel/connection_pool.rb +38 -28
  92. data/lib/sequel/core.rb +42 -101
  93. data/lib/sequel/database/connecting.rb +23 -60
  94. data/lib/sequel/database/dataset.rb +6 -9
  95. data/lib/sequel/database/dataset_defaults.rb +4 -48
  96. data/lib/sequel/database/features.rb +5 -4
  97. data/lib/sequel/database/logging.rb +2 -9
  98. data/lib/sequel/database/misc.rb +36 -55
  99. data/lib/sequel/database/query.rb +8 -13
  100. data/lib/sequel/database/schema_generator.rb +93 -64
  101. data/lib/sequel/database/schema_methods.rb +61 -79
  102. data/lib/sequel/database/transactions.rb +4 -24
  103. data/lib/sequel/database.rb +12 -2
  104. data/lib/sequel/dataset/actions.rb +57 -107
  105. data/lib/sequel/dataset/dataset_module.rb +4 -16
  106. data/lib/sequel/dataset/features.rb +35 -30
  107. data/lib/sequel/dataset/graph.rb +40 -49
  108. data/lib/sequel/dataset/misc.rb +12 -37
  109. data/lib/sequel/dataset/placeholder_literalizer.rb +4 -4
  110. data/lib/sequel/dataset/prepared_statements.rb +23 -51
  111. data/lib/sequel/dataset/query.rb +91 -161
  112. data/lib/sequel/dataset/sql.rb +33 -225
  113. data/lib/sequel/dataset.rb +18 -10
  114. data/lib/sequel/deprecated.rb +18 -27
  115. data/lib/sequel/exceptions.rb +1 -17
  116. data/lib/sequel/extensions/_model_pg_row.rb +0 -7
  117. data/lib/sequel/extensions/_pretty_table.rb +1 -3
  118. data/lib/sequel/extensions/arbitrary_servers.rb +10 -10
  119. data/lib/sequel/extensions/connection_expiration.rb +1 -1
  120. data/lib/sequel/extensions/connection_validator.rb +1 -1
  121. data/lib/sequel/extensions/constraint_validations.rb +11 -11
  122. data/lib/sequel/extensions/core_extensions.rb +39 -49
  123. data/lib/sequel/extensions/core_refinements.rb +39 -45
  124. data/lib/sequel/extensions/current_datetime_timestamp.rb +0 -4
  125. data/lib/sequel/extensions/date_arithmetic.rb +7 -7
  126. data/lib/sequel/extensions/duplicate_columns_handler.rb +12 -9
  127. data/lib/sequel/extensions/empty_array_consider_nulls.rb +2 -2
  128. data/lib/sequel/extensions/eval_inspect.rb +4 -11
  129. data/lib/sequel/extensions/freeze_datasets.rb +1 -69
  130. data/lib/sequel/extensions/from_block.rb +1 -35
  131. data/lib/sequel/extensions/graph_each.rb +2 -2
  132. data/lib/sequel/extensions/identifier_mangling.rb +9 -19
  133. data/lib/sequel/extensions/implicit_subquery.rb +2 -2
  134. data/lib/sequel/extensions/inflector.rb +4 -4
  135. data/lib/sequel/extensions/migration.rb +27 -43
  136. data/lib/sequel/extensions/no_auto_literal_strings.rb +2 -84
  137. data/lib/sequel/extensions/null_dataset.rb +2 -8
  138. data/lib/sequel/extensions/pagination.rb +1 -17
  139. data/lib/sequel/extensions/pg_array.rb +20 -189
  140. data/lib/sequel/extensions/pg_extended_date_support.rb +230 -0
  141. data/lib/sequel/extensions/pg_hstore.rb +11 -50
  142. data/lib/sequel/extensions/pg_hstore_ops.rb +2 -2
  143. data/lib/sequel/extensions/pg_inet.rb +3 -16
  144. data/lib/sequel/extensions/pg_interval.rb +1 -20
  145. data/lib/sequel/extensions/pg_json.rb +7 -27
  146. data/lib/sequel/extensions/pg_loose_count.rb +1 -1
  147. data/lib/sequel/extensions/pg_range.rb +6 -121
  148. data/lib/sequel/extensions/pg_range_ops.rb +1 -3
  149. data/lib/sequel/extensions/pg_row.rb +5 -77
  150. data/lib/sequel/extensions/pg_row_ops.rb +2 -13
  151. data/lib/sequel/extensions/query.rb +3 -4
  152. data/lib/sequel/extensions/round_timestamps.rb +0 -6
  153. data/lib/sequel/extensions/schema_dumper.rb +13 -13
  154. data/lib/sequel/extensions/select_remove.rb +3 -3
  155. data/lib/sequel/extensions/split_array_nil.rb +2 -2
  156. data/lib/sequel/extensions/sql_comments.rb +2 -2
  157. data/lib/sequel/extensions/string_agg.rb +11 -8
  158. data/lib/sequel/extensions/symbol_aref.rb +6 -20
  159. data/lib/sequel/extensions/synchronize_sql.rb +45 -0
  160. data/lib/sequel/model/associations.rb +129 -131
  161. data/lib/sequel/model/base.rb +133 -731
  162. data/lib/sequel/model/default_inflections.rb +1 -1
  163. data/lib/sequel/model/errors.rb +0 -3
  164. data/lib/sequel/model/exceptions.rb +2 -6
  165. data/lib/sequel/model/inflections.rb +1 -26
  166. data/lib/sequel/model/plugins.rb +1 -0
  167. data/lib/sequel/model.rb +27 -62
  168. data/lib/sequel/plugins/active_model.rb +2 -5
  169. data/lib/sequel/plugins/association_dependencies.rb +15 -15
  170. data/lib/sequel/plugins/association_pks.rb +14 -28
  171. data/lib/sequel/plugins/association_proxies.rb +6 -7
  172. data/lib/sequel/plugins/auto_validations.rb +4 -4
  173. data/lib/sequel/plugins/before_after_save.rb +0 -43
  174. data/lib/sequel/plugins/blacklist_security.rb +9 -8
  175. data/lib/sequel/plugins/boolean_readers.rb +3 -3
  176. data/lib/sequel/plugins/boolean_subsets.rb +2 -2
  177. data/lib/sequel/plugins/caching.rb +5 -5
  178. data/lib/sequel/plugins/class_table_inheritance.rb +71 -102
  179. data/lib/sequel/plugins/column_conflicts.rb +2 -2
  180. data/lib/sequel/plugins/column_select.rb +2 -2
  181. data/lib/sequel/plugins/composition.rb +15 -24
  182. data/lib/sequel/plugins/constraint_validations.rb +4 -3
  183. data/lib/sequel/plugins/csv_serializer.rb +13 -20
  184. data/lib/sequel/plugins/dataset_associations.rb +2 -2
  185. data/lib/sequel/plugins/def_dataset_method.rb +5 -5
  186. data/lib/sequel/plugins/defaults_setter.rb +1 -1
  187. data/lib/sequel/plugins/delay_add_association.rb +1 -1
  188. data/lib/sequel/plugins/finder.rb +16 -10
  189. data/lib/sequel/plugins/force_encoding.rb +1 -7
  190. data/lib/sequel/plugins/hook_class_methods.rb +4 -106
  191. data/lib/sequel/plugins/input_transformer.rb +10 -11
  192. data/lib/sequel/plugins/insert_returning_select.rb +1 -9
  193. data/lib/sequel/plugins/instance_filters.rb +5 -5
  194. data/lib/sequel/plugins/instance_hooks.rb +7 -52
  195. data/lib/sequel/plugins/inverted_subsets.rb +3 -1
  196. data/lib/sequel/plugins/json_serializer.rb +19 -19
  197. data/lib/sequel/plugins/lazy_attributes.rb +1 -10
  198. data/lib/sequel/plugins/list.rb +6 -6
  199. data/lib/sequel/plugins/many_through_many.rb +11 -8
  200. data/lib/sequel/plugins/mssql_optimistic_locking.rb +3 -3
  201. data/lib/sequel/plugins/nested_attributes.rb +18 -31
  202. data/lib/sequel/plugins/optimistic_locking.rb +3 -3
  203. data/lib/sequel/plugins/pg_array_associations.rb +8 -2
  204. data/lib/sequel/plugins/pg_row.rb +2 -11
  205. data/lib/sequel/plugins/prepared_statements.rb +13 -66
  206. data/lib/sequel/plugins/prepared_statements_safe.rb +1 -1
  207. data/lib/sequel/plugins/rcte_tree.rb +7 -7
  208. data/lib/sequel/plugins/serialization.rb +15 -33
  209. data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
  210. data/lib/sequel/plugins/sharding.rb +2 -8
  211. data/lib/sequel/plugins/single_table_inheritance.rb +10 -13
  212. data/lib/sequel/plugins/skip_create_refresh.rb +3 -3
  213. data/lib/sequel/plugins/static_cache.rb +8 -9
  214. data/lib/sequel/plugins/string_stripper.rb +3 -3
  215. data/lib/sequel/plugins/subclasses.rb +1 -1
  216. data/lib/sequel/plugins/subset_conditions.rb +2 -2
  217. data/lib/sequel/plugins/table_select.rb +2 -2
  218. data/lib/sequel/plugins/tactical_eager_loading.rb +4 -4
  219. data/lib/sequel/plugins/timestamps.rb +6 -7
  220. data/lib/sequel/plugins/touch.rb +4 -8
  221. data/lib/sequel/plugins/tree.rb +3 -3
  222. data/lib/sequel/plugins/typecast_on_load.rb +2 -2
  223. data/lib/sequel/plugins/unlimited_update.rb +1 -7
  224. data/lib/sequel/plugins/update_or_create.rb +3 -3
  225. data/lib/sequel/plugins/update_refresh.rb +3 -3
  226. data/lib/sequel/plugins/uuid.rb +7 -11
  227. data/lib/sequel/plugins/validation_class_methods.rb +10 -9
  228. data/lib/sequel/plugins/validation_contexts.rb +4 -4
  229. data/lib/sequel/plugins/validation_helpers.rb +26 -25
  230. data/lib/sequel/plugins/whitelist_security.rb +13 -9
  231. data/lib/sequel/plugins/xml_serializer.rb +24 -25
  232. data/lib/sequel/sql.rb +145 -276
  233. data/lib/sequel/timezones.rb +8 -23
  234. data/lib/sequel/version.rb +2 -2
  235. data/lib/sequel.rb +1 -1
  236. data/spec/adapter_spec.rb +1 -1
  237. data/spec/adapters/db2_spec.rb +2 -103
  238. data/spec/adapters/mssql_spec.rb +89 -68
  239. data/spec/adapters/mysql_spec.rb +111 -478
  240. data/spec/adapters/oracle_spec.rb +1 -9
  241. data/spec/adapters/postgres_spec.rb +459 -664
  242. data/spec/adapters/spec_helper.rb +12 -31
  243. data/spec/adapters/sqlanywhere_spec.rb +2 -77
  244. data/spec/adapters/sqlite_spec.rb +8 -146
  245. data/spec/bin_spec.rb +11 -16
  246. data/spec/core/connection_pool_spec.rb +173 -74
  247. data/spec/core/database_spec.rb +96 -244
  248. data/spec/core/dataset_spec.rb +99 -414
  249. data/spec/core/deprecated_spec.rb +3 -3
  250. data/spec/core/expression_filters_spec.rb +37 -144
  251. data/spec/core/mock_adapter_spec.rb +241 -4
  252. data/spec/core/object_graph_spec.rb +11 -60
  253. data/spec/core/placeholder_literalizer_spec.rb +1 -14
  254. data/spec/core/schema_generator_spec.rb +51 -40
  255. data/spec/core/schema_spec.rb +88 -77
  256. data/spec/core/spec_helper.rb +6 -24
  257. data/spec/core/version_spec.rb +1 -1
  258. data/spec/core_extensions_spec.rb +7 -83
  259. data/spec/core_model_spec.rb +2 -2
  260. data/spec/deprecation_helper.rb +2 -14
  261. data/spec/extensions/accessed_columns_spec.rb +1 -1
  262. data/spec/extensions/active_model_spec.rb +3 -3
  263. data/spec/extensions/after_initialize_spec.rb +1 -1
  264. data/spec/extensions/arbitrary_servers_spec.rb +2 -2
  265. data/spec/extensions/association_dependencies_spec.rb +1 -1
  266. data/spec/extensions/association_pks_spec.rb +30 -92
  267. data/spec/extensions/association_proxies_spec.rb +1 -1
  268. data/spec/extensions/auto_literal_strings_spec.rb +1 -12
  269. data/spec/extensions/auto_validations_spec.rb +1 -1
  270. data/spec/extensions/blacklist_security_spec.rb +1 -1
  271. data/spec/extensions/blank_spec.rb +1 -1
  272. data/spec/extensions/boolean_readers_spec.rb +1 -1
  273. data/spec/extensions/boolean_subsets_spec.rb +1 -1
  274. data/spec/extensions/caching_spec.rb +1 -1
  275. data/spec/extensions/class_table_inheritance_spec.rb +53 -1118
  276. data/spec/extensions/column_conflicts_spec.rb +1 -1
  277. data/spec/extensions/column_select_spec.rb +4 -4
  278. data/spec/extensions/columns_introspection_spec.rb +1 -1
  279. data/spec/extensions/columns_updated_spec.rb +1 -1
  280. data/spec/extensions/composition_spec.rb +8 -30
  281. data/spec/extensions/connection_expiration_spec.rb +3 -3
  282. data/spec/extensions/connection_validator_spec.rb +3 -3
  283. data/spec/extensions/constraint_validations_plugin_spec.rb +1 -1
  284. data/spec/extensions/constraint_validations_spec.rb +1 -1
  285. data/spec/extensions/core_refinements_spec.rb +1 -3
  286. data/spec/extensions/csv_serializer_spec.rb +4 -9
  287. data/spec/extensions/current_datetime_timestamp_spec.rb +1 -1
  288. data/spec/extensions/dataset_associations_spec.rb +2 -1
  289. data/spec/extensions/dataset_source_alias_spec.rb +1 -1
  290. data/spec/extensions/date_arithmetic_spec.rb +3 -3
  291. data/spec/extensions/def_dataset_method_spec.rb +1 -1
  292. data/spec/extensions/defaults_setter_spec.rb +2 -2
  293. data/spec/extensions/delay_add_association_spec.rb +8 -9
  294. data/spec/extensions/dirty_spec.rb +1 -1
  295. data/spec/extensions/duplicate_columns_handler_spec.rb +1 -1
  296. data/spec/extensions/eager_each_spec.rb +2 -2
  297. data/spec/extensions/empty_array_consider_nulls_spec.rb +1 -1
  298. data/spec/extensions/error_splitter_spec.rb +1 -1
  299. data/spec/extensions/error_sql_spec.rb +1 -1
  300. data/spec/extensions/eval_inspect_spec.rb +1 -1
  301. data/spec/extensions/finder_spec.rb +1 -1
  302. data/spec/extensions/force_encoding_spec.rb +2 -5
  303. data/spec/extensions/freeze_datasets_spec.rb +1 -1
  304. data/spec/extensions/graph_each_spec.rb +5 -5
  305. data/spec/extensions/hook_class_methods_spec.rb +1 -194
  306. data/spec/extensions/identifier_mangling_spec.rb +17 -170
  307. data/spec/extensions/implicit_subquery_spec.rb +1 -5
  308. data/spec/extensions/inflector_spec.rb +1 -1
  309. data/spec/extensions/input_transformer_spec.rb +7 -2
  310. data/spec/extensions/insert_returning_select_spec.rb +1 -1
  311. data/spec/extensions/instance_filters_spec.rb +1 -1
  312. data/spec/extensions/instance_hooks_spec.rb +1 -95
  313. data/spec/extensions/inverted_subsets_spec.rb +1 -1
  314. data/spec/extensions/json_serializer_spec.rb +1 -1
  315. data/spec/extensions/lazy_attributes_spec.rb +1 -7
  316. data/spec/extensions/list_spec.rb +5 -6
  317. data/spec/extensions/looser_typecasting_spec.rb +1 -1
  318. data/spec/extensions/many_through_many_spec.rb +25 -33
  319. data/spec/extensions/migration_spec.rb +12 -2
  320. data/spec/extensions/modification_detection_spec.rb +1 -1
  321. data/spec/extensions/mssql_optimistic_locking_spec.rb +1 -1
  322. data/spec/extensions/named_timezones_spec.rb +3 -3
  323. data/spec/extensions/nested_attributes_spec.rb +1 -29
  324. data/spec/extensions/null_dataset_spec.rb +1 -11
  325. data/spec/extensions/optimistic_locking_spec.rb +2 -2
  326. data/spec/extensions/pagination_spec.rb +1 -1
  327. data/spec/extensions/pg_array_associations_spec.rb +22 -26
  328. data/spec/extensions/pg_array_ops_spec.rb +1 -1
  329. data/spec/extensions/pg_array_spec.rb +3 -48
  330. data/spec/extensions/pg_enum_spec.rb +1 -1
  331. data/spec/extensions/pg_extended_date_support_spec.rb +122 -0
  332. data/spec/extensions/pg_hstore_ops_spec.rb +1 -1
  333. data/spec/extensions/pg_hstore_spec.rb +22 -31
  334. data/spec/extensions/pg_inet_ops_spec.rb +1 -1
  335. data/spec/extensions/pg_inet_spec.rb +1 -14
  336. data/spec/extensions/pg_interval_spec.rb +3 -13
  337. data/spec/extensions/pg_json_ops_spec.rb +1 -1
  338. data/spec/extensions/pg_json_spec.rb +1 -13
  339. data/spec/extensions/pg_loose_count_spec.rb +1 -1
  340. data/spec/extensions/pg_range_ops_spec.rb +1 -1
  341. data/spec/extensions/pg_range_spec.rb +3 -88
  342. data/spec/extensions/pg_row_ops_spec.rb +1 -1
  343. data/spec/extensions/pg_row_plugin_spec.rb +1 -1
  344. data/spec/extensions/pg_row_spec.rb +1 -44
  345. data/spec/extensions/pg_static_cache_updater_spec.rb +1 -1
  346. data/spec/extensions/prepared_statements_safe_spec.rb +7 -7
  347. data/spec/extensions/prepared_statements_spec.rb +13 -48
  348. data/spec/extensions/pretty_table_spec.rb +40 -9
  349. data/spec/extensions/query_spec.rb +1 -12
  350. data/spec/extensions/rcte_tree_spec.rb +23 -34
  351. data/spec/extensions/round_timestamps_spec.rb +1 -5
  352. data/spec/extensions/s_spec.rb +1 -1
  353. data/spec/extensions/schema_caching_spec.rb +1 -1
  354. data/spec/extensions/schema_dumper_spec.rb +43 -32
  355. data/spec/extensions/select_remove_spec.rb +1 -1
  356. data/spec/extensions/sequel_4_dataset_methods_spec.rb +1 -1
  357. data/spec/extensions/serialization_modification_detection_spec.rb +1 -1
  358. data/spec/extensions/serialization_spec.rb +5 -17
  359. data/spec/extensions/server_block_spec.rb +1 -1
  360. data/spec/extensions/server_logging_spec.rb +2 -2
  361. data/spec/extensions/sharding_spec.rb +1 -1
  362. data/spec/extensions/shared_caching_spec.rb +1 -28
  363. data/spec/extensions/single_table_inheritance_spec.rb +2 -5
  364. data/spec/extensions/singular_table_names_spec.rb +1 -1
  365. data/spec/extensions/skip_create_refresh_spec.rb +1 -1
  366. data/spec/extensions/spec_helper.rb +5 -27
  367. data/spec/extensions/split_array_nil_spec.rb +1 -1
  368. data/spec/extensions/split_values_spec.rb +1 -1
  369. data/spec/extensions/sql_comments_spec.rb +1 -1
  370. data/spec/extensions/sql_expr_spec.rb +1 -1
  371. data/spec/extensions/static_cache_spec.rb +1 -1
  372. data/spec/extensions/string_agg_spec.rb +2 -2
  373. data/spec/extensions/string_date_time_spec.rb +1 -1
  374. data/spec/extensions/string_stripper_spec.rb +1 -1
  375. data/spec/extensions/subclasses_spec.rb +1 -1
  376. data/spec/extensions/subset_conditions_spec.rb +1 -1
  377. data/spec/extensions/symbol_aref_refinement_spec.rb +1 -1
  378. data/spec/extensions/symbol_as_refinement_spec.rb +1 -1
  379. data/spec/extensions/synchronize_sql_spec.rb +124 -0
  380. data/spec/extensions/table_select_spec.rb +4 -4
  381. data/spec/extensions/tactical_eager_loading_spec.rb +1 -6
  382. data/spec/extensions/thread_local_timezones_spec.rb +1 -1
  383. data/spec/extensions/timestamps_spec.rb +5 -7
  384. data/spec/extensions/to_dot_spec.rb +1 -1
  385. data/spec/extensions/touch_spec.rb +1 -1
  386. data/spec/extensions/tree_spec.rb +1 -1
  387. data/spec/extensions/typecast_on_load_spec.rb +1 -1
  388. data/spec/extensions/unlimited_update_spec.rb +1 -1
  389. data/spec/extensions/update_or_create_spec.rb +12 -16
  390. data/spec/extensions/update_primary_key_spec.rb +4 -3
  391. data/spec/extensions/update_refresh_spec.rb +1 -1
  392. data/spec/extensions/uuid_spec.rb +10 -13
  393. data/spec/extensions/validate_associated_spec.rb +1 -1
  394. data/spec/extensions/validation_class_methods_spec.rb +3 -3
  395. data/spec/extensions/validation_contexts_spec.rb +1 -1
  396. data/spec/extensions/validation_helpers_spec.rb +10 -44
  397. data/spec/extensions/whitelist_security_spec.rb +5 -5
  398. data/spec/extensions/xml_serializer_spec.rb +8 -13
  399. data/spec/guards_helper.rb +2 -1
  400. data/spec/integration/associations_test.rb +1 -23
  401. data/spec/integration/database_test.rb +7 -7
  402. data/spec/integration/dataset_test.rb +12 -47
  403. data/spec/integration/eager_loader_test.rb +1 -1
  404. data/spec/integration/migrator_test.rb +1 -1
  405. data/spec/integration/model_test.rb +4 -82
  406. data/spec/integration/plugin_test.rb +7 -23
  407. data/spec/integration/prepared_statement_test.rb +8 -88
  408. data/spec/integration/schema_test.rb +10 -10
  409. data/spec/integration/spec_helper.rb +17 -21
  410. data/spec/integration/timezone_test.rb +5 -5
  411. data/spec/integration/transaction_test.rb +3 -55
  412. data/spec/integration/type_test.rb +9 -9
  413. data/spec/model/association_reflection_spec.rb +24 -9
  414. data/spec/model/associations_spec.rb +124 -303
  415. data/spec/model/base_spec.rb +43 -137
  416. data/spec/model/class_dataset_methods_spec.rb +2 -20
  417. data/spec/model/dataset_methods_spec.rb +1 -20
  418. data/spec/model/eager_loading_spec.rb +48 -17
  419. data/spec/model/hooks_spec.rb +5 -300
  420. data/spec/model/inflector_spec.rb +1 -1
  421. data/spec/model/model_spec.rb +29 -339
  422. data/spec/model/plugins_spec.rb +2 -16
  423. data/spec/model/record_spec.rb +33 -129
  424. data/spec/model/spec_helper.rb +5 -15
  425. data/spec/model/validations_spec.rb +1 -1
  426. data/spec/sequel_warning.rb +1 -12
  427. metadata +19 -65
  428. data/doc/active_record.rdoc +0 -927
  429. data/lib/sequel/adapters/cubrid.rb +0 -160
  430. data/lib/sequel/adapters/do/mysql.rb +0 -69
  431. data/lib/sequel/adapters/do/postgres.rb +0 -46
  432. data/lib/sequel/adapters/do/sqlite3.rb +0 -41
  433. data/lib/sequel/adapters/do.rb +0 -166
  434. data/lib/sequel/adapters/jdbc/as400.rb +0 -92
  435. data/lib/sequel/adapters/jdbc/cubrid.rb +0 -65
  436. data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -37
  437. data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -34
  438. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -34
  439. data/lib/sequel/adapters/odbc/progress.rb +0 -12
  440. data/lib/sequel/adapters/shared/cubrid.rb +0 -245
  441. data/lib/sequel/adapters/shared/firebird.rb +0 -261
  442. data/lib/sequel/adapters/shared/informix.rb +0 -63
  443. data/lib/sequel/adapters/shared/progress.rb +0 -40
  444. data/lib/sequel/adapters/swift/mysql.rb +0 -50
  445. data/lib/sequel/adapters/swift/postgres.rb +0 -49
  446. data/lib/sequel/adapters/swift/sqlite.rb +0 -48
  447. data/lib/sequel/adapters/swift.rb +0 -169
  448. data/lib/sequel/adapters/utils/pg_types.rb +0 -4
  449. data/lib/sequel/dataset/mutation.rb +0 -98
  450. data/lib/sequel/extensions/_deprecated_identifier_mangling.rb +0 -117
  451. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +0 -8
  452. data/lib/sequel/extensions/filter_having.rb +0 -65
  453. data/lib/sequel/extensions/hash_aliases.rb +0 -51
  454. data/lib/sequel/extensions/meta_def.rb +0 -37
  455. data/lib/sequel/extensions/query_literals.rb +0 -86
  456. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +0 -26
  457. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +0 -133
  458. data/lib/sequel/extensions/set_overrides.rb +0 -82
  459. data/lib/sequel/no_core_ext.rb +0 -4
  460. data/lib/sequel/plugins/association_autoreloading.rb +0 -11
  461. data/lib/sequel/plugins/identifier_columns.rb +0 -49
  462. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +0 -11
  463. data/lib/sequel/plugins/pg_typecast_on_load.rb +0 -90
  464. data/lib/sequel/plugins/prepared_statements_associations.rb +0 -137
  465. data/lib/sequel/plugins/prepared_statements_with_pk.rb +0 -71
  466. data/lib/sequel/plugins/schema.rb +0 -84
  467. data/lib/sequel/plugins/scissors.rb +0 -37
  468. data/spec/core/dataset_mutation_spec.rb +0 -253
  469. data/spec/extensions/_deprecated_identifier_mangling_spec.rb +0 -314
  470. data/spec/extensions/before_after_save_spec.rb +0 -40
  471. data/spec/extensions/filter_having_spec.rb +0 -42
  472. data/spec/extensions/from_block_spec.rb +0 -21
  473. data/spec/extensions/hash_aliases_spec.rb +0 -26
  474. data/spec/extensions/identifier_columns_spec.rb +0 -19
  475. data/spec/extensions/meta_def_spec.rb +0 -35
  476. data/spec/extensions/no_auto_literal_strings_spec.rb +0 -69
  477. data/spec/extensions/pg_typecast_on_load_spec.rb +0 -70
  478. data/spec/extensions/prepared_statements_associations_spec.rb +0 -212
  479. data/spec/extensions/prepared_statements_with_pk_spec.rb +0 -40
  480. data/spec/extensions/query_literals_spec.rb +0 -185
  481. data/spec/extensions/schema_spec.rb +0 -123
  482. data/spec/extensions/scissors_spec.rb +0 -27
  483. data/spec/extensions/sequel_3_dataset_methods_spec.rb +0 -118
  484. data/spec/extensions/set_overrides_spec.rb +0 -75
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe "Dataset" do
4
4
  before do
@@ -50,6 +50,21 @@ describe "Dataset#clone" do
50
50
  it "should create an exact copy of the dataset" do
51
51
  @dataset = @dataset.with_row_proc(Proc.new{|r| r})
52
52
  clone = @dataset.clone
53
+ @dataset.dup.must_be_same_as @dataset
54
+
55
+ if RUBY_VERSION >= '2.4'
56
+ clone.must_be_same_as @dataset
57
+ else
58
+ clone.object_id.wont_equal @dataset.object_id
59
+ clone.class.must_equal @dataset.class
60
+ clone.db.must_equal @dataset.db
61
+ clone.opts.must_equal @dataset.opts
62
+ end
63
+ end
64
+
65
+ it "should create an exact copy of the dataset when given an empty hash" do
66
+ @dataset = @dataset.with_row_proc(Proc.new{|r| r})
67
+ clone = @dataset.clone({})
53
68
 
54
69
  clone.object_id.wont_equal @dataset.object_id
55
70
  clone.class.must_equal @dataset.class
@@ -164,15 +179,12 @@ describe "A simple dataset" do
164
179
  end
165
180
 
166
181
  it "should format an insert statement with hash" do
167
- @dataset.insert_sql(:name => 'wxyz', :price => 342).
168
- must_match(/INSERT INTO test \(name, price\) VALUES \('wxyz', 342\)|INSERT INTO test \(price, name\) VALUES \(342, 'wxyz'\)/)
169
-
170
- @dataset.insert_sql({}).must_equal "INSERT INTO test DEFAULT VALUES"
182
+ @dataset.insert_sql(:name => 'wxyz', :price => 342).must_equal 'INSERT INTO test (name, price) VALUES (\'wxyz\', 342)'
183
+ @dataset.insert_sql({}).must_equal "INSERT INTO test DEFAULT VALUES"
171
184
  end
172
185
 
173
186
  it "should format an insert statement with string keys" do
174
- @dataset.insert_sql('name' => 'wxyz', 'price' => 342).
175
- must_match(/INSERT INTO test \(name, price\) VALUES \('wxyz', 342\)|INSERT INTO test \(price, name\) VALUES \(342, 'wxyz'\)/)
187
+ @dataset.insert_sql('name' => 'wxyz', 'price' => 342).must_equal 'INSERT INTO test (name, price) VALUES (\'wxyz\', 342)'
176
188
  end
177
189
 
178
190
  it "should format an insert statement with an arbitrary value" do
@@ -248,19 +260,17 @@ describe "A dataset with a limit" do
248
260
  @dataset.db.sqls.must_equal ['DELETE FROM a']
249
261
  end
250
262
 
251
- if false #SEQUEL5
252
- it "should raise on #update" do
253
- proc{@dataset.update(:a=>1)}.must_raise(Sequel::InvalidOperation)
254
- end
263
+ it "should raise on #update" do
264
+ proc{@dataset.update(:a=>1)}.must_raise(Sequel::InvalidOperation)
265
+ end
255
266
 
256
- it "should raise on #delete" do
257
- proc{@dataset.delete}.must_raise(Sequel::InvalidOperation)
258
- end
259
-
260
- it "should raise on #truncate" do
261
- proc{@dataset.truncate}.must_raise(Sequel::InvalidOperation)
262
- proc{@dataset.skip_limit_check.truncate}.must_raise(Sequel::InvalidOperation)
263
- end
267
+ it "should raise on #delete" do
268
+ proc{@dataset.delete}.must_raise(Sequel::InvalidOperation)
269
+ end
270
+
271
+ it "should raise on #truncate" do
272
+ proc{@dataset.truncate}.must_raise(Sequel::InvalidOperation)
273
+ proc{@dataset.skip_limit_check.truncate}.must_raise(Sequel::InvalidOperation)
264
274
  end
265
275
  end
266
276
 
@@ -279,19 +289,17 @@ describe "A dataset with an offset" do
279
289
  @dataset.db.sqls.must_equal ['DELETE FROM a']
280
290
  end
281
291
 
282
- if false #SEQUEL5
283
- it "should raise on #update" do
284
- proc{@dataset.update(:a=>1)}.must_raise(Sequel::InvalidOperation)
285
- end
292
+ it "should raise on #update" do
293
+ proc{@dataset.update(:a=>1)}.must_raise(Sequel::InvalidOperation)
294
+ end
286
295
 
287
- it "should raise on #delete" do
288
- proc{@dataset.delete}.must_raise(Sequel::InvalidOperation)
289
- end
290
-
291
- it "should raise on #truncate" do
292
- proc{@dataset.truncate}.must_raise(Sequel::InvalidOperation)
293
- proc{@dataset.skip_limit_check.truncate}.must_raise(Sequel::InvalidOperation)
294
- end
296
+ it "should raise on #delete" do
297
+ proc{@dataset.delete}.must_raise(Sequel::InvalidOperation)
298
+ end
299
+
300
+ it "should raise on #truncate" do
301
+ proc{@dataset.truncate}.must_raise(Sequel::InvalidOperation)
302
+ proc{@dataset.skip_limit_check.truncate}.must_raise(Sequel::InvalidOperation)
295
303
  end
296
304
  end
297
305
 
@@ -351,11 +359,17 @@ describe "Dataset#where" do
351
359
  @d1 = @dataset.where(:region => 'Asia')
352
360
  end
353
361
 
354
- if false # SEQUEL5: remove if
355
- it "should just clone if given no arguments or block" do
362
+ it "should raise Error if given no arguments or block" do
356
363
  proc{@dataset.where}.must_raise Sequel::Error
357
364
  end
358
365
 
366
+ it "should raise Error for arrays/multiple arguments that are not condition specifiers" do
367
+ proc{@dataset.where('a = ?', 1)}.must_raise Sequel::Error
368
+ proc{@dataset.where(['a = ?', 1])}.must_raise Sequel::Error
369
+ proc{@dataset.where({:a=>1}, {:b=>2})}.must_raise Sequel::Error
370
+ proc{@dataset.where([{:a=>1}, {:b=>2}])}.must_raise Sequel::Error
371
+ end
372
+
359
373
  it "should handle nil argument if block is given" do
360
374
  @d1.where(nil){a}.sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND NULL AND a)"
361
375
  end
@@ -363,7 +377,15 @@ describe "Dataset#where" do
363
377
  it "should handle nil argument if block has no existing filter" do
364
378
  @dataset.where(nil).sql.must_equal "SELECT * FROM test WHERE NULL"
365
379
  end
380
+
381
+ deprecated "should handle nil block result has no existing filter" do
382
+ @dataset.where{nil}.sql.must_equal "SELECT * FROM test"
366
383
  end
384
+
385
+ # SEQUEL54
386
+ it "should handle nil block result has no existing filter" do
387
+ @dataset.where{nil}.sql.must_equal "SELECT * FROM test WHERE NULL"
388
+ end if false
367
389
 
368
390
  it "should just clone if given an empty array or hash argument" do
369
391
  @dataset.where({}).sql.must_equal @dataset.sql
@@ -373,84 +395,36 @@ describe "Dataset#where" do
373
395
  @dataset.filter([]).sql.must_equal @dataset.sql
374
396
  end
375
397
 
376
- deprecated "should just clone if given an empty string argument" do
377
- @dataset.where('').sql.must_equal @dataset.sql
378
- @dataset.filter('').sql.must_equal @dataset.sql
379
- end
380
-
381
- deprecated "should just clone if given no arguments or block" do
382
- @dataset.where.sql.must_equal @dataset.sql
383
- @dataset.filter.sql.must_equal @dataset.sql
384
- end
385
-
386
- deprecated "should ignore nil argument if block is given" do
387
- @d1.where(nil){a}.sql.must_equal @d1.where(:a).sql
398
+ it "should raise if no arguments or block" do
399
+ proc{@dataset.where}.must_raise Sequel::Error
400
+ proc{@dataset.filter}.must_raise Sequel::Error
388
401
  end
389
402
 
390
- deprecated "should ignore nil argument if block has no existing filter" do
391
- @dataset.where(nil).sql.must_equal @dataset.sql
403
+ it "should treat nil as NULL argument if block has no existing filter" do
404
+ @dataset.where(nil).sql.must_equal "SELECT * FROM test WHERE NULL"
405
+ @d1.where(nil).sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND NULL)"
392
406
  end
393
407
 
394
408
  it "should work with hashes" do
395
- @dataset.where(:name => 'xyz', :price => 342).select_sql.
396
- must_match(/WHERE \(\(name = 'xyz'\) AND \(price = 342\)\)|WHERE \(\(price = 342\) AND \(name = 'xyz'\)\)/)
397
- end
398
-
399
- deprecated "should handle literal strings in arrays in filter methods" do
400
- @dataset.where([Sequel.lit("a")]).sql.must_equal 'SELECT * FROM test WHERE (a)'
401
- end
402
-
403
- deprecated "should work with a string with placeholders and arguments for those placeholders" do
404
- @dataset.where('price < ? AND id in ?', 100, [1, 2, 3]).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
409
+ @dataset.where(:name => 'xyz', :price => 342).select_sql.must_equal 'SELECT * FROM test WHERE ((name = \'xyz\') AND (price = 342))'
405
410
  end
406
411
 
407
412
  it "should work with a placeholder literal string" do
408
413
  @dataset.where(Sequel.lit('price < ? AND id in ?', 100, [1, 2, 3])).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
409
414
  end
410
415
 
411
- deprecated "should not modify passed array with placeholders" do
412
- a = ['price < ? AND id in ?', 100, 1, 2, 3]
413
- b = a.dup
414
- @dataset.where(a)
415
- b.must_equal a
416
- end
417
-
418
- deprecated "should work with strings (custom SQL expressions)" do
419
- @dataset.where('(a = 1 AND b = 2)').select_sql.must_equal "SELECT * FROM test WHERE ((a = 1 AND b = 2))"
420
- end
421
-
422
416
  it "should work with literal strings" do
423
417
  @dataset.where(Sequel.lit('(a = 1 AND b = 2)')).select_sql.must_equal "SELECT * FROM test WHERE ((a = 1 AND b = 2))"
424
418
  end
425
419
 
426
- deprecated "should work with a string with named placeholders and a hash of placeholder value arguments" do
427
- @dataset.where('price < :price AND id in :ids', :price=>100, :ids=>[1, 2, 3]).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
428
- end
429
-
430
420
  it "should work with named placeholder strings" do
431
421
  @dataset.where(Sequel.lit('price < :price AND id in :ids', :price=>100, :ids=>[1, 2, 3])).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id in (1, 2, 3))"
432
422
  end
433
423
 
434
- deprecated "should not modify passed array with named placeholders" do
435
- a = ['price < :price AND id in :ids', {:price=>100}]
436
- b = a.dup
437
- @dataset.where(a)
438
- b.must_equal a
439
- end
440
-
441
- deprecated "should not replace named placeholders that don't exist in the hash" do
442
- @dataset.where('price < :price AND id in :ids', :price=>100).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id in :ids)"
443
- end
444
-
445
424
  it "should not replace named placeholders that don't exist in the hash when using placeholder strings" do
446
425
  @dataset.where(Sequel.lit('price < :price AND id in :ids', :price=>100)).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id in :ids)"
447
426
  end
448
427
 
449
- deprecated "should raise an error for a mismatched number of placeholders" do
450
- proc{@dataset.where('price < ? AND id in ?', 100).select_sql}.must_raise(Sequel::Error)
451
- proc{@dataset.where('price < ? AND id in ?', 100, [1, 2, 3], 4).select_sql}.must_raise(Sequel::Error)
452
- end
453
-
454
428
  it "should raise an error for a mismatched number of placeholders in placeholder literal strings" do
455
429
  proc{@dataset.where(Sequel.lit('price < ? AND id in ?', 100)).select_sql}.must_raise(Sequel::Error)
456
430
  proc{@dataset.where(Sequel.lit('price < ? AND id in ?', 100, [1, 2, 3], 4)).select_sql}.must_raise(Sequel::Error)
@@ -466,19 +440,10 @@ describe "Dataset#where" do
466
440
  proc{@dataset.where(Sequel.lit(['price < ', ' AND id in '], 100, [1, 2, 3], 4)).select_sql}.must_raise(Sequel::Error)
467
441
  end
468
442
 
469
- deprecated "should handle partial names" do
470
- @dataset.where('price < :price AND id = :p', :p=>2, :price=>100).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id = 2)"
471
- end
472
-
473
443
  it "should handle partial names when using placeholder literal strings" do
474
444
  @dataset.where(Sequel.lit('price < :price AND id = :p', :p=>2, :price=>100)).select_sql.must_equal "SELECT * FROM test WHERE (price < 100 AND id = 2)"
475
445
  end
476
446
 
477
- deprecated "should handle ::cast syntax when no parameters are supplied" do
478
- @dataset.where('price::float = 10', {}).select_sql.must_equal "SELECT * FROM test WHERE (price::float = 10)"
479
- @dataset.where('price::float ? 10', {}).select_sql.must_equal "SELECT * FROM test WHERE (price::float ? 10)"
480
- end
481
-
482
447
  it "should handle ::cast syntax when no parameters are supplied when using placeholder strings" do
483
448
  @dataset.where(Sequel.lit('price::float = 10', {})).select_sql.must_equal "SELECT * FROM test WHERE (price::float = 10)"
484
449
  @dataset.where(Sequel.lit('price::float ? 10', {})).select_sql.must_equal "SELECT * FROM test WHERE (price::float ? 10)"
@@ -490,18 +455,6 @@ describe "Dataset#where" do
490
455
  @d1.update_sql(:GDP => 0).must_equal "UPDATE test SET GDP = 0 WHERE (region = 'Asia')"
491
456
  end
492
457
 
493
- deprecated "should affect select, delete and update statements when using strings" do
494
- @d2 = @dataset.where('region = ?', 'Asia')
495
- @d2.select_sql.must_equal "SELECT * FROM test WHERE (region = 'Asia')"
496
- @d2.delete_sql.must_equal "DELETE FROM test WHERE (region = 'Asia')"
497
- @d2.update_sql(:GDP => 0).must_equal "UPDATE test SET GDP = 0 WHERE (region = 'Asia')"
498
-
499
- @d3 = @dataset.where("a = 1")
500
- @d3.select_sql.must_equal "SELECT * FROM test WHERE (a = 1)"
501
- @d3.delete_sql.must_equal "DELETE FROM test WHERE (a = 1)"
502
- @d3.update_sql(:GDP => 0).must_equal "UPDATE test SET GDP = 0 WHERE (a = 1)"
503
- end
504
-
505
458
  it "should affect select, delete and update statements when using literal strings" do
506
459
  @d2 = @dataset.where(Sequel.lit('region = ?', 'Asia'))
507
460
  @d2.select_sql.must_equal "SELECT * FROM test WHERE (region = 'Asia')"
@@ -521,18 +474,6 @@ describe "Dataset#where" do
521
474
  @d1.where{GDP() > 1000}.select_sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
522
475
  end
523
476
 
524
- deprecated "should be composable using AND operator (for scoping) when using strings" do
525
- @d2 = @dataset.where('region = ?', 'Asia')
526
- @d2.where('GDP > ?', 1000).select_sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
527
- @d2.where(:name => ['Japan', 'China']).select_sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND (name IN ('Japan', 'China')))"
528
- @d2.where('GDP > ?').select_sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > ?))"
529
-
530
- @d3 = @dataset.where("a = 1")
531
- @d3.where('b = 2').select_sql.must_equal "SELECT * FROM test WHERE ((a = 1) AND (b = 2))"
532
- @d3.where(:c => 3).select_sql.must_equal "SELECT * FROM test WHERE ((a = 1) AND (c = 3))"
533
- @d3.where('d = ?', 4).select_sql.must_equal "SELECT * FROM test WHERE ((a = 1) AND (d = 4))"
534
- end
535
-
536
477
  it "should be composable using AND operator (for scoping) when using literal strings" do
537
478
  @d2 = @dataset.where(Sequel.lit('region = ?', 'Asia'))
538
479
  @d2.where(Sequel.lit('GDP > ?', 1000)).select_sql.must_equal "SELECT * FROM test WHERE ((region = 'Asia') AND (GDP > 1000))"
@@ -545,10 +486,6 @@ describe "Dataset#where" do
545
486
  @d3.where(Sequel.lit('d = ?', 4)).select_sql.must_equal "SELECT * FROM test WHERE ((a = 1) AND (d = 4))"
546
487
  end
547
488
 
548
- deprecated "should be composable using AND operator (for scoping) with block and string" do
549
- @dataset.where("a = 1").where{e < 5}.select_sql.must_equal "SELECT * FROM test WHERE ((a = 1) AND (e < 5))"
550
- end
551
-
552
489
  it "should be composable using AND operator (for scoping) with block and literal string" do
553
490
  @dataset.where(Sequel.lit("a = 1")).where{e < 5}.select_sql.must_equal "SELECT * FROM test WHERE ((a = 1) AND (e < 5))"
554
491
  end
@@ -660,20 +597,10 @@ describe "Dataset#where" do
660
597
  @dataset.filter(Sequel::SQLFALSE).sql.must_equal "SELECT * FROM test WHERE (1 = 0)"
661
598
  end
662
599
 
663
- deprecated "should allow the use of multiple arguments" do
664
- @dataset.filter(:a, :b).sql.must_equal 'SELECT * FROM test WHERE (a AND b)'
665
- @dataset.filter(:a, :b=>1).sql.must_equal 'SELECT * FROM test WHERE (a AND (b = 1))'
666
- @dataset.filter(:a, Sequel.expr(:c) > 3, :b=>1).sql.must_equal 'SELECT * FROM test WHERE (a AND (c > 3) AND (b = 1))'
667
- end
668
-
669
600
  it "should allow the use of blocks and arguments simultaneously" do
670
601
  @dataset.filter(Sequel.expr(:zz) < 3){yy > 3}.sql.must_equal 'SELECT * FROM test WHERE ((zz < 3) AND (yy > 3))'
671
602
  end
672
603
 
673
- deprecated "should allow the use of procs" do
674
- @dataset.filter(proc{yy > 3}).sql.must_equal 'SELECT * FROM test WHERE (yy > 3)'
675
- end
676
-
677
604
  it "should yield a VirtualRow to the block" do
678
605
  x = nil
679
606
  @dataset.filter{|r| x = r; false}
@@ -725,18 +652,10 @@ describe "Dataset#or" do
725
652
  @d1.or([]).sql.must_equal @d1.sql
726
653
  end
727
654
 
728
- deprecated "should just clone if given an empty string argument" do
729
- @d1.or('').sql.must_equal @d1.sql
730
- end
731
-
732
655
  it "should add an alternative expression to the where clause" do
733
656
  @d1.or(:y => 2).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) OR (y = 2))'
734
657
  end
735
658
 
736
- deprecated "should accept string filters" do
737
- @d1.or('y > ?', 2).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) OR (y > 2))'
738
- end
739
-
740
659
  it "should accept literal string filters" do
741
660
  @d1.or(Sequel.lit('y > ?', 2)).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) OR (y > 2))'
742
661
  end
@@ -759,42 +678,6 @@ describe "Dataset#or" do
759
678
  end
760
679
  end
761
680
 
762
- describe "Dataset#and" do
763
- before do
764
- @dataset = Sequel.mock.dataset.from(:test)
765
- @d1 = @dataset.where(:x => 1)
766
- end
767
-
768
- deprecated "should add a WHERE filter if none exists" do
769
- @dataset.and(:a => 1).sql.must_equal 'SELECT * FROM test WHERE (a = 1)'
770
- end
771
-
772
- deprecated "should add an expression to the where clause" do
773
- @d1.and(:y => 2).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) AND (y = 2))'
774
- end
775
-
776
- deprecated "should accept string filters with placeholders" do
777
- @d1.and('y > ?', 2).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) AND (y > 2))'
778
- end
779
-
780
- deprecated "should accept placeholder literal string filters" do
781
- @d1.and(Sequel.lit('y > ?', 2)).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) AND (y > 2))'
782
- end
783
-
784
- deprecated "should accept expression filters" do
785
- @d1.and(Sequel.expr(:yy) > 3).sql.must_equal 'SELECT * FROM test WHERE ((x = 1) AND (yy > 3))'
786
- end
787
-
788
- deprecated "should accept blocks passed to filter" do
789
- @d1.and{yy > 3}.sql.must_equal 'SELECT * FROM test WHERE ((x = 1) AND (yy > 3))'
790
- end
791
-
792
- deprecated "should correctly add parens to give predictable results" do
793
- @d1.or(:y => 2).and(:z => 3).sql.must_equal 'SELECT * FROM test WHERE (((x = 1) OR (y = 2)) AND (z = 3))'
794
- @d1.and(:y => 2).or(:z => 3).sql.must_equal 'SELECT * FROM test WHERE (((x = 1) AND (y = 2)) OR (z = 3))'
795
- end
796
- end
797
-
798
681
  describe "Dataset#exclude" do
799
682
  before do
800
683
  @dataset = Sequel.mock.dataset.from(:test)
@@ -805,17 +688,7 @@ describe "Dataset#exclude" do
805
688
  end
806
689
 
807
690
  it "should take multiple conditions as a hash and express the logic correctly in SQL" do
808
- @dataset.exclude(:region => 'Asia', :name => 'Japan').select_sql.
809
- must_match(Regexp.union(/WHERE \(\(region != 'Asia'\) OR \(name != 'Japan'\)\)/,
810
- /WHERE \(\(name != 'Japan'\) OR \(region != 'Asia'\)\)/))
811
- end
812
-
813
- deprecated "should parenthesize a single string condition correctly" do
814
- @dataset.exclude("region = 'Asia' AND name = 'Japan'").select_sql.must_equal "SELECT * FROM test WHERE NOT (region = 'Asia' AND name = 'Japan')"
815
- end
816
-
817
- deprecated "should parenthesize an array condition correctly" do
818
- @dataset.exclude('region = ? AND name = ?', 'Asia', 'Japan').select_sql.must_equal "SELECT * FROM test WHERE NOT (region = 'Asia' AND name = 'Japan')"
691
+ @dataset.exclude(:region => 'Asia', :name => 'Japan').select_sql.must_equal 'SELECT * FROM test WHERE ((region != \'Asia\') OR (name != \'Japan\'))'
819
692
  end
820
693
 
821
694
  it "should parenthesize a single literal string condition correctly" do
@@ -840,24 +713,8 @@ describe "Dataset#exclude" do
840
713
  end
841
714
  end
842
715
 
843
- describe "Dataset#exclude_where" do
844
- before do
845
- @dataset = Sequel.mock.dataset.from(:test)
846
- end
847
-
848
- deprecated "should correctly negate the expression and add it to the where clause" do
849
- @dataset.exclude_where(:region=>'Asia').sql.must_equal "SELECT * FROM test WHERE (region != 'Asia')"
850
- @dataset.exclude_where(:region=>'Asia').exclude_where(:region=>'NA').sql.must_equal "SELECT * FROM test WHERE ((region != 'Asia') AND (region != 'NA'))"
851
- end
852
-
853
- deprecated "should affect the where clause even if having clause is already used" do
854
- @dataset.group_and_count(:name).having{count > 2}.exclude_where(:region=>'Asia').sql.
855
- must_equal "SELECT name, count(*) AS count FROM test WHERE (region != 'Asia') GROUP BY name HAVING (count > 2)"
856
- end
857
- end
858
-
859
716
  describe "Dataset#exclude_having" do
860
- deprecated "should correctly negate the expression and add it to the having clause" do
717
+ it "should correctly negate the expression and add it to the having clause" do
861
718
  Sequel.mock.dataset.from(:test).exclude_having{count > 2}.exclude_having{count < 0}.sql.must_equal "SELECT * FROM test HAVING ((count <= 2) AND (count >= 0))"
862
719
  end
863
720
  end
@@ -893,14 +750,6 @@ describe "Dataset#having" do
893
750
  @dataset.having([]).sql.must_equal @dataset.sql
894
751
  end
895
752
 
896
- deprecated "should just clone if given an empty string argument" do
897
- @dataset.having('').sql.must_equal @dataset.sql
898
- end
899
-
900
- deprecated "should handle string arguments" do
901
- @grouped.having('sum(population) > 10').select_sql.must_equal "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING (sum(population) > 10)"
902
- end
903
-
904
753
  it "should handle literal string arguments" do
905
754
  @grouped.having(Sequel.lit('sum(population) > 10')).select_sql.must_equal "SELECT region, sum(population), avg(gdp) FROM test GROUP BY region HAVING (sum(population) > 10)"
906
755
  end
@@ -2316,8 +2165,9 @@ describe "Dataset#count" do
2316
2165
 
2317
2166
  it "should work on a graphed_dataset" do
2318
2167
  ds = @dataset.with_extend{ def columns; [:a] end}
2319
- @dataset.graph(@dataset, [:a], :table_alias=>:test2).count.must_equal 1
2320
- @db.sqls.must_equal ['SELECT count(*) AS count FROM test LEFT OUTER JOIN test AS test2 USING (a) LIMIT 1']
2168
+ ds.graph(@dataset, [:a], :table_alias=>:test2).count.must_equal 1
2169
+ @dataset.graph(ds, [:a], :table_alias=>:test2).count.must_equal 1
2170
+ @db.sqls.must_equal(['SELECT count(*) AS count FROM test LEFT OUTER JOIN test AS test2 USING (a) LIMIT 1'] * 2)
2321
2171
  end
2322
2172
 
2323
2173
  it "should not cache the columns value" do
@@ -2397,10 +2247,7 @@ describe "Dataset#first_source_alias" do
2397
2247
  end
2398
2248
 
2399
2249
  it "should be the entire first source if not aliased" do
2400
- deprecated do
2401
- # SEQUEL5: Remove deprecation block, but keep code
2402
- @ds.from(:s__t).first_source_alias.must_equal :s__t
2403
- end
2250
+ @ds.from(:s__t).first_source_alias.must_equal :s__t
2404
2251
  end
2405
2252
 
2406
2253
  with_symbol_splitting "should be the alias if aliased when using symbol splitting" do
@@ -2440,10 +2287,7 @@ describe "Dataset#first_source_table" do
2440
2287
 
2441
2288
  it "should be the entire first source if not aliased" do
2442
2289
  @ds.from(:t).first_source_table.must_equal :t
2443
- deprecated do
2444
- # SEQUEL5: Remove deprecation block, but keep code
2445
- @ds.from(:s__t).first_source_table.must_equal :s__t
2446
- end
2290
+ @ds.from(:s__t).first_source_table.must_equal :s__t
2447
2291
  end
2448
2292
 
2449
2293
  it "should be the entire first source if not aliased" do
@@ -2693,10 +2537,6 @@ describe "Dataset#join_table" do
2693
2537
  'RIGHT OUTER JOIN (SELECT * FROM attributes WHERE (name = \'blah\')) AS "t3" ON ("t3"."attribute_id" = "t2"."id")'
2694
2538
  end
2695
2539
 
2696
- deprecated "should support using a string as the join condition" do
2697
- @d.join(:categories, "c.item_id = items.id", :table_alias=>:c).sql.must_equal 'SELECT * FROM "items" INNER JOIN "categories" AS "c" ON (c.item_id = items.id)'
2698
- end
2699
-
2700
2540
  it "should support using a literal string as the join condition" do
2701
2541
  @d.join(:categories, Sequel.lit("c.item_id = items.id"), :table_alias=>:c).sql.must_equal 'SELECT * FROM "items" INNER JOIN "categories" AS "c" ON (c.item_id = items.id)'
2702
2542
  end
@@ -2874,73 +2714,6 @@ describe "Dataset aggregate methods" do
2874
2714
  end
2875
2715
  end
2876
2716
 
2877
- describe "Dataset#range" do
2878
- before do
2879
- @db = Sequel.mock(:fetch=>{:v1 => 1, :v2 => 10})
2880
- @ds = @db[:test].freeze
2881
- end
2882
-
2883
- deprecated "should generate a correct SQL statement" do
2884
- 5.times do
2885
- @ds.range(:stamp)
2886
- @db.sqls.must_equal ["SELECT min(stamp) AS v1, max(stamp) AS v2 FROM test LIMIT 1"]
2887
- end
2888
-
2889
- @ds.filter(Sequel.expr(:price) > 100).range(:stamp)
2890
- @db.sqls.must_equal ["SELECT min(stamp) AS v1, max(stamp) AS v2 FROM test WHERE (price > 100) LIMIT 1"]
2891
- end
2892
-
2893
- deprecated "should return a range object" do
2894
- 5.times do
2895
- @ds.range(:tryme).must_equal(1..10)
2896
- end
2897
- end
2898
-
2899
- deprecated "should use a subselect for the same conditions as count" do
2900
- @ds.order(:stamp).limit(5).range(:stamp).must_equal(1..10)
2901
- @db.sqls.must_equal ['SELECT min(stamp) AS v1, max(stamp) AS v2 FROM (SELECT * FROM test ORDER BY stamp LIMIT 5) AS t1 LIMIT 1']
2902
- end
2903
-
2904
- deprecated "should accept virtual row blocks" do
2905
- 5.times do
2906
- @ds.range{a(b)}
2907
- @db.sqls.must_equal ["SELECT min(a(b)) AS v1, max(a(b)) AS v2 FROM test LIMIT 1"]
2908
- end
2909
- end
2910
- end
2911
-
2912
- describe "Dataset#interval" do
2913
- before do
2914
- @db = Sequel.mock(:fetch=>{:v => 1234})
2915
- @ds = @db[:test].freeze
2916
- end
2917
-
2918
- deprecated "should generate the correct SQL statement" do
2919
- 5.times do
2920
- @ds.interval(:stamp)
2921
- @db.sqls.must_equal ["SELECT (max(stamp) - min(stamp)) AS interval FROM test LIMIT 1"]
2922
- end
2923
-
2924
- @ds.filter(Sequel.expr(:price) > 100).interval(:stamp)
2925
- @db.sqls.must_equal ["SELECT (max(stamp) - min(stamp)) AS interval FROM test WHERE (price > 100) LIMIT 1"]
2926
- end
2927
-
2928
- deprecated "should use a subselect for the same conditions as count" do
2929
- ds = @ds.order(:stamp).limit(5)
2930
- 5.times do
2931
- ds.interval(:stamp).must_equal 1234
2932
- @db.sqls.must_equal ['SELECT (max(stamp) - min(stamp)) AS interval FROM (SELECT * FROM test ORDER BY stamp LIMIT 5) AS t1 LIMIT 1']
2933
- end
2934
- end
2935
-
2936
- deprecated "should accept virtual row blocks" do
2937
- 5.times do
2938
- @ds.interval{a(b)}
2939
- @db.sqls.must_equal ["SELECT (max(a(b)) - min(a(b))) AS interval FROM test LIMIT 1"]
2940
- end
2941
- end
2942
- end
2943
-
2944
2717
  describe "Dataset #first and #last" do
2945
2718
  before do
2946
2719
  @d = Sequel.mock(:fetch=>proc{|s| {:s=>s}})[:test]
@@ -2999,16 +2772,6 @@ describe "Dataset #first and #last" do
2999
2772
  end
3000
2773
  end
3001
2774
 
3002
- deprecated "should combine block and standard argument filters if argument is a string" do
3003
- ds = @d.order(:name).freeze
3004
- 5.times do
3005
- @d.first('y = 25'){z > 26}.must_equal(:s=>'SELECT * FROM test WHERE ((y = 25) AND (z > 26)) LIMIT 1')
3006
- ds.last('y = 16'){z > 26}.must_equal(:s=>'SELECT * FROM test WHERE ((y = 16) AND (z > 26)) ORDER BY name DESC LIMIT 1')
3007
- @d.first('y = ?', 25){z > 26}.must_equal(:s=>'SELECT * FROM test WHERE ((y = 25) AND (z > 26)) LIMIT 1')
3008
- ds.last('y = ?', 16){z > 26}.must_equal(:s=>'SELECT * FROM test WHERE ((y = 16) AND (z > 26)) ORDER BY name DESC LIMIT 1')
3009
- end
3010
- end
3011
-
3012
2775
  it "should filter and return an array of records if an Integer argument is provided and a block is given" do
3013
2776
  ds = @d.order(:a).freeze
3014
2777
  5.times do
@@ -3264,7 +3027,7 @@ describe "Dataset#single_value!" do
3264
3027
 
3265
3028
  it "should call each and return the first value of the first record" do
3266
3029
  @db.fetch = [{:a=>1, :b=>2}, {:a=>3, :b=>4}]
3267
- @db[:test].single_value!.to_s.must_match(/\A(1|2)\z/)
3030
+ @db[:test].single_value!.must_equal 1
3268
3031
  @db.sqls.must_equal ['SELECT * FROM test']
3269
3032
  end
3270
3033
 
@@ -3705,10 +3468,7 @@ describe "Dataset#multi_insert" do
3705
3468
 
3706
3469
  it "should accept string keys as column names" do
3707
3470
  @ds.multi_insert([{'x'=>1, 'y'=>2}, {'x'=>3, 'y'=>4}])
3708
- sqls = @db.sqls
3709
- ["INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (y, x) VALUES (2, 1)"].must_include(sqls.slice!(1))
3710
- ["INSERT INTO items (x, y) VALUES (3, 4)", "INSERT INTO items (y, x) VALUES (4, 3)"].must_include(sqls.slice!(1))
3711
- sqls.must_equal ['BEGIN', 'COMMIT']
3471
+ @db.sqls.must_equal ['BEGIN', "INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (x, y) VALUES (3, 4)", 'COMMIT']
3712
3472
  end
3713
3473
 
3714
3474
  it "should not do anything if no hashes are provided" do
@@ -3722,8 +3482,8 @@ describe "Dataset#update_sql" do
3722
3482
  @ds = Sequel.mock.dataset.from(:items)
3723
3483
  end
3724
3484
 
3725
- deprecated "should accept strings" do
3726
- @ds.update_sql("a = b").must_equal "UPDATE items SET a = b"
3485
+ it "should raise Error for plain strings" do
3486
+ proc{@ds.update_sql("a = b")}.must_raise Sequel::Error
3727
3487
  end
3728
3488
 
3729
3489
  it "should accept literal strings" do
@@ -3817,6 +3577,16 @@ describe "Dataset#insert_sql" do
3817
3577
  it "should use unaliased table name" do
3818
3578
  @ds.from(Sequel.as(:items, :i)).insert_sql(1).must_equal "INSERT INTO items VALUES (1)"
3819
3579
  end
3580
+
3581
+ it "should hoist WITH clauses from query if the dataset doesn't support CTEs in subselects" do
3582
+ @ds = @ds.with_extend do
3583
+ Sequel::Dataset.def_sql_method(self, :insert, %w'with insert into columns values')
3584
+ def supports_cte?(type=:select); true end
3585
+ def supports_cte_in_subselect?; false end
3586
+ end
3587
+ @ds.insert_sql(@ds.from(:foo).with(:foo, @ds.select(:bar))).must_equal 'WITH foo AS (SELECT bar FROM items) INSERT INTO items SELECT * FROM foo'
3588
+ @ds.insert_sql([:a], @ds.from(:foo).with(:foo, @ds.select(:bar))).must_equal 'WITH foo AS (SELECT bar FROM items) INSERT INTO items (a) SELECT * FROM foo'
3589
+ end
3820
3590
  end
3821
3591
 
3822
3592
  describe "Dataset#inspect" do
@@ -4121,6 +3891,15 @@ describe "Dataset prepared statements and bound variables " do
4121
3891
  ]*2)
4122
3892
  end
4123
3893
 
3894
+ it "Dataset#prepare with a delayed evaluation should raise an error" do
3895
+ proc{@ds.where(Sequel.delay{{:n=>1}}).prepare(:select, :select_n)}.must_raise Sequel::Error
3896
+ end
3897
+
3898
+ it "Dataset#call with a delayed evaluation should work" do
3899
+ @ds.where(Sequel.delay{{:n=>1}}).call(:select).must_equal []
3900
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (n = 1)"]
3901
+ end
3902
+
4124
3903
  it "PreparedStatement#prepare should raise an error" do
4125
3904
  ps = @ds.prepare(:select, :select_n)
4126
3905
  proc{ps.prepare(:select, :select_n2)}.must_raise Sequel::Error
@@ -4132,9 +3911,8 @@ describe "Dataset prepared statements and bound variables " do
4132
3911
  @db.sqls.must_equal ["SELECT * FROM items"]
4133
3912
  end
4134
3913
 
4135
- deprecated "#call should default to using :all if an invalid type is given" do
4136
- @ds.filter(:num=>:$n).call(:select_all, :n=>1)
4137
- @db.sqls.must_equal ['SELECT * FROM items WHERE (num = 1)']
3914
+ it "#call should raise Error if an invalid type is given" do
3915
+ proc{@ds.filter(:num=>:$n).call(:select_all, :n=>1)}.must_raise Sequel::Error
4138
3916
  end
4139
3917
 
4140
3918
  it "#inspect should indicate it is a prepared statement with the prepared SQL" do
@@ -4142,11 +3920,6 @@ describe "Dataset prepared statements and bound variables " do
4142
3920
  '<Sequel::Mock::Dataset/PreparedStatement "SELECT * FROM items WHERE (num = $n)">'
4143
3921
  end
4144
3922
 
4145
- deprecated "should handle literal strings" do
4146
- @ds.filter("num = ?", :$n).call(:select, :n=>1)
4147
- @db.sqls.must_equal ['SELECT * FROM items WHERE (num = 1)']
4148
- end
4149
-
4150
3923
  it "should handle literal strings" do
4151
3924
  @ds.filter(Sequel.lit("num = ?", :$n)).call(:select, :n=>1)
4152
3925
  @db.sqls.must_equal ['SELECT * FROM items WHERE (num = 1)']
@@ -4174,11 +3947,6 @@ describe "Dataset prepared statements and bound variables " do
4174
3947
  @db.sqls.must_equal ['SELECT * FROM items WHERE (0 AND (num IN (SELECT num FROM items WHERE (num IN (SELECT num FROM items WHERE (num = 1))))))']
4175
3948
  end
4176
3949
 
4177
- deprecated "should handle subselects with strings" do
4178
- @ds.filter(:$b).filter(:num=>@ds.select(:num).filter("num = ?", :$n)).call(:select, :n=>1, :b=>0)
4179
- @db.sqls.must_equal ['SELECT * FROM items WHERE (0 AND (num IN (SELECT num FROM items WHERE (num = 1))))']
4180
- end
4181
-
4182
3950
  it "should handle subselects with literal strings" do
4183
3951
  @ds.filter(:$b).filter(:num=>@ds.select(:num).filter(Sequel.lit("num = ?", :$n))).call(:select, :n=>1, :b=>0)
4184
3952
  @db.sqls.must_equal ['SELECT * FROM items WHERE (0 AND (num IN (SELECT num FROM items WHERE (num = 1))))']
@@ -4243,13 +4011,12 @@ describe Sequel::Dataset::UnnumberedArgumentMapper do
4243
4011
  "UPDATE items SET num = ? WHERE (num = ?) -- args: [1, 1]"]
4244
4012
  end
4245
4013
 
4246
- deprecated "should handle unrecognized statement types as :all" do
4014
+ it "should raise Error for unrecognized statement types" do
4247
4015
  ps = @ds.prepare(:select_all, :s)
4248
4016
  ps = ps.with_extend(Sequel::Dataset::UnnumberedArgumentMapper)
4249
4017
  sql = ps.prepared_sql
4250
4018
  ps.prepared_sql.must_be_same_as(sql)
4251
- ps.call(:n=>1)
4252
- @db.sqls.must_equal ["SELECT * FROM items WHERE (num = ?) -- args: [1]"]
4019
+ proc{ps.call(:n=>1)}.must_raise Sequel::Error
4253
4020
  end
4254
4021
  end
4255
4022
 
@@ -4396,87 +4163,6 @@ describe "Sequel::Dataset#qualify" do
4396
4163
  end
4397
4164
  end
4398
4165
 
4399
- describe "Sequel::Dataset#unbind" do
4400
- before do
4401
- deprecated do
4402
- @ds = Sequel.mock[:t]
4403
- @u = proc{|ds| ds, bv = ds.unbind; [ds.sql, bv]}
4404
- end
4405
- end
4406
-
4407
- deprecated "should unbind values assigned to equality and inequality statements" do
4408
- @ds.filter(:foo=>1).unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo = $foo)"
4409
- @ds.exclude(:foo=>1).unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo != $foo)"
4410
- @ds.filter{foo > 1}.unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo > $foo)"
4411
- @ds.filter{foo >= 1}.unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo >= $foo)"
4412
- @ds.filter{foo < 1}.unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo < $foo)"
4413
- @ds.filter{foo <= 1}.unbind.first.sql.must_equal "SELECT * FROM t WHERE (foo <= $foo)"
4414
- end
4415
-
4416
- deprecated "should return variables that could be used bound to recreate the previous query" do
4417
- @ds.filter(:foo=>1).unbind.last.must_equal(:foo=>1)
4418
- @ds.exclude(:foo=>1).unbind.last.must_equal(:foo=>1)
4419
- end
4420
-
4421
- deprecated "should return variables as symbols" do
4422
- @ds.filter(Sequel.expr(:foo)=>1).unbind.last.must_equal(:foo=>1)
4423
- @ds.exclude(Sequel.expr(:foo__bar)=>1).unbind.last.must_equal(:"foo.bar"=>1)
4424
- end
4425
-
4426
- deprecated "should handle numerics, strings, dates, times, and datetimes" do
4427
- @u[@ds.filter(:foo=>1)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>1}]
4428
- @u[@ds.filter(:foo=>1.0)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>1.0}]
4429
- @u[@ds.filter(:foo=>BigDecimal.new('1.0'))].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>BigDecimal.new('1.0')}]
4430
- @u[@ds.filter(:foo=>'a')].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>'a'}]
4431
- @u[@ds.filter(:foo=>Date.today)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>Date.today}]
4432
- t = Time.now
4433
- @u[@ds.filter(:foo=>t)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>t}]
4434
- dt = DateTime.now
4435
- @u[@ds.filter(:foo=>dt)].must_equal ["SELECT * FROM t WHERE (foo = $foo)", {:foo=>dt}]
4436
- end
4437
-
4438
- deprecated "should not unbind literal strings" do
4439
- @u[@ds.filter(:foo=>Sequel.lit('a'))].must_equal ["SELECT * FROM t WHERE (foo = a)", {}]
4440
- end
4441
-
4442
- deprecated "should not unbind Identifiers, QualifiedIdentifiers, or Symbols used as booleans" do
4443
- @u[@ds.filter(:foo).filter{bar}.filter{foo__bar}].must_equal ["SELECT * FROM t WHERE (foo AND bar AND foo.bar)", {}]
4444
- end
4445
-
4446
- deprecated "should not unbind for values it doesn't understand" do
4447
- @u[@ds.filter(:foo=>Class.new{def sql_literal(ds) 'bar' end}.new)].must_equal ["SELECT * FROM t WHERE (foo = bar)", {}]
4448
- end
4449
-
4450
- deprecated "should handle QualifiedIdentifiers" do
4451
- @u[@ds.filter{foo__bar > 1}].must_equal ["SELECT * FROM t WHERE (foo.bar > $foo.bar)", {:"foo.bar"=>1}]
4452
- end
4453
-
4454
- deprecated "should handle wrapped objects" do
4455
- @u[@ds.filter{Sequel::SQL::Wrapper.new(foo__bar) > Sequel::SQL::Wrapper.new(1)}].must_equal ["SELECT * FROM t WHERE (foo.bar > $foo.bar)", {:"foo.bar"=>1}]
4456
- end
4457
-
4458
- deprecated "should handle deep nesting" do
4459
- @u[@ds.filter{foo > 1}.and{bar < 2}.or(:baz=>3).and(Sequel.case({~Sequel.expr(:x=>4)=>true}, false))].must_equal ["SELECT * FROM t WHERE ((((foo > $foo) AND (bar < $bar)) OR (baz = $baz)) AND (CASE WHEN (x != $x) THEN 't' ELSE 'f' END))", {:foo=>1, :bar=>2, :baz=>3, :x=>4}]
4460
- end
4461
-
4462
- deprecated "should handle JOIN ON" do
4463
- @u[@ds.cross_join(:x).join(:a, [:u]).join(:b, [[:c, :d], [:e,1]])].must_equal ["SELECT * FROM t CROSS JOIN x INNER JOIN a USING (u) INNER JOIN b ON ((b.c = a.d) AND (b.e = $b.e))", {:"b.e"=>1}]
4464
- end
4465
-
4466
- deprecated "should raise an UnbindDuplicate exception if same variable is used with multiple different values" do
4467
- proc{@ds.filter(:foo=>1).or(:foo=>2).unbind}.must_raise(Sequel::UnbindDuplicate)
4468
- end
4469
-
4470
- deprecated "should handle case where the same variable has the same value in multiple places " do
4471
- @u[@ds.filter(:foo=>1).or(:foo=>1)].must_equal ["SELECT * FROM t WHERE ((foo = $foo) OR (foo = $foo))", {:foo=>1}]
4472
- end
4473
-
4474
- deprecated "should raise Error for unhandled objects inside Identifiers and QualifiedIndentifiers" do
4475
- proc{@ds.filter(Sequel::SQL::Identifier.new([]) > 1).unbind}.must_raise(Sequel::Error)
4476
- proc{@ds.filter{foo.qualify({}) > 1}.unbind}.must_raise(Sequel::Error)
4477
- end
4478
- end
4479
-
4480
4166
  describe "Sequel::Dataset #with and #with_recursive" do
4481
4167
  before do
4482
4168
  @db = Sequel.mock
@@ -5230,7 +4916,7 @@ describe "Dataset extensions" do
5230
4916
  end
5231
4917
  end
5232
4918
  before do
5233
- @ds = Sequel.mock(:identifier_mangling=>false).dataset
4919
+ @ds = Sequel.mock.dataset
5234
4920
  end
5235
4921
 
5236
4922
  it "should be able to register an extension with a module Database#extension extend the module" do
@@ -5271,7 +4957,7 @@ describe "Dataset extensions" do
5271
4957
 
5272
4958
  it "should register a Database extension for modifying all datasets when registering with a module" do
5273
4959
  Sequel::Dataset.register_extension(:foo, Module.new{def a; 1; end})
5274
- Sequel.mock(:identifier_mangling=>false).extension(:foo).dataset.a.must_equal 1
4960
+ Sequel.mock.extension(:foo).dataset.a.must_equal 1
5275
4961
  end
5276
4962
 
5277
4963
  it "should raise an Error if registering with both a module and a block" do
@@ -5648,7 +5334,7 @@ end
5648
5334
 
5649
5335
  describe "Dataset#output_identifier" do
5650
5336
  it "should handle empty identifiers and uppercase identifiers" do
5651
- meth = Sequel::Database.new(:identifier_mangling=>false).dataset.method(:output_identifier)
5337
+ meth = Sequel::Database.new.dataset.method(:output_identifier)
5652
5338
  meth.call('').must_equal :untitled
5653
5339
  meth.call('A').must_equal :a
5654
5340
  end
@@ -5700,7 +5386,6 @@ describe "Dataset#where_single_value" do
5700
5386
 
5701
5387
  it "should return single value" do
5702
5388
  5.times do
5703
- a = []
5704
5389
  @ds.only_id.where_single_value(:id=>1).must_equal 1
5705
5390
  @ds.db.sqls.must_equal ['SELECT id FROM items WHERE (id = 1) LIMIT 1']
5706
5391
  end