sequel 5.29.0 → 5.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (323) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +8 -1922
  3. data/doc/release_notes/5.30.0.txt +20 -0
  4. data/lib/sequel/adapters/shared/sqlite.rb +7 -1
  5. data/lib/sequel/database/transactions.rb +5 -9
  6. data/lib/sequel/version.rb +1 -1
  7. metadata +4 -368
  8. data/Rakefile +0 -151
  9. data/doc/release_notes/4.0.0.txt +0 -262
  10. data/doc/release_notes/4.1.0.txt +0 -85
  11. data/doc/release_notes/4.10.0.txt +0 -226
  12. data/doc/release_notes/4.11.0.txt +0 -147
  13. data/doc/release_notes/4.12.0.txt +0 -105
  14. data/doc/release_notes/4.13.0.txt +0 -169
  15. data/doc/release_notes/4.14.0.txt +0 -68
  16. data/doc/release_notes/4.15.0.txt +0 -56
  17. data/doc/release_notes/4.16.0.txt +0 -36
  18. data/doc/release_notes/4.17.0.txt +0 -38
  19. data/doc/release_notes/4.18.0.txt +0 -36
  20. data/doc/release_notes/4.19.0.txt +0 -45
  21. data/doc/release_notes/4.2.0.txt +0 -129
  22. data/doc/release_notes/4.20.0.txt +0 -79
  23. data/doc/release_notes/4.21.0.txt +0 -94
  24. data/doc/release_notes/4.22.0.txt +0 -72
  25. data/doc/release_notes/4.23.0.txt +0 -65
  26. data/doc/release_notes/4.24.0.txt +0 -99
  27. data/doc/release_notes/4.25.0.txt +0 -181
  28. data/doc/release_notes/4.26.0.txt +0 -44
  29. data/doc/release_notes/4.27.0.txt +0 -78
  30. data/doc/release_notes/4.28.0.txt +0 -57
  31. data/doc/release_notes/4.29.0.txt +0 -41
  32. data/doc/release_notes/4.3.0.txt +0 -40
  33. data/doc/release_notes/4.30.0.txt +0 -37
  34. data/doc/release_notes/4.31.0.txt +0 -57
  35. data/doc/release_notes/4.32.0.txt +0 -132
  36. data/doc/release_notes/4.33.0.txt +0 -88
  37. data/doc/release_notes/4.34.0.txt +0 -86
  38. data/doc/release_notes/4.35.0.txt +0 -130
  39. data/doc/release_notes/4.36.0.txt +0 -116
  40. data/doc/release_notes/4.37.0.txt +0 -50
  41. data/doc/release_notes/4.38.0.txt +0 -67
  42. data/doc/release_notes/4.39.0.txt +0 -127
  43. data/doc/release_notes/4.4.0.txt +0 -92
  44. data/doc/release_notes/4.40.0.txt +0 -179
  45. data/doc/release_notes/4.41.0.txt +0 -77
  46. data/doc/release_notes/4.42.0.txt +0 -221
  47. data/doc/release_notes/4.43.0.txt +0 -87
  48. data/doc/release_notes/4.44.0.txt +0 -125
  49. data/doc/release_notes/4.45.0.txt +0 -370
  50. data/doc/release_notes/4.46.0.txt +0 -404
  51. data/doc/release_notes/4.47.0.txt +0 -56
  52. data/doc/release_notes/4.48.0.txt +0 -293
  53. data/doc/release_notes/4.49.0.txt +0 -222
  54. data/doc/release_notes/4.5.0.txt +0 -34
  55. data/doc/release_notes/4.6.0.txt +0 -30
  56. data/doc/release_notes/4.7.0.txt +0 -103
  57. data/doc/release_notes/4.8.0.txt +0 -175
  58. data/doc/release_notes/4.9.0.txt +0 -190
  59. data/spec/adapter_spec.rb +0 -4
  60. data/spec/adapters/db2_spec.rb +0 -170
  61. data/spec/adapters/mssql_spec.rb +0 -828
  62. data/spec/adapters/mysql_spec.rb +0 -1060
  63. data/spec/adapters/oracle_spec.rb +0 -371
  64. data/spec/adapters/postgres_spec.rb +0 -4476
  65. data/spec/adapters/spec_helper.rb +0 -44
  66. data/spec/adapters/sqlanywhere_spec.rb +0 -97
  67. data/spec/adapters/sqlite_spec.rb +0 -652
  68. data/spec/bin_spec.rb +0 -278
  69. data/spec/core/connection_pool_spec.rb +0 -1250
  70. data/spec/core/database_spec.rb +0 -2915
  71. data/spec/core/dataset_spec.rb +0 -5544
  72. data/spec/core/deprecated_spec.rb +0 -70
  73. data/spec/core/expression_filters_spec.rb +0 -1498
  74. data/spec/core/mock_adapter_spec.rb +0 -722
  75. data/spec/core/object_graph_spec.rb +0 -336
  76. data/spec/core/placeholder_literalizer_spec.rb +0 -166
  77. data/spec/core/schema_generator_spec.rb +0 -214
  78. data/spec/core/schema_spec.rb +0 -1844
  79. data/spec/core/spec_helper.rb +0 -24
  80. data/spec/core/version_spec.rb +0 -14
  81. data/spec/core_extensions_spec.rb +0 -763
  82. data/spec/core_model_spec.rb +0 -2
  83. data/spec/core_spec.rb +0 -1
  84. data/spec/deprecation_helper.rb +0 -30
  85. data/spec/extensions/accessed_columns_spec.rb +0 -51
  86. data/spec/extensions/active_model_spec.rb +0 -99
  87. data/spec/extensions/after_initialize_spec.rb +0 -28
  88. data/spec/extensions/any_not_empty_spec.rb +0 -23
  89. data/spec/extensions/arbitrary_servers_spec.rb +0 -109
  90. data/spec/extensions/association_dependencies_spec.rb +0 -125
  91. data/spec/extensions/association_multi_add_remove_spec.rb +0 -1041
  92. data/spec/extensions/association_pks_spec.rb +0 -423
  93. data/spec/extensions/association_proxies_spec.rb +0 -100
  94. data/spec/extensions/auto_literal_strings_spec.rb +0 -205
  95. data/spec/extensions/auto_validations_spec.rb +0 -229
  96. data/spec/extensions/blacklist_security_spec.rb +0 -95
  97. data/spec/extensions/blank_spec.rb +0 -69
  98. data/spec/extensions/boolean_readers_spec.rb +0 -93
  99. data/spec/extensions/boolean_subsets_spec.rb +0 -47
  100. data/spec/extensions/caching_spec.rb +0 -273
  101. data/spec/extensions/caller_logging_spec.rb +0 -52
  102. data/spec/extensions/class_table_inheritance_spec.rb +0 -750
  103. data/spec/extensions/column_conflicts_spec.rb +0 -75
  104. data/spec/extensions/column_select_spec.rb +0 -129
  105. data/spec/extensions/columns_introspection_spec.rb +0 -90
  106. data/spec/extensions/columns_updated_spec.rb +0 -35
  107. data/spec/extensions/composition_spec.rb +0 -248
  108. data/spec/extensions/connection_expiration_spec.rb +0 -151
  109. data/spec/extensions/connection_validator_spec.rb +0 -144
  110. data/spec/extensions/constant_sql_override_spec.rb +0 -24
  111. data/spec/extensions/constraint_validations_plugin_spec.rb +0 -300
  112. data/spec/extensions/constraint_validations_spec.rb +0 -439
  113. data/spec/extensions/core_refinements_spec.rb +0 -528
  114. data/spec/extensions/csv_serializer_spec.rb +0 -183
  115. data/spec/extensions/current_datetime_timestamp_spec.rb +0 -27
  116. data/spec/extensions/dataset_associations_spec.rb +0 -365
  117. data/spec/extensions/dataset_source_alias_spec.rb +0 -51
  118. data/spec/extensions/date_arithmetic_spec.rb +0 -181
  119. data/spec/extensions/datetime_parse_to_time_spec.rb +0 -169
  120. data/spec/extensions/def_dataset_method_spec.rb +0 -100
  121. data/spec/extensions/defaults_setter_spec.rb +0 -150
  122. data/spec/extensions/delay_add_association_spec.rb +0 -73
  123. data/spec/extensions/dirty_spec.rb +0 -222
  124. data/spec/extensions/duplicate_columns_handler_spec.rb +0 -104
  125. data/spec/extensions/eager_each_spec.rb +0 -62
  126. data/spec/extensions/eager_graph_eager_spec.rb +0 -100
  127. data/spec/extensions/empty_array_consider_nulls_spec.rb +0 -24
  128. data/spec/extensions/empty_failure_backtraces_spec.rb +0 -60
  129. data/spec/extensions/error_splitter_spec.rb +0 -18
  130. data/spec/extensions/error_sql_spec.rb +0 -20
  131. data/spec/extensions/escaped_like_spec.rb +0 -40
  132. data/spec/extensions/eval_inspect_spec.rb +0 -81
  133. data/spec/extensions/exclude_or_null_spec.rb +0 -15
  134. data/spec/extensions/finder_spec.rb +0 -260
  135. data/spec/extensions/force_encoding_spec.rb +0 -126
  136. data/spec/extensions/freeze_datasets_spec.rb +0 -31
  137. data/spec/extensions/graph_each_spec.rb +0 -113
  138. data/spec/extensions/hook_class_methods_spec.rb +0 -402
  139. data/spec/extensions/identifier_mangling_spec.rb +0 -201
  140. data/spec/extensions/implicit_subquery_spec.rb +0 -58
  141. data/spec/extensions/index_caching_spec.rb +0 -66
  142. data/spec/extensions/inflector_spec.rb +0 -183
  143. data/spec/extensions/input_transformer_spec.rb +0 -69
  144. data/spec/extensions/insert_conflict_spec.rb +0 -103
  145. data/spec/extensions/insert_returning_select_spec.rb +0 -72
  146. data/spec/extensions/instance_filters_spec.rb +0 -79
  147. data/spec/extensions/instance_hooks_spec.rb +0 -246
  148. data/spec/extensions/integer64_spec.rb +0 -22
  149. data/spec/extensions/inverted_subsets_spec.rb +0 -33
  150. data/spec/extensions/json_serializer_spec.rb +0 -346
  151. data/spec/extensions/lazy_attributes_spec.rb +0 -183
  152. data/spec/extensions/list_spec.rb +0 -291
  153. data/spec/extensions/looser_typecasting_spec.rb +0 -43
  154. data/spec/extensions/many_through_many_spec.rb +0 -2177
  155. data/spec/extensions/migration_spec.rb +0 -864
  156. data/spec/extensions/modification_detection_spec.rb +0 -93
  157. data/spec/extensions/mssql_optimistic_locking_spec.rb +0 -92
  158. data/spec/extensions/named_timezones_spec.rb +0 -218
  159. data/spec/extensions/nested_attributes_spec.rb +0 -815
  160. data/spec/extensions/null_dataset_spec.rb +0 -85
  161. data/spec/extensions/optimistic_locking_spec.rb +0 -127
  162. data/spec/extensions/pagination_spec.rb +0 -116
  163. data/spec/extensions/pg_array_associations_spec.rb +0 -802
  164. data/spec/extensions/pg_array_ops_spec.rb +0 -144
  165. data/spec/extensions/pg_array_spec.rb +0 -398
  166. data/spec/extensions/pg_auto_constraint_validations_spec.rb +0 -209
  167. data/spec/extensions/pg_enum_spec.rb +0 -118
  168. data/spec/extensions/pg_extended_date_support_spec.rb +0 -126
  169. data/spec/extensions/pg_hstore_ops_spec.rb +0 -238
  170. data/spec/extensions/pg_hstore_spec.rb +0 -219
  171. data/spec/extensions/pg_inet_ops_spec.rb +0 -102
  172. data/spec/extensions/pg_inet_spec.rb +0 -72
  173. data/spec/extensions/pg_interval_spec.rb +0 -103
  174. data/spec/extensions/pg_json_ops_spec.rb +0 -356
  175. data/spec/extensions/pg_json_spec.rb +0 -451
  176. data/spec/extensions/pg_loose_count_spec.rb +0 -23
  177. data/spec/extensions/pg_range_ops_spec.rb +0 -60
  178. data/spec/extensions/pg_range_spec.rb +0 -600
  179. data/spec/extensions/pg_row_ops_spec.rb +0 -61
  180. data/spec/extensions/pg_row_plugin_spec.rb +0 -60
  181. data/spec/extensions/pg_row_spec.rb +0 -363
  182. data/spec/extensions/pg_static_cache_updater_spec.rb +0 -93
  183. data/spec/extensions/pg_timestamptz_spec.rb +0 -17
  184. data/spec/extensions/prepared_statements_safe_spec.rb +0 -66
  185. data/spec/extensions/prepared_statements_spec.rb +0 -177
  186. data/spec/extensions/pretty_table_spec.rb +0 -123
  187. data/spec/extensions/query_spec.rb +0 -94
  188. data/spec/extensions/rcte_tree_spec.rb +0 -387
  189. data/spec/extensions/round_timestamps_spec.rb +0 -39
  190. data/spec/extensions/s_spec.rb +0 -60
  191. data/spec/extensions/schema_caching_spec.rb +0 -64
  192. data/spec/extensions/schema_dumper_spec.rb +0 -870
  193. data/spec/extensions/select_remove_spec.rb +0 -38
  194. data/spec/extensions/sequel_4_dataset_methods_spec.rb +0 -121
  195. data/spec/extensions/serialization_modification_detection_spec.rb +0 -98
  196. data/spec/extensions/serialization_spec.rb +0 -365
  197. data/spec/extensions/server_block_spec.rb +0 -135
  198. data/spec/extensions/server_logging_spec.rb +0 -45
  199. data/spec/extensions/sharding_spec.rb +0 -197
  200. data/spec/extensions/shared_caching_spec.rb +0 -151
  201. data/spec/extensions/single_table_inheritance_spec.rb +0 -347
  202. data/spec/extensions/singular_table_names_spec.rb +0 -22
  203. data/spec/extensions/skip_create_refresh_spec.rb +0 -18
  204. data/spec/extensions/spec_helper.rb +0 -70
  205. data/spec/extensions/split_array_nil_spec.rb +0 -24
  206. data/spec/extensions/split_values_spec.rb +0 -57
  207. data/spec/extensions/sql_comments_spec.rb +0 -33
  208. data/spec/extensions/sql_expr_spec.rb +0 -59
  209. data/spec/extensions/static_cache_cache_spec.rb +0 -35
  210. data/spec/extensions/static_cache_spec.rb +0 -471
  211. data/spec/extensions/string_agg_spec.rb +0 -90
  212. data/spec/extensions/string_date_time_spec.rb +0 -95
  213. data/spec/extensions/string_stripper_spec.rb +0 -68
  214. data/spec/extensions/subclasses_spec.rb +0 -79
  215. data/spec/extensions/subset_conditions_spec.rb +0 -38
  216. data/spec/extensions/symbol_aref_refinement_spec.rb +0 -28
  217. data/spec/extensions/symbol_as_refinement_spec.rb +0 -21
  218. data/spec/extensions/synchronize_sql_spec.rb +0 -124
  219. data/spec/extensions/table_select_spec.rb +0 -83
  220. data/spec/extensions/tactical_eager_loading_spec.rb +0 -402
  221. data/spec/extensions/thread_local_timezones_spec.rb +0 -67
  222. data/spec/extensions/throw_failures_spec.rb +0 -74
  223. data/spec/extensions/timestamps_spec.rb +0 -209
  224. data/spec/extensions/to_dot_spec.rb +0 -153
  225. data/spec/extensions/touch_spec.rb +0 -226
  226. data/spec/extensions/tree_spec.rb +0 -334
  227. data/spec/extensions/typecast_on_load_spec.rb +0 -86
  228. data/spec/extensions/unlimited_update_spec.rb +0 -21
  229. data/spec/extensions/update_or_create_spec.rb +0 -83
  230. data/spec/extensions/update_primary_key_spec.rb +0 -105
  231. data/spec/extensions/update_refresh_spec.rb +0 -59
  232. data/spec/extensions/uuid_spec.rb +0 -101
  233. data/spec/extensions/validate_associated_spec.rb +0 -52
  234. data/spec/extensions/validation_class_methods_spec.rb +0 -1040
  235. data/spec/extensions/validation_contexts_spec.rb +0 -31
  236. data/spec/extensions/validation_helpers_spec.rb +0 -525
  237. data/spec/extensions/whitelist_security_spec.rb +0 -157
  238. data/spec/extensions/xml_serializer_spec.rb +0 -213
  239. data/spec/files/bad_down_migration/001_create_alt_basic.rb +0 -4
  240. data/spec/files/bad_down_migration/002_create_alt_advanced.rb +0 -4
  241. data/spec/files/bad_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  242. data/spec/files/bad_timestamped_migrations/1273253851_create_nodes.rb +0 -9
  243. data/spec/files/bad_timestamped_migrations/1273253853_3_create_users.rb +0 -3
  244. data/spec/files/bad_up_migration/001_create_alt_basic.rb +0 -4
  245. data/spec/files/bad_up_migration/002_create_alt_advanced.rb +0 -3
  246. data/spec/files/convert_to_timestamp_migrations/001_create_sessions.rb +0 -9
  247. data/spec/files/convert_to_timestamp_migrations/002_create_nodes.rb +0 -9
  248. data/spec/files/convert_to_timestamp_migrations/003_3_create_users.rb +0 -4
  249. data/spec/files/convert_to_timestamp_migrations/1273253850_create_artists.rb +0 -9
  250. data/spec/files/convert_to_timestamp_migrations/1273253852_create_albums.rb +0 -9
  251. data/spec/files/double_migration/001_create_sessions.rb +0 -9
  252. data/spec/files/double_migration/002_create_nodes.rb +0 -19
  253. data/spec/files/double_migration/003_3_create_users.rb +0 -4
  254. data/spec/files/duplicate_integer_migrations/001_create_alt_advanced.rb +0 -4
  255. data/spec/files/duplicate_integer_migrations/001_create_alt_basic.rb +0 -4
  256. data/spec/files/duplicate_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  257. data/spec/files/duplicate_timestamped_migrations/1273253853_create_nodes.rb +0 -9
  258. data/spec/files/duplicate_timestamped_migrations/1273253853_create_users.rb +0 -4
  259. data/spec/files/empty_migration/001_create_sessions.rb +0 -9
  260. data/spec/files/empty_migration/002_create_nodes.rb +0 -0
  261. data/spec/files/empty_migration/003_3_create_users.rb +0 -4
  262. data/spec/files/integer_migrations/001_create_sessions.rb +0 -9
  263. data/spec/files/integer_migrations/002_create_nodes.rb +0 -9
  264. data/spec/files/integer_migrations/003_3_create_users.rb +0 -4
  265. data/spec/files/interleaved_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  266. data/spec/files/interleaved_timestamped_migrations/1273253850_create_artists.rb +0 -9
  267. data/spec/files/interleaved_timestamped_migrations/1273253851_create_nodes.rb +0 -9
  268. data/spec/files/interleaved_timestamped_migrations/1273253852_create_albums.rb +0 -9
  269. data/spec/files/interleaved_timestamped_migrations/1273253853_3_create_users.rb +0 -4
  270. data/spec/files/missing_integer_migrations/001_create_alt_basic.rb +0 -4
  271. data/spec/files/missing_integer_migrations/003_create_alt_advanced.rb +0 -4
  272. data/spec/files/missing_timestamped_migrations/1273253849_create_sessions.rb +0 -9
  273. data/spec/files/missing_timestamped_migrations/1273253853_3_create_users.rb +0 -4
  274. data/spec/files/reversible_migrations/001_reversible.rb +0 -5
  275. data/spec/files/reversible_migrations/002_reversible.rb +0 -5
  276. data/spec/files/reversible_migrations/003_reversible.rb +0 -5
  277. data/spec/files/reversible_migrations/004_reversible.rb +0 -5
  278. data/spec/files/reversible_migrations/005_reversible.rb +0 -10
  279. data/spec/files/reversible_migrations/006_reversible.rb +0 -10
  280. data/spec/files/reversible_migrations/007_reversible.rb +0 -10
  281. data/spec/files/timestamped_migrations/1273253849_create_sessions.rb +0 -9
  282. data/spec/files/timestamped_migrations/1273253851_create_nodes.rb +0 -9
  283. data/spec/files/timestamped_migrations/1273253853_3_create_users.rb +0 -4
  284. data/spec/files/transaction_specified_migrations/001_create_alt_basic.rb +0 -4
  285. data/spec/files/transaction_specified_migrations/002_create_basic.rb +0 -4
  286. data/spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb +0 -3
  287. data/spec/files/transaction_unspecified_migrations/002_create_basic.rb +0 -3
  288. data/spec/files/uppercase_timestamped_migrations/1273253849_CREATE_SESSIONS.RB +0 -9
  289. data/spec/files/uppercase_timestamped_migrations/1273253851_CREATE_NODES.RB +0 -9
  290. data/spec/files/uppercase_timestamped_migrations/1273253853_3_CREATE_USERS.RB +0 -4
  291. data/spec/guards_helper.rb +0 -59
  292. data/spec/integration/associations_test.rb +0 -2597
  293. data/spec/integration/database_test.rb +0 -113
  294. data/spec/integration/dataset_test.rb +0 -2037
  295. data/spec/integration/eager_loader_test.rb +0 -687
  296. data/spec/integration/migrator_test.rb +0 -262
  297. data/spec/integration/model_test.rb +0 -203
  298. data/spec/integration/plugin_test.rb +0 -2423
  299. data/spec/integration/prepared_statement_test.rb +0 -405
  300. data/spec/integration/schema_test.rb +0 -903
  301. data/spec/integration/spec_helper.rb +0 -71
  302. data/spec/integration/timezone_test.rb +0 -86
  303. data/spec/integration/transaction_test.rb +0 -603
  304. data/spec/integration/type_test.rb +0 -127
  305. data/spec/model/association_reflection_spec.rb +0 -803
  306. data/spec/model/associations_spec.rb +0 -4738
  307. data/spec/model/base_spec.rb +0 -875
  308. data/spec/model/class_dataset_methods_spec.rb +0 -146
  309. data/spec/model/dataset_methods_spec.rb +0 -198
  310. data/spec/model/eager_loading_spec.rb +0 -2377
  311. data/spec/model/hooks_spec.rb +0 -370
  312. data/spec/model/inflector_spec.rb +0 -26
  313. data/spec/model/model_spec.rb +0 -956
  314. data/spec/model/plugins_spec.rb +0 -429
  315. data/spec/model/record_spec.rb +0 -2118
  316. data/spec/model/spec_helper.rb +0 -46
  317. data/spec/model/validations_spec.rb +0 -220
  318. data/spec/model_no_assoc_spec.rb +0 -1
  319. data/spec/model_spec.rb +0 -1
  320. data/spec/plugin_spec.rb +0 -1
  321. data/spec/sequel_coverage.rb +0 -15
  322. data/spec/sequel_warning.rb +0 -5
  323. data/spec/spec_config.rb +0 -12
@@ -1,451 +0,0 @@
1
- require_relative "spec_helper"
2
-
3
- Sequel.extension :pg_array, :pg_json
4
-
5
- describe "pg_json extension" do
6
- integer_class = RUBY_VERSION >= '2.4' ? Integer : Fixnum
7
-
8
- before(:all) do
9
- m = Sequel::Postgres
10
- @m = m::JSONDatabaseMethods
11
- @hc = m::JSONHash
12
- @ac = m::JSONArray
13
- @bhc = m::JSONBHash
14
- @bac = m::JSONBArray
15
- end
16
- before do
17
- @db = Sequel.connect('mock://postgres')
18
- @db.extend_datasets{def quote_identifiers?; false end}
19
- @db.extension(:pg_array, :pg_json)
20
- end
21
-
22
- it "should set up conversion procs correctly" do
23
- cp = @db.conversion_procs
24
- cp[114].call("{}").must_equal @hc.new({})
25
- cp[3802].call("{}").must_equal @bhc.new({})
26
- end
27
-
28
- it "should set up conversion procs for arrays correctly" do
29
- cp = @db.conversion_procs
30
- cp[199].call("{[]}").must_equal [@ac.new([])]
31
- cp[3807].call("{[]}").must_equal [@bac.new([])]
32
- end
33
-
34
- deprecated "should parse json strings correctly" do
35
- @m.parse_json('[]').class.must_equal(@ac)
36
- @m.parse_json('[]').to_a.must_equal []
37
- @m.parse_json('[1]').to_a.must_equal [1]
38
- @m.parse_json('[1, 2]').to_a.must_equal [1, 2]
39
- @m.parse_json('[1, [2], {"a": "b"}]').to_a.must_equal [1, [2], {'a'=>'b'}]
40
- @m.parse_json('{}').class.must_equal(@hc)
41
- @m.parse_json('{}').to_hash.must_equal({})
42
- @m.parse_json('{"a": "b"}').to_hash.must_equal('a'=>'b')
43
- @m.parse_json('{"a": "b", "c": [1, 2, 3]}').to_hash.must_equal('a'=>'b', 'c'=>[1, 2, 3])
44
- @m.parse_json('{"a": "b", "c": {"d": "e"}}').to_hash.must_equal('a'=>'b', 'c'=>{'d'=>'e'})
45
- proc{@m.parse_json("a")}.must_raise Sequel::InvalidValue
46
-
47
- begin
48
- Sequel.instance_eval do
49
- alias pj parse_json
50
- def parse_json(v)
51
- {'1'=>1, "'a'"=>'a', 'true'=>true, 'false'=>false, 'null'=>nil, 'o'=>Object.new, '[one]'=>[1]}.fetch(v){pj(v)}
52
- end
53
- end
54
- proc{@m.parse_json('o')}.must_raise(Sequel::InvalidValue)
55
- ensure
56
- Sequel.instance_eval do
57
- alias parse_json pj
58
- end
59
- end
60
- end
61
-
62
- deprecated "should parse json and non-json plain strings, integers, and floats correctly in db_parse_json" do
63
- @m.db_parse_json('{"a": "b", "c": {"d": "e"}}').to_hash.must_equal('a'=>'b', 'c'=>{'d'=>'e'})
64
- @m.db_parse_json('[1, [2], {"a": "b"}]').to_a.must_equal [1, [2], {'a'=>'b'}]
65
- @m.db_parse_json('1').must_equal 1
66
- @m.db_parse_json('"b"').must_equal 'b'
67
- @m.db_parse_json('1.1').must_equal 1.1
68
- proc{@m.db_parse_json("a")}.must_raise Sequel::InvalidValue
69
- end
70
-
71
- deprecated "should parse jsonb and non-jsonb plain strings, integers, and floats correctly in db_parse_jsonb" do
72
- @m.db_parse_jsonb('{"a": "b", "c": {"d": "e"}}').to_hash.must_equal('a'=>'b', 'c'=>{'d'=>'e'})
73
- @m.db_parse_jsonb('[1, [2], {"a": "b"}]').to_a.must_equal [1, [2], {'a'=>'b'}]
74
- @m.db_parse_jsonb('1').must_equal 1
75
- @m.db_parse_jsonb('"b"').must_equal 'b'
76
- @m.db_parse_jsonb('1.1').must_equal 1.1
77
- proc{@m.db_parse_jsonb("a")}.must_raise Sequel::InvalidValue
78
- end
79
-
80
- it "should parse json and non-json plain strings, integers, and floats correctly in conversion_proc" do
81
- cp = @db.conversion_procs[114]
82
- cp.call('{"a": "b", "c": {"d": "e"}}').to_hash.must_equal('a'=>'b', 'c'=>{'d'=>'e'})
83
- cp.call('[1, [2], {"a": "b"}]').to_a.must_equal [1, [2], {'a'=>'b'}]
84
- cp.call('1').must_equal 1
85
- cp.call('"b"').must_equal 'b'
86
- cp.call('1.1').must_equal 1.1
87
- end
88
-
89
- it "should parse jsonb and non-jsonb plain strings, integers, and floats correctly in conversion_proc" do
90
- cp = @db.conversion_procs[3802]
91
- cp.call('{"a": "b", "c": {"d": "e"}}').to_hash.must_equal('a'=>'b', 'c'=>{'d'=>'e'})
92
- cp.call('[1, [2], {"a": "b"}]').to_a.must_equal [1, [2], {'a'=>'b'}]
93
- cp.call('1').must_equal 1
94
- cp.call('"b"').must_equal 'b'
95
- cp.call('1.1').must_equal 1.1
96
- end
97
-
98
- it "should raise an error when attempting to parse invalid json" do
99
- [114, 3802].each do |oid|
100
- cp = @db.conversion_procs[oid]
101
- proc{cp.call('a')}.must_raise(Sequel::InvalidValue)
102
-
103
- begin
104
- Sequel.instance_eval do
105
- alias pj parse_json
106
- def parse_json(v)
107
- {'1'=>1, "'a'"=>'a', 'true'=>true, 'false'=>false, 'null'=>nil, 'o'=>Object.new, '[one]'=>[1]}.fetch(v){pj(v)}
108
- end
109
- end
110
- cp.call('1').must_equal 1
111
- cp.call("'a'").must_equal 'a'
112
- cp.call('true').must_equal true
113
- cp.call('false').must_equal false
114
- cp.call('null').must_be_nil
115
- proc{cp.call('o')}.must_raise(Sequel::InvalidValue)
116
- cp.call('one').must_equal 1
117
- ensure
118
- Sequel.instance_eval do
119
- alias parse_json pj
120
- end
121
- end
122
- end
123
- end
124
-
125
- it "should literalize JSONHash and JSONArray to strings correctly" do
126
- @db.literal(Sequel.pg_json([])).must_equal "'[]'::json"
127
- @db.literal(Sequel.pg_json([1, [2], {'a'=>'b'}])).must_equal "'[1,[2],{\"a\":\"b\"}]'::json"
128
- @db.literal(Sequel.pg_json({})).must_equal "'{}'::json"
129
- @db.literal(Sequel.pg_json('a'=>'b')).must_equal "'{\"a\":\"b\"}'::json"
130
- end
131
-
132
- it "should literalize JSONBHash and JSONBArray to strings correctly" do
133
- @db.literal(Sequel.pg_jsonb([])).must_equal "'[]'::jsonb"
134
- @db.literal(Sequel.pg_jsonb([1, [2], {'a'=>'b'}])).must_equal "'[1,[2],{\"a\":\"b\"}]'::jsonb"
135
- @db.literal(Sequel.pg_jsonb({})).must_equal "'{}'::jsonb"
136
- @db.literal(Sequel.pg_jsonb('a'=>'b')).must_equal "'{\"a\":\"b\"}'::jsonb"
137
- end
138
-
139
- it "should have Sequel.pg_json return JSONHash and JSONArray as is" do
140
- a = Sequel.pg_json({})
141
- Sequel.pg_json(a).object_id.must_equal(a.object_id)
142
- a = Sequel.pg_json([])
143
- Sequel.pg_json(a).object_id.must_equal(a.object_id)
144
- end
145
-
146
- it "should have Sequel.pg_json convert jsonb values" do
147
- a = {}
148
- v = Sequel.pg_json(Sequel.pg_jsonb(a))
149
- v.to_hash.must_be_same_as(a)
150
- v.class.must_equal(@hc)
151
-
152
- a = []
153
- v = Sequel.pg_json(Sequel.pg_jsonb(a))
154
- v.to_a.must_be_same_as(a)
155
- v.class.must_equal(@ac)
156
- end
157
-
158
- it "should have Sequel.pg_jsonb return JSONBHash and JSONBArray as is" do
159
- a = Sequel.pg_jsonb({})
160
- Sequel.pg_jsonb(a).object_id.must_equal(a.object_id)
161
- a = Sequel.pg_jsonb([])
162
- Sequel.pg_jsonb(a).object_id.must_equal(a.object_id)
163
- end
164
-
165
- it "should have Sequel.pg_jsonb convert json values" do
166
- a = {}
167
- v = Sequel.pg_jsonb(Sequel.pg_json(a))
168
- v.to_hash.must_be_same_as(a)
169
- v.class.must_equal(@bhc)
170
-
171
- a = []
172
- v = Sequel.pg_jsonb(Sequel.pg_json(a))
173
- v.to_a.must_be_same_as(a)
174
- v.class.must_equal(@bac)
175
- end
176
-
177
- it "should have JSONHashBase#to_hash method for getting underlying hash" do
178
- Sequel.pg_json({}).to_hash.must_be_kind_of(Hash)
179
- Sequel.pg_jsonb({}).to_hash.must_be_kind_of(Hash)
180
- end
181
-
182
- it "should allow aliasing json objects" do
183
- @db.literal(Sequel.pg_json({}).as(:a)).must_equal "'{}'::json AS a"
184
- @db.literal(Sequel.pg_json([]).as(:a)).must_equal "'[]'::json AS a"
185
- @db.literal(Sequel.pg_jsonb({}).as(:a)).must_equal "'{}'::jsonb AS a"
186
- @db.literal(Sequel.pg_jsonb([]).as(:a)).must_equal "'[]'::jsonb AS a"
187
- end
188
-
189
- it "should allow casting json objects" do
190
- @db.literal(Sequel.pg_json({}).cast(String)).must_equal "CAST('{}'::json AS text)"
191
- @db.literal(Sequel.pg_json([]).cast(String)).must_equal "CAST('[]'::json AS text)"
192
- @db.literal(Sequel.pg_jsonb({}).cast(String)).must_equal "CAST('{}'::jsonb AS text)"
193
- @db.literal(Sequel.pg_jsonb([]).cast(String)).must_equal "CAST('[]'::jsonb AS text)"
194
- end
195
-
196
- it "should have JSONArrayBase#to_a method for getting underlying array" do
197
- Sequel.pg_json([]).to_a.must_be_kind_of(Array)
198
- Sequel.pg_jsonb([]).to_a.must_be_kind_of(Array)
199
- end
200
-
201
- it "should support using JSONHashBase and JSONArrayBase as bound variables" do
202
- @db.bound_variable_arg(1, nil).must_equal 1
203
- @db.bound_variable_arg(Sequel.pg_json([1]), nil).must_equal '[1]'
204
- @db.bound_variable_arg(Sequel.pg_json('a'=>'b'), nil).must_equal '{"a":"b"}'
205
- @db.bound_variable_arg(Sequel.pg_jsonb([1]), nil).must_equal '[1]'
206
- @db.bound_variable_arg(Sequel.pg_jsonb('a'=>'b'), nil).must_equal '{"a":"b"}'
207
- end
208
-
209
- it "should support using json[] and jsonb[] types in bound variables" do
210
- @db.bound_variable_arg(Sequel.pg_array([Sequel.pg_json([{"a"=>1}]), Sequel.pg_json("b"=>[1, 2])]), nil).must_equal '{"[{\\"a\\":1}]","{\\"b\\":[1,2]}"}'
211
- @db.bound_variable_arg(Sequel.pg_array([Sequel.pg_jsonb([{"a"=>1}]), Sequel.pg_jsonb("b"=>[1, 2])]), nil).must_equal '{"[{\\"a\\":1}]","{\\"b\\":[1,2]}"}'
212
- end
213
-
214
- it "should support using wrapped JSON and JSONB primitives as bound variables" do
215
- @db.bound_variable_arg(Sequel.pg_json_wrap(1), nil).must_equal '1'
216
- @db.bound_variable_arg(Sequel.pg_json_wrap(2.5), nil).must_equal '2.5'
217
- @db.bound_variable_arg(Sequel.pg_json_wrap('a'), nil).must_equal '"a"'
218
- @db.bound_variable_arg(Sequel.pg_json_wrap(true), nil).must_equal 'true'
219
- @db.bound_variable_arg(Sequel.pg_json_wrap(false), nil).must_equal 'false'
220
- @db.bound_variable_arg(Sequel.pg_json_wrap(nil), nil).must_equal 'null'
221
- end
222
-
223
- it "should support using json[] and jsonb[] types in bound variables with ruby primitives" do
224
- @db.bound_variable_arg(Sequel.pg_array([1, 2.5, 'a', true, false, nil].map{|v| Sequel.pg_json_wrap(v)}), nil).must_equal '{"1","2.5","\"a\"","true","false","null"}'
225
- end
226
-
227
- it "Sequel.pg_json_wrap should wrap Ruby primitives in JSON wrappers" do
228
- Sequel.pg_json_wrap({}).class.must_equal Sequel::Postgres::JSONHash
229
- Sequel.pg_json_wrap({}).must_equal({})
230
- Sequel.pg_json_wrap([]).class.must_equal Sequel::Postgres::JSONArray
231
- Sequel.pg_json_wrap([]).must_equal []
232
- Sequel.pg_json_wrap('a').class.must_equal Sequel::Postgres::JSONString
233
- Sequel.pg_json_wrap('a').must_equal 'a'
234
- Sequel.pg_json_wrap(1).class.must_equal Sequel::Postgres::JSONInteger
235
- Sequel.pg_json_wrap(1).must_equal 1
236
- Sequel.pg_json_wrap(2.5).class.must_equal Sequel::Postgres::JSONFloat
237
- Sequel.pg_json_wrap(2.5).must_equal 2.5
238
- Sequel.pg_json_wrap(true).class.must_equal Sequel::Postgres::JSONTrue
239
- Sequel.pg_json_wrap(true).must_equal true
240
- Sequel.pg_json_wrap(false).class.must_equal Sequel::Postgres::JSONFalse
241
- Sequel.pg_json_wrap(false).must_equal false
242
- Sequel.pg_json_wrap(nil).class.must_equal Sequel::Postgres::JSONNull
243
- Sequel.pg_json_wrap(nil).must_be_nil
244
-
245
- c = Class.new(Hash).new
246
- Sequel.pg_json_wrap(c).class.must_equal Sequel::Postgres::JSONHash
247
- Sequel.pg_json_wrap(c).must_equal(c)
248
-
249
- c = Class.new(Array).new
250
- Sequel.pg_json_wrap(c).class.must_equal Sequel::Postgres::JSONArray
251
- Sequel.pg_json_wrap(c).must_equal c
252
-
253
- c = Class.new(String).new('a')
254
- Sequel.pg_json_wrap(c).class.must_equal Sequel::Postgres::JSONString
255
- Sequel.pg_json_wrap(c).must_equal c
256
- end
257
-
258
- it "Sequel.pg_json_wrap should fail when passed an unsupported object" do
259
- proc{Sequel.pg_json_wrap(Object.new)}.must_raise Sequel::Error
260
- end
261
-
262
- it "Sequel.pg_jsonb_wrap should wrap Ruby primitives in JSONB wrappers" do
263
- Sequel.pg_jsonb_wrap({}).class.must_equal Sequel::Postgres::JSONBHash
264
- Sequel.pg_jsonb_wrap({}).must_equal({})
265
- Sequel.pg_jsonb_wrap([]).class.must_equal Sequel::Postgres::JSONBArray
266
- Sequel.pg_jsonb_wrap([]).must_equal []
267
- Sequel.pg_jsonb_wrap('a').class.must_equal Sequel::Postgres::JSONBString
268
- Sequel.pg_jsonb_wrap('a').must_equal 'a'
269
- Sequel.pg_jsonb_wrap(1).class.must_equal Sequel::Postgres::JSONBInteger
270
- Sequel.pg_jsonb_wrap(1).must_equal 1
271
- Sequel.pg_jsonb_wrap(2.5).class.must_equal Sequel::Postgres::JSONBFloat
272
- Sequel.pg_jsonb_wrap(2.5).must_equal 2.5
273
- Sequel.pg_jsonb_wrap(true).class.must_equal Sequel::Postgres::JSONBTrue
274
- Sequel.pg_jsonb_wrap(true).must_equal true
275
- Sequel.pg_jsonb_wrap(false).class.must_equal Sequel::Postgres::JSONBFalse
276
- Sequel.pg_jsonb_wrap(false).must_equal false
277
- Sequel.pg_jsonb_wrap(nil).class.must_equal Sequel::Postgres::JSONBNull
278
- Sequel.pg_jsonb_wrap(nil).must_be_nil
279
- end
280
-
281
- it "Sequel.pg_jsonb_wrap should fail when passed an unsupported object" do
282
- proc{Sequel.pg_jsonb_wrap(Object.new)}.must_raise Sequel::Error
283
- end
284
-
285
- it "should not wrap JSON primitives in json and jsonb conversion_proc when not setting wrap_json_primitives" do
286
- [114, 3802].each do |oid|
287
- cp = @db.conversion_procs[oid]
288
- cp.call('1').class.must_equal(integer_class)
289
- cp.call('1').must_equal 1
290
- cp.call('2.5').class.must_equal Float
291
- cp.call('2.5').must_equal 2.5
292
- cp.call('"a"').class.must_equal String
293
- cp.call('"a"').must_equal 'a'
294
- cp.call('true').class.must_equal TrueClass
295
- cp.call('true').must_equal true
296
- cp.call('false').class.must_equal FalseClass
297
- cp.call('false').must_equal false
298
- cp.call('null').class.must_equal NilClass
299
- cp.call('null').must_be_nil
300
- end
301
- end
302
-
303
- it "should wrap JSON primitives in json conversion_proc when setting wrap_json_primitives" do
304
- cp = @db.conversion_procs[114]
305
- @db.wrap_json_primitives = true
306
- cp.call('1').class.must_equal Sequel::Postgres::JSONInteger
307
- cp.call('1').must_equal 1
308
- cp.call('2.5').class.must_equal Sequel::Postgres::JSONFloat
309
- cp.call('2.5').must_equal 2.5
310
- cp.call('"a"').class.must_equal Sequel::Postgres::JSONString
311
- cp.call('"a"').must_equal "a"
312
- cp.call('true').class.must_equal Sequel::Postgres::JSONTrue
313
- cp.call('true').must_equal true
314
- cp.call('false').class.must_equal Sequel::Postgres::JSONFalse
315
- cp.call('false').must_equal false
316
- cp.call('null').class.must_equal Sequel::Postgres::JSONNull
317
- cp.call('null').must_be_nil
318
- end
319
-
320
- it "should wrap JSON primitives in jsonb conversion_proc when setting wrap_json_primitives" do
321
- cp = @db.conversion_procs[3802]
322
- @db.wrap_json_primitives = true
323
- cp.call('1').class.must_equal Sequel::Postgres::JSONBInteger
324
- cp.call('1').must_equal 1
325
- cp.call('2.5').class.must_equal Sequel::Postgres::JSONBFloat
326
- cp.call('2.5').must_equal 2.5
327
- cp.call('"a"').class.must_equal Sequel::Postgres::JSONBString
328
- cp.call('"a"').must_equal "a"
329
- cp.call('true').class.must_equal Sequel::Postgres::JSONBTrue
330
- cp.call('true').must_equal true
331
- cp.call('false').class.must_equal Sequel::Postgres::JSONBFalse
332
- cp.call('false').must_equal false
333
- cp.call('null').class.must_equal Sequel::Postgres::JSONBNull
334
- cp.call('null').must_be_nil
335
- end
336
-
337
- it "should parse json type from the schema correctly" do
338
- @db.fetch = [{:name=>'id', :db_type=>'integer'}, {:name=>'i', :db_type=>'json'}]
339
- @db.schema(:items).map{|e| e[1][:type]}.must_equal [:integer, :json]
340
- end
341
-
342
- it "should parse json type from the schema correctly" do
343
- @db.fetch = [{:name=>'id', :db_type=>'integer'}, {:name=>'i', :db_type=>'jsonb'}]
344
- @db.schema(:items).map{|e| e[1][:type]}.must_equal [:integer, :jsonb]
345
- end
346
-
347
- it "should set :callable_default schema entries if default value is recognized" do
348
- @db.fetch = [{:name=>'id', :db_type=>'integer', :default=>'1'}, {:name=>'jh', :db_type=>'json', :default=>"'{}'::json"}, {:name=>'ja', :db_type=>'json', :default=>"'[]'::json"}, {:name=>'jbh', :db_type=>'jsonb', :default=>"'{}'::jsonb"}, {:name=>'jba', :db_type=>'jsonb', :default=>"'[]'::jsonb"}]
349
- s = @db.schema(:items)
350
- s[0][1][:callable_default].must_be_nil
351
- v = s[1][1][:callable_default].call
352
- Sequel::Postgres::JSONHash.===(v).must_equal true
353
- @db.literal(v).must_equal "'{}'::json"
354
- v['a'] = 'b'
355
- @db.literal(v).must_equal "'{\"a\":\"b\"}'::json"
356
-
357
- v = s[2][1][:callable_default].call
358
- Sequel::Postgres::JSONArray.===(v).must_equal true
359
- @db.literal(v).must_equal "'[]'::json"
360
- v << 1
361
- @db.literal(v).must_equal "'[1]'::json"
362
-
363
- v = s[3][1][:callable_default].call
364
- Sequel::Postgres::JSONBHash.===(v).must_equal true
365
- @db.literal(v).must_equal "'{}'::jsonb"
366
- v['a'] = 'b'
367
- @db.literal(v).must_equal "'{\"a\":\"b\"}'::jsonb"
368
-
369
- v = s[4][1][:callable_default].call
370
- Sequel::Postgres::JSONBArray.===(v).must_equal true
371
- @db.literal(v).must_equal "'[]'::jsonb"
372
- v << 1
373
- @db.literal(v).must_equal "'[1]'::jsonb"
374
- end
375
-
376
- it "should support typecasting for the json type" do
377
- h = Sequel.pg_json(1=>2)
378
- a = Sequel.pg_json([1])
379
- @db.typecast_value(:json, h).object_id.must_equal(h.object_id)
380
- @db.typecast_value(:json, h.to_hash).must_equal h
381
- @db.typecast_value(:json, h.to_hash).class.must_equal(@hc)
382
- @db.typecast_value(:json, Sequel.pg_jsonb(h)).must_equal h
383
- @db.typecast_value(:json, Sequel.pg_jsonb(h)).class.must_equal(@hc)
384
- @db.typecast_value(:json, a).object_id.must_equal(a.object_id)
385
- @db.typecast_value(:json, a.to_a).must_equal a
386
- @db.typecast_value(:json, a.to_a).class.must_equal(@ac)
387
- @db.typecast_value(:json, Sequel.pg_jsonb(a)).must_equal a
388
- @db.typecast_value(:json, Sequel.pg_jsonb(a)).class.must_equal(@ac)
389
- @db.typecast_value(:json, '[]').must_equal Sequel.pg_json([])
390
- @db.typecast_value(:json, '[]').class.must_equal(@ac)
391
- @db.typecast_value(:json, '{"a": "b"}').must_equal Sequel.pg_json("a"=>"b")
392
- @db.typecast_value(:json, '{"a": "b"}').class.must_equal(@hc)
393
- @db.typecast_value(:json, 1).class.must_equal Sequel::Postgres::JSONInteger
394
- @db.typecast_value(:json, 1).must_equal 1
395
- @db.typecast_value(:json, 2.5).class.must_equal Sequel::Postgres::JSONFloat
396
- @db.typecast_value(:json, 2.5).must_equal 2.5
397
- @db.typecast_value(:json, true).class.must_equal Sequel::Postgres::JSONTrue
398
- @db.typecast_value(:json, true).must_equal true
399
- @db.typecast_value(:json, false).class.must_equal Sequel::Postgres::JSONFalse
400
- @db.typecast_value(:json, false).must_equal false
401
- @db.typecast_value(:json, nil).class.must_equal NilClass
402
- @db.typecast_value(:json, nil).must_be_nil
403
- proc{@db.typecast_value(:json, 'a')}.must_raise(Sequel::InvalidValue)
404
- proc{@db.typecast_value(:json, Object.new)}.must_raise(Sequel::InvalidValue)
405
-
406
- @db.typecast_json_strings = true
407
- @db.typecast_value(:json, '[]').class.must_equal(Sequel::Postgres::JSONString)
408
- @db.typecast_value(:json, '[]').must_equal '[]'
409
- end
410
-
411
- it "should support typecasting for the jsonb type" do
412
- h = Sequel.pg_jsonb(1=>2)
413
- a = Sequel.pg_jsonb([1])
414
- @db.typecast_value(:jsonb, h).object_id.must_equal(h.object_id)
415
- @db.typecast_value(:jsonb, h.to_hash).must_equal h
416
- @db.typecast_value(:jsonb, h.to_hash).class.must_equal(@bhc)
417
- @db.typecast_value(:jsonb, Sequel.pg_json(h)).must_equal h
418
- @db.typecast_value(:jsonb, Sequel.pg_json(h)).class.must_equal(@bhc)
419
- @db.typecast_value(:jsonb, a).object_id.must_equal(a.object_id)
420
- @db.typecast_value(:jsonb, a.to_a).must_equal a
421
- @db.typecast_value(:jsonb, a.to_a).class.must_equal(@bac)
422
- @db.typecast_value(:jsonb, Sequel.pg_json(a)).must_equal a
423
- @db.typecast_value(:jsonb, Sequel.pg_json(a)).class.must_equal(@bac)
424
- @db.typecast_value(:jsonb, '[]').must_equal Sequel.pg_jsonb([])
425
- @db.typecast_value(:jsonb, '[]').class.must_equal(@bac)
426
- @db.typecast_value(:jsonb, '{"a": "b"}').must_equal Sequel.pg_jsonb("a"=>"b")
427
- @db.typecast_value(:jsonb, '{"a": "b"}').class.must_equal(@bhc)
428
- @db.typecast_value(:jsonb, 1).class.must_equal Sequel::Postgres::JSONBInteger
429
- @db.typecast_value(:jsonb, 1).must_equal 1
430
- @db.typecast_value(:jsonb, 2.5).class.must_equal Sequel::Postgres::JSONBFloat
431
- @db.typecast_value(:jsonb, 2.5).must_equal 2.5
432
- @db.typecast_value(:jsonb, true).class.must_equal Sequel::Postgres::JSONBTrue
433
- @db.typecast_value(:jsonb, true).must_equal true
434
- @db.typecast_value(:jsonb, false).class.must_equal Sequel::Postgres::JSONBFalse
435
- @db.typecast_value(:jsonb, false).must_equal false
436
- @db.typecast_value(:jsonb, nil).class.must_equal NilClass
437
- @db.typecast_value(:jsonb, nil).must_be_nil
438
- proc{@db.typecast_value(:jsonb, 'a')}.must_raise(Sequel::InvalidValue)
439
- proc{@db.typecast_value(:jsonb, Object.new)}.must_raise(Sequel::InvalidValue)
440
-
441
- @db.typecast_json_strings = true
442
- @db.typecast_value(:jsonb, '[]').class.must_equal(Sequel::Postgres::JSONBString)
443
- @db.typecast_value(:jsonb, '[]').must_equal '[]'
444
- end
445
-
446
- it "should return correct results for Database#schema_type_class" do
447
- @db.schema_type_class(:json).must_equal [Sequel::Postgres::JSONObject]
448
- @db.schema_type_class(:jsonb).must_equal [Sequel::Postgres::JSONBObject]
449
- @db.schema_type_class(:integer).must_equal Integer
450
- end
451
- end
@@ -1,23 +0,0 @@
1
- require_relative "spec_helper"
2
-
3
- describe "pg_loose_count extension" do
4
- before do
5
- @db = Sequel.mock(:host=>'postgres', :fetch=>{:v=>1}).extension(:pg_loose_count)
6
- @db.extend_datasets{def quote_identifiers?; false end}
7
- end
8
-
9
- it "should add loose_count method getting fast count for entire table using table statistics" do
10
- @db.loose_count(:a).must_equal 1
11
- @db.sqls.must_equal ["SELECT CAST(reltuples AS integer) AS v FROM pg_class WHERE (oid = CAST(CAST('a' AS regclass) AS oid)) LIMIT 1"]
12
- end
13
-
14
- it "should support schema qualified tables" do
15
- @db.loose_count(Sequel[:a][:b]).must_equal 1
16
- @db.sqls.must_equal ["SELECT CAST(reltuples AS integer) AS v FROM pg_class WHERE (oid = CAST(CAST('a.b' AS regclass) AS oid)) LIMIT 1"]
17
- end
18
-
19
- with_symbol_splitting "should support schema qualified table symbols" do
20
- @db.loose_count(:a__b).must_equal 1
21
- @db.sqls.must_equal ["SELECT CAST(reltuples AS integer) AS v FROM pg_class WHERE (oid = CAST(CAST('a.b' AS regclass) AS oid)) LIMIT 1"]
22
- end
23
- end