sequel 4.30.0 → 4.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +18 -0
  3. data/MIT-LICENSE +1 -1
  4. data/bin/sequel +1 -0
  5. data/doc/opening_databases.rdoc +6 -0
  6. data/doc/release_notes/4.31.0.txt +57 -0
  7. data/lib/sequel.rb +2 -0
  8. data/lib/sequel/adapters/ado.rb +2 -0
  9. data/lib/sequel/adapters/ado/access.rb +2 -0
  10. data/lib/sequel/adapters/ado/mssql.rb +2 -0
  11. data/lib/sequel/adapters/amalgalite.rb +2 -0
  12. data/lib/sequel/adapters/cubrid.rb +2 -0
  13. data/lib/sequel/adapters/do.rb +2 -0
  14. data/lib/sequel/adapters/do/mysql.rb +2 -0
  15. data/lib/sequel/adapters/do/postgres.rb +2 -0
  16. data/lib/sequel/adapters/do/sqlite3.rb +2 -0
  17. data/lib/sequel/adapters/ibmdb.rb +3 -1
  18. data/lib/sequel/adapters/jdbc.rb +2 -0
  19. data/lib/sequel/adapters/jdbc/as400.rb +2 -0
  20. data/lib/sequel/adapters/jdbc/cubrid.rb +2 -0
  21. data/lib/sequel/adapters/jdbc/db2.rb +2 -0
  22. data/lib/sequel/adapters/jdbc/derby.rb +2 -0
  23. data/lib/sequel/adapters/jdbc/firebirdsql.rb +2 -0
  24. data/lib/sequel/adapters/jdbc/h2.rb +2 -0
  25. data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -0
  26. data/lib/sequel/adapters/jdbc/informix-sqli.rb +2 -0
  27. data/lib/sequel/adapters/jdbc/jdbcprogress.rb +2 -0
  28. data/lib/sequel/adapters/jdbc/jtds.rb +2 -0
  29. data/lib/sequel/adapters/jdbc/mssql.rb +2 -0
  30. data/lib/sequel/adapters/jdbc/mysql.rb +2 -0
  31. data/lib/sequel/adapters/jdbc/oracle.rb +2 -0
  32. data/lib/sequel/adapters/jdbc/postgresql.rb +24 -1
  33. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +2 -0
  34. data/lib/sequel/adapters/jdbc/sqlite.rb +2 -0
  35. data/lib/sequel/adapters/jdbc/sqlserver.rb +2 -0
  36. data/lib/sequel/adapters/jdbc/transactions.rb +2 -0
  37. data/lib/sequel/adapters/mock.rb +2 -0
  38. data/lib/sequel/adapters/mysql.rb +2 -0
  39. data/lib/sequel/adapters/mysql2.rb +2 -0
  40. data/lib/sequel/adapters/odbc.rb +2 -0
  41. data/lib/sequel/adapters/odbc/db2.rb +2 -0
  42. data/lib/sequel/adapters/odbc/mssql.rb +2 -0
  43. data/lib/sequel/adapters/odbc/progress.rb +2 -0
  44. data/lib/sequel/adapters/oracle.rb +4 -2
  45. data/lib/sequel/adapters/postgres.rb +5 -3
  46. data/lib/sequel/adapters/postgresql.rb +2 -0
  47. data/lib/sequel/adapters/shared/access.rb +2 -0
  48. data/lib/sequel/adapters/shared/cubrid.rb +2 -0
  49. data/lib/sequel/adapters/shared/db2.rb +2 -0
  50. data/lib/sequel/adapters/shared/firebird.rb +2 -0
  51. data/lib/sequel/adapters/shared/informix.rb +2 -0
  52. data/lib/sequel/adapters/shared/mssql.rb +2 -0
  53. data/lib/sequel/adapters/shared/mysql.rb +5 -1
  54. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +2 -0
  55. data/lib/sequel/adapters/shared/oracle.rb +5 -3
  56. data/lib/sequel/adapters/shared/postgres.rb +19 -12
  57. data/lib/sequel/adapters/shared/progress.rb +2 -0
  58. data/lib/sequel/adapters/shared/sqlanywhere.rb +3 -1
  59. data/lib/sequel/adapters/shared/sqlite.rb +2 -0
  60. data/lib/sequel/adapters/sqlanywhere.rb +2 -0
  61. data/lib/sequel/adapters/sqlite.rb +4 -1
  62. data/lib/sequel/adapters/swift.rb +2 -0
  63. data/lib/sequel/adapters/swift/mysql.rb +2 -0
  64. data/lib/sequel/adapters/swift/postgres.rb +2 -0
  65. data/lib/sequel/adapters/swift/sqlite.rb +2 -0
  66. data/lib/sequel/adapters/tinytds.rb +2 -0
  67. data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +5 -3
  68. data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +5 -3
  69. data/lib/sequel/adapters/utils/pg_types.rb +2 -0
  70. data/lib/sequel/adapters/utils/replace.rb +2 -0
  71. data/lib/sequel/adapters/utils/split_alter_table.rb +2 -0
  72. data/lib/sequel/adapters/utils/stored_procedures.rb +2 -0
  73. data/lib/sequel/ast_transformer.rb +2 -0
  74. data/lib/sequel/connection_pool.rb +2 -0
  75. data/lib/sequel/connection_pool/sharded_single.rb +2 -0
  76. data/lib/sequel/connection_pool/sharded_threaded.rb +2 -0
  77. data/lib/sequel/connection_pool/single.rb +2 -0
  78. data/lib/sequel/connection_pool/threaded.rb +2 -0
  79. data/lib/sequel/core.rb +2 -0
  80. data/lib/sequel/database.rb +2 -0
  81. data/lib/sequel/database/connecting.rb +2 -0
  82. data/lib/sequel/database/dataset.rb +2 -0
  83. data/lib/sequel/database/dataset_defaults.rb +2 -0
  84. data/lib/sequel/database/features.rb +2 -0
  85. data/lib/sequel/database/logging.rb +2 -0
  86. data/lib/sequel/database/misc.rb +2 -0
  87. data/lib/sequel/database/query.rb +2 -0
  88. data/lib/sequel/database/schema_generator.rb +2 -0
  89. data/lib/sequel/database/schema_methods.rb +11 -4
  90. data/lib/sequel/database/transactions.rb +2 -0
  91. data/lib/sequel/dataset.rb +2 -0
  92. data/lib/sequel/dataset/actions.rb +2 -0
  93. data/lib/sequel/dataset/features.rb +2 -0
  94. data/lib/sequel/dataset/graph.rb +2 -0
  95. data/lib/sequel/dataset/misc.rb +2 -0
  96. data/lib/sequel/dataset/mutation.rb +2 -0
  97. data/lib/sequel/dataset/placeholder_literalizer.rb +3 -1
  98. data/lib/sequel/dataset/prepared_statements.rb +2 -0
  99. data/lib/sequel/dataset/query.rb +2 -0
  100. data/lib/sequel/dataset/sql.rb +7 -5
  101. data/lib/sequel/deprecated.rb +2 -0
  102. data/lib/sequel/exceptions.rb +2 -0
  103. data/lib/sequel/extensions/_pretty_table.rb +5 -3
  104. data/lib/sequel/extensions/arbitrary_servers.rb +2 -0
  105. data/lib/sequel/extensions/blank.rb +2 -0
  106. data/lib/sequel/extensions/columns_introspection.rb +2 -0
  107. data/lib/sequel/extensions/connection_validator.rb +2 -0
  108. data/lib/sequel/extensions/constraint_validations.rb +2 -0
  109. data/lib/sequel/extensions/core_extensions.rb +2 -0
  110. data/lib/sequel/extensions/core_refinements.rb +2 -0
  111. data/lib/sequel/extensions/current_datetime_timestamp.rb +2 -0
  112. data/lib/sequel/extensions/dataset_source_alias.rb +2 -0
  113. data/lib/sequel/extensions/date_arithmetic.rb +3 -1
  114. data/lib/sequel/extensions/empty_array_consider_nulls.rb +2 -0
  115. data/lib/sequel/extensions/empty_array_ignore_nulls.rb +2 -0
  116. data/lib/sequel/extensions/error_sql.rb +2 -0
  117. data/lib/sequel/extensions/eval_inspect.rb +2 -0
  118. data/lib/sequel/extensions/filter_having.rb +2 -0
  119. data/lib/sequel/extensions/from_block.rb +2 -0
  120. data/lib/sequel/extensions/graph_each.rb +2 -0
  121. data/lib/sequel/extensions/hash_aliases.rb +2 -0
  122. data/lib/sequel/extensions/inflector.rb +2 -0
  123. data/lib/sequel/extensions/looser_typecasting.rb +2 -0
  124. data/lib/sequel/extensions/meta_def.rb +2 -0
  125. data/lib/sequel/extensions/migration.rb +14 -4
  126. data/lib/sequel/extensions/mssql_emulate_lateral_with_apply.rb +2 -0
  127. data/lib/sequel/extensions/named_timezones.rb +2 -0
  128. data/lib/sequel/extensions/null_dataset.rb +2 -0
  129. data/lib/sequel/extensions/pagination.rb +2 -0
  130. data/lib/sequel/extensions/pg_array.rb +16 -36
  131. data/lib/sequel/extensions/pg_array_ops.rb +2 -0
  132. data/lib/sequel/extensions/pg_enum.rb +4 -1
  133. data/lib/sequel/extensions/pg_hstore.rb +3 -1
  134. data/lib/sequel/extensions/pg_hstore_ops.rb +2 -0
  135. data/lib/sequel/extensions/pg_inet.rb +2 -0
  136. data/lib/sequel/extensions/pg_inet_ops.rb +2 -0
  137. data/lib/sequel/extensions/pg_interval.rb +3 -1
  138. data/lib/sequel/extensions/pg_json.rb +2 -0
  139. data/lib/sequel/extensions/pg_json_ops.rb +2 -0
  140. data/lib/sequel/extensions/pg_loose_count.rb +2 -0
  141. data/lib/sequel/extensions/pg_range.rb +2 -0
  142. data/lib/sequel/extensions/pg_range_ops.rb +2 -0
  143. data/lib/sequel/extensions/pg_row.rb +2 -0
  144. data/lib/sequel/extensions/pg_row_ops.rb +2 -0
  145. data/lib/sequel/extensions/pg_static_cache_updater.rb +2 -0
  146. data/lib/sequel/extensions/pretty_table.rb +2 -0
  147. data/lib/sequel/extensions/query.rb +2 -0
  148. data/lib/sequel/extensions/query_literals.rb +2 -0
  149. data/lib/sequel/extensions/round_timestamps.rb +2 -0
  150. data/lib/sequel/extensions/ruby18_symbol_extensions.rb +2 -0
  151. data/lib/sequel/extensions/schema_caching.rb +2 -0
  152. data/lib/sequel/extensions/schema_dumper.rb +4 -1
  153. data/lib/sequel/extensions/select_remove.rb +2 -0
  154. data/lib/sequel/extensions/sequel_3_dataset_methods.rb +3 -1
  155. data/lib/sequel/extensions/server_block.rb +2 -0
  156. data/lib/sequel/extensions/set_overrides.rb +2 -0
  157. data/lib/sequel/extensions/split_array_nil.rb +2 -0
  158. data/lib/sequel/extensions/sql_expr.rb +2 -0
  159. data/lib/sequel/extensions/string_date_time.rb +2 -0
  160. data/lib/sequel/extensions/thread_local_timezones.rb +2 -0
  161. data/lib/sequel/extensions/to_dot.rb +3 -1
  162. data/lib/sequel/model.rb +2 -0
  163. data/lib/sequel/model/associations.rb +3 -1
  164. data/lib/sequel/model/base.rb +5 -1
  165. data/lib/sequel/model/dataset_module.rb +2 -0
  166. data/lib/sequel/model/default_inflections.rb +2 -0
  167. data/lib/sequel/model/errors.rb +2 -0
  168. data/lib/sequel/model/exceptions.rb +2 -0
  169. data/lib/sequel/model/inflections.rb +2 -0
  170. data/lib/sequel/model/plugins.rb +2 -0
  171. data/lib/sequel/no_core_ext.rb +2 -0
  172. data/lib/sequel/plugins/accessed_columns.rb +2 -0
  173. data/lib/sequel/plugins/active_model.rb +2 -0
  174. data/lib/sequel/plugins/after_initialize.rb +2 -0
  175. data/lib/sequel/plugins/association_autoreloading.rb +2 -0
  176. data/lib/sequel/plugins/association_dependencies.rb +2 -0
  177. data/lib/sequel/plugins/association_pks.rb +20 -24
  178. data/lib/sequel/plugins/association_proxies.rb +2 -0
  179. data/lib/sequel/plugins/auto_validations.rb +2 -0
  180. data/lib/sequel/plugins/before_after_save.rb +2 -0
  181. data/lib/sequel/plugins/blacklist_security.rb +2 -0
  182. data/lib/sequel/plugins/boolean_readers.rb +2 -0
  183. data/lib/sequel/plugins/boolean_subsets.rb +2 -0
  184. data/lib/sequel/plugins/caching.rb +2 -0
  185. data/lib/sequel/plugins/class_table_inheritance.rb +2 -0
  186. data/lib/sequel/plugins/column_conflicts.rb +2 -0
  187. data/lib/sequel/plugins/column_select.rb +2 -0
  188. data/lib/sequel/plugins/composition.rb +2 -0
  189. data/lib/sequel/plugins/constraint_validations.rb +2 -0
  190. data/lib/sequel/plugins/csv_serializer.rb +2 -0
  191. data/lib/sequel/plugins/dataset_associations.rb +2 -0
  192. data/lib/sequel/plugins/defaults_setter.rb +2 -0
  193. data/lib/sequel/plugins/delay_add_association.rb +2 -0
  194. data/lib/sequel/plugins/dirty.rb +2 -0
  195. data/lib/sequel/plugins/eager_each.rb +2 -0
  196. data/lib/sequel/plugins/error_splitter.rb +2 -0
  197. data/lib/sequel/plugins/force_encoding.rb +2 -0
  198. data/lib/sequel/plugins/hook_class_methods.rb +2 -0
  199. data/lib/sequel/plugins/identifier_columns.rb +2 -0
  200. data/lib/sequel/plugins/input_transformer.rb +2 -0
  201. data/lib/sequel/plugins/insert_returning_select.rb +2 -0
  202. data/lib/sequel/plugins/instance_filters.rb +2 -0
  203. data/lib/sequel/plugins/instance_hooks.rb +2 -0
  204. data/lib/sequel/plugins/inverted_subsets.rb +2 -0
  205. data/lib/sequel/plugins/json_serializer.rb +2 -0
  206. data/lib/sequel/plugins/lazy_attributes.rb +2 -0
  207. data/lib/sequel/plugins/list.rb +2 -0
  208. data/lib/sequel/plugins/many_through_many.rb +2 -0
  209. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +2 -0
  210. data/lib/sequel/plugins/modification_detection.rb +2 -0
  211. data/lib/sequel/plugins/mssql_optimistic_locking.rb +2 -0
  212. data/lib/sequel/plugins/nested_attributes.rb +2 -0
  213. data/lib/sequel/plugins/optimistic_locking.rb +2 -0
  214. data/lib/sequel/plugins/pg_array_associations.rb +2 -0
  215. data/lib/sequel/plugins/pg_row.rb +2 -0
  216. data/lib/sequel/plugins/pg_typecast_on_load.rb +2 -0
  217. data/lib/sequel/plugins/prepared_statements.rb +2 -0
  218. data/lib/sequel/plugins/prepared_statements_associations.rb +2 -0
  219. data/lib/sequel/plugins/prepared_statements_safe.rb +2 -0
  220. data/lib/sequel/plugins/prepared_statements_with_pk.rb +2 -0
  221. data/lib/sequel/plugins/rcte_tree.rb +2 -0
  222. data/lib/sequel/plugins/schema.rb +2 -0
  223. data/lib/sequel/plugins/scissors.rb +2 -0
  224. data/lib/sequel/plugins/serialization.rb +2 -0
  225. data/lib/sequel/plugins/serialization_modification_detection.rb +2 -0
  226. data/lib/sequel/plugins/sharding.rb +2 -0
  227. data/lib/sequel/plugins/single_table_inheritance.rb +2 -0
  228. data/lib/sequel/plugins/singular_table_names.rb +2 -0
  229. data/lib/sequel/plugins/skip_create_refresh.rb +2 -0
  230. data/lib/sequel/plugins/split_values.rb +2 -0
  231. data/lib/sequel/plugins/static_cache.rb +2 -0
  232. data/lib/sequel/plugins/string_stripper.rb +2 -0
  233. data/lib/sequel/plugins/subclasses.rb +2 -0
  234. data/lib/sequel/plugins/subset_conditions.rb +2 -0
  235. data/lib/sequel/plugins/table_select.rb +2 -0
  236. data/lib/sequel/plugins/tactical_eager_loading.rb +2 -0
  237. data/lib/sequel/plugins/timestamps.rb +2 -0
  238. data/lib/sequel/plugins/touch.rb +2 -0
  239. data/lib/sequel/plugins/tree.rb +2 -0
  240. data/lib/sequel/plugins/typecast_on_load.rb +2 -0
  241. data/lib/sequel/plugins/unlimited_update.rb +2 -0
  242. data/lib/sequel/plugins/update_or_create.rb +2 -0
  243. data/lib/sequel/plugins/update_primary_key.rb +2 -0
  244. data/lib/sequel/plugins/update_refresh.rb +2 -0
  245. data/lib/sequel/plugins/uuid.rb +2 -0
  246. data/lib/sequel/plugins/validate_associated.rb +2 -0
  247. data/lib/sequel/plugins/validation_class_methods.rb +2 -0
  248. data/lib/sequel/plugins/validation_helpers.rb +3 -1
  249. data/lib/sequel/plugins/xml_serializer.rb +2 -0
  250. data/lib/sequel/sql.rb +3 -1
  251. data/lib/sequel/timezones.rb +2 -0
  252. data/lib/sequel/version.rb +3 -1
  253. data/spec/adapters/mysql_spec.rb +4 -0
  254. data/spec/adapters/postgres_spec.rb +35 -11
  255. data/spec/core/connection_pool_spec.rb +1 -1
  256. data/spec/extensions/association_pks_spec.rb +4 -2
  257. data/spec/extensions/caching_spec.rb +1 -1
  258. data/spec/extensions/csv_serializer_spec.rb +7 -0
  259. data/spec/extensions/date_arithmetic_spec.rb +1 -1
  260. data/spec/extensions/dirty_spec.rb +6 -6
  261. data/spec/extensions/force_encoding_spec.rb +12 -12
  262. data/spec/extensions/input_transformer_spec.rb +1 -1
  263. data/spec/extensions/migration_spec.rb +16 -0
  264. data/spec/extensions/modification_detection_spec.rb +2 -2
  265. data/spec/extensions/nested_attributes_spec.rb +1 -1
  266. data/spec/extensions/optimistic_locking_spec.rb +1 -1
  267. data/spec/extensions/pg_array_spec.rb +3 -8
  268. data/spec/files/double_migration/001_create_sessions.rb +9 -0
  269. data/spec/files/double_migration/002_create_nodes.rb +19 -0
  270. data/spec/files/double_migration/003_3_create_users.rb +4 -0
  271. data/spec/files/empty_migration/001_create_sessions.rb +9 -0
  272. data/spec/files/empty_migration/002_create_nodes.rb +0 -0
  273. data/spec/files/empty_migration/003_3_create_users.rb +4 -0
  274. metadata +11 -3
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The prepared_statements_safe plugin modifies the model to reduce the number of
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The prepared_statements_with_pk plugin allows Dataset#with_pk for model datasets
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # = Overview
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # Sequel's built in schema plugin allows you to define your schema
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The scissors plugin adds class methods for update, delete, and destroy.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # Sequel's built in Serialization plugin allows you to keep serialized
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # This plugin extends the serialization plugin and enables it to detect
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The sharding plugin augments Sequel's default model sharding support
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The single_table_inheritance plugin allows storing all objects
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The singular_table_names plugin changes the default
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # SkipCreateRefresh is a simple plugin that make Sequel not
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The split_values plugin splits the values hash retreived from the
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The static_cache plugin is designed for models that are not modified at all
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # StringStripper is a plugin that strips all input strings
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The Subclasses plugin keeps track of all subclasses of the
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The subset_conditions plugin creates an additional *_conditions method
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The table_select plugin changes the default selection for a
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The tactical_eager_loading plugin allows you to eagerly load
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The timestamps plugin creates hooks that automatically set create and
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The touch plugin adds a touch method to model instances, which saves
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The Tree plugin adds additional associations and methods that allow you to
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The TypecastOnLoad plugin exists because most of Sequel's database adapters don't
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The unlimited_update plugin is designed to work around a
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The update_or_create plugin adds a couple of methods that make it easier
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The update_primary_key plugin allows you to modify an object's
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The update_refresh plugin makes the model class refresh
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  module Sequel
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The validates_associated plugin allows you to validate associated
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  extension :blank
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  module Plugins
3
5
  # The validation_helpers plugin contains instance method equivalents for most of the legacy
@@ -214,7 +216,7 @@ module Sequel
214
216
  # a modified dataset that is filtered to include only rows with
215
217
  # the same values as the current object for each column in the array.
216
218
  #
217
- # If you want to to a case insensitive uniqueness validation on a database that
219
+ # If you want to do a case insensitive uniqueness validation on a database that
218
220
  # is case sensitive by default, you can use:
219
221
  #
220
222
  # validates_unique :column, :where=>(proc do |ds, obj, cols|
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require 'nokogiri'
2
4
 
3
5
  module Sequel
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  if RUBY_VERSION < '1.9.0'
3
5
  # :nocov:
@@ -137,7 +139,7 @@ module Sequel
137
139
 
138
140
  # Alias of +to_s+
139
141
  def sql_literal(ds)
140
- s = ''
142
+ s = String.new
141
143
  to_s_append(ds, s)
142
144
  s
143
145
  end
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  @application_timezone = nil
3
5
  @database_timezone = nil
@@ -1,9 +1,11 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  # The major version of Sequel. Only bumped for major changes.
3
5
  MAJOR = 4
4
6
  # The minor version of Sequel. Bumped for every non-patch level
5
7
  # release, generally around once a month.
6
- MINOR = 30
8
+ MINOR = 31
7
9
  # The tiny version of Sequel. Usually 0, only bumped for bugfix
8
10
  # releases that fix regressions from previous versions.
9
11
  TINY = 0
@@ -640,6 +640,10 @@ describe "MySQL foreign key support" do
640
640
  DB.create_table!(:testfk){primary_key :id; foreign_key :fk, :testfk}
641
641
  end
642
642
 
643
+ it "should create table with self referential with non-autoincrementing key without :key" do
644
+ DB.create_table!(:testfk){Integer :id, :primary_key=>true; foreign_key :fk, :testfk}
645
+ end
646
+
643
647
  it "should create table with self referential with composite keys without :key" do
644
648
  DB.create_table!(:testfk){Integer :id; Integer :id2; Integer :fk; Integer :fk2; primary_key([:id, :id2]); foreign_key([:fk, :fk2], :testfk)}
645
649
  end
@@ -2289,6 +2289,30 @@ describe 'PostgreSQL array handling' do
2289
2289
  end
2290
2290
  end
2291
2291
 
2292
+ it 'retrieve arrays with explicit bounds' do
2293
+ @db.create_table!(:items) do
2294
+ column :n, 'integer[]'
2295
+ end
2296
+ @ds.insert(:n=>"[0:1]={2,3}")
2297
+ rs = @ds.all
2298
+ rs.must_equal [{:n=>[2,3]}]
2299
+ rs.first.values.each{|v| v.class.must_equal(Sequel::Postgres::PGArray)}
2300
+ rs.first.values.each{|v| v.to_a.must_be_kind_of(Array)}
2301
+ @ds.delete
2302
+ @ds.insert(rs.first)
2303
+ @ds.all.must_equal rs
2304
+
2305
+ @ds.delete
2306
+ @ds.insert(:n=>"[0:1][0:0]={{2},{3}}")
2307
+ rs = @ds.all
2308
+ rs.must_equal [{:n=>[[2], [3]]}]
2309
+ rs.first.values.each{|v| v.class.must_equal(Sequel::Postgres::PGArray)}
2310
+ rs.first.values.each{|v| v.to_a.must_be_kind_of(Array)}
2311
+ @ds.delete
2312
+ @ds.insert(rs.first)
2313
+ @ds.all.must_equal rs
2314
+ end if DB.adapter_scheme == :postgres || DB.adapter_scheme == :jdbc
2315
+
2292
2316
  it 'use arrays in bound variables' do
2293
2317
  @db.create_table!(:items) do
2294
2318
  column :i, 'int4[]'
@@ -2347,7 +2371,7 @@ describe 'PostgreSQL array handling' do
2347
2371
  @ds.get(:i).must_equal a
2348
2372
  @ds.filter(:i=>:$i).call(:first, :i=>a).must_equal(:i=>a)
2349
2373
  @ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([Sequel.blob("b\0")], 'bytea')).must_equal nil
2350
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
2374
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
2351
2375
 
2352
2376
  it 'with models' do
2353
2377
  @db.create_table!(:items) do
@@ -2535,7 +2559,7 @@ describe 'PostgreSQL hstore handling' do
2535
2559
  @ds.get(:i).must_equal @h
2536
2560
  @ds.filter(:i=>:$i).call(:first, :i=>@h).must_equal(:i=>@h)
2537
2561
  @ds.filter(:i=>:$i).call(:first, :i=>{}).must_equal nil
2538
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
2562
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
2539
2563
 
2540
2564
  it 'with models and associations' do
2541
2565
  @db.create_table!(:items) do
@@ -2808,7 +2832,7 @@ describe 'PostgreSQL json type' do
2808
2832
  j = Sequel.pg_array([pg_json.call('a'=>1), pg_json.call(['b', 2])], json_type)
2809
2833
  @ds.call(:insert, {:i=>j}, {:i=>:$i})
2810
2834
  @ds.get(:i).must_equal j
2811
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
2835
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
2812
2836
 
2813
2837
  it 'operations/functions with pg_json_ops' do
2814
2838
  Sequel.extension :pg_json_ops
@@ -2996,7 +3020,7 @@ describe 'PostgreSQL inet/cidr types' do
2996
3020
  @ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:first, :i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab']).must_equal(:i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab'])
2997
3021
  @ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:first, :i=>[], :c=>[], :m=>[]).must_equal nil
2998
3022
  @ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:delete, :i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab']).must_equal 1
2999
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3023
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3000
3024
 
3001
3025
  it 'with models' do
3002
3026
  @db.create_table!(:items) do
@@ -3145,7 +3169,7 @@ describe 'PostgreSQL range types' do
3145
3169
  @ds.filter(h).call(:first, @pgra).each{|k, v| v.must_be :==, @ra[k].to_a}
3146
3170
  @ds.filter(h).call(:first, r2).must_equal nil
3147
3171
  @ds.filter(h).call(:delete, @ra).must_equal 1
3148
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3172
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3149
3173
 
3150
3174
  it 'with models' do
3151
3175
  @db.create_table!(:items){primary_key :id; int4range :i4; int8range :i8; numrange :n; daterange :d; tsrange :t; tstzrange :tz}
@@ -3318,7 +3342,7 @@ describe 'PostgreSQL interval types' do
3318
3342
  @ds.call(:insert, {:i=>d}, {:i=>:$i})
3319
3343
  @ds.get(:i).must_equal d
3320
3344
  @ds.filter(:i=>:$i).call(:first, :i=>d).must_equal(:i=>d)
3321
- @ds.filter(:i=>:$i).call(:first, :i=>'0').must_equal nil
3345
+ @ds.filter(:i=>Sequel.cast(:$i, :interval)).call(:first, :i=>'0').must_equal nil
3322
3346
  @ds.filter(:i=>:$i).call(:delete, :i=>d).must_equal 1
3323
3347
 
3324
3348
  @db.create_table!(:items){column :i, 'interval[]'}
@@ -3326,7 +3350,7 @@ describe 'PostgreSQL interval types' do
3326
3350
  @ds.filter(:i=>:$i).call(:first, :i=>[d]).must_equal(:i=>[d])
3327
3351
  @ds.filter(:i=>:$i).call(:first, :i=>[]).must_equal nil
3328
3352
  @ds.filter(:i=>:$i).call(:delete, :i=>[d]).must_equal 1
3329
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3353
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3330
3354
 
3331
3355
  it 'with models' do
3332
3356
  @db.create_table!(:items) do
@@ -3443,7 +3467,7 @@ describe 'PostgreSQL row-valued/composite types' do
3443
3467
  @ds.delete
3444
3468
  @ds.call(:insert, {:address=>Sequel.pg_row([nil, nil, nil])}, {:address=>:$address, :id=>1})
3445
3469
  @ds.get(:address).must_equal(:street=>nil, :city=>nil, :zip=>nil)
3446
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3470
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3447
3471
 
3448
3472
  it 'use arrays of row types in bound variables' do
3449
3473
  @ds = @db[:company]
@@ -3455,7 +3479,7 @@ describe 'PostgreSQL row-valued/composite types' do
3455
3479
  @ds.delete
3456
3480
  @ds.call(:insert, {:employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row([nil, nil, nil])])])}, {:employees=>:$employees, :id=>1})
3457
3481
  @ds.get(:employees).must_equal [{:address=>{:city=>nil, :zip=>nil, :street=>nil}, :id=>1}]
3458
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3482
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3459
3483
 
3460
3484
  it 'operations/functions with pg_row_ops' do
3461
3485
  @ds.insert(:id=>1, :address=>Sequel.pg_row(['123 Sesame St', 'Somewhere', '12345']))
@@ -3581,7 +3605,7 @@ describe 'PostgreSQL row-valued/composite types' do
3581
3605
  @ds.get(:address).must_equal @a
3582
3606
  @ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>@a)[:id].must_equal 1
3583
3607
  @ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>Address.new(:street=>'123 Sesame St', :city=>'Somewhere', :zip=>'12356')).must_equal nil
3584
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3608
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3585
3609
 
3586
3610
  it 'use arrays of model objects in bound variables' do
3587
3611
  @ds = @db[:company]
@@ -3589,7 +3613,7 @@ describe 'PostgreSQL row-valued/composite types' do
3589
3613
  @ds.get(:company).must_equal Company.new(:id=>1, :employees=>@es)
3590
3614
  @ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>@es)[:id].must_equal 1
3591
3615
  @ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])])])).must_equal nil
3592
- end if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG
3616
+ end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
3593
3617
 
3594
3618
  it 'model typecasting' do
3595
3619
  Person.plugin :pg_typecast_on_load, :address unless @native
@@ -169,7 +169,7 @@ describe "A connection pool with a max size of 1" do
169
169
  before do
170
170
  @invoked_count = 0
171
171
  icp = proc{@invoked_count += 1}
172
- @pool = Sequel::ConnectionPool.get_pool(mock_db.call{icp.call; 'herro'}, CONNECTION_POOL_DEFAULTS.merge(:max_connections=>1))
172
+ @pool = Sequel::ConnectionPool.get_pool(mock_db.call{icp.call; 'herro'.dup}, CONNECTION_POOL_DEFAULTS.merge(:max_connections=>1))
173
173
  end
174
174
 
175
175
  it "should let only one thread access the connection at any time" do
@@ -284,10 +284,11 @@ describe "Sequel::Plugins::AssociationPks" do
284
284
  it "should handle delaying setting of association pks until after saving for new objects, if :delay plugin option is used" do
285
285
  @Artist.one_to_many :albums, :clone=>:albums, :delay_pks=>true
286
286
  @Album.many_to_many :tags, :clone=>:tags, :delay_pks=>true
287
+ @Album.db_schema[:id][:type] = :integer
287
288
 
288
289
  ar = @Artist.new
289
290
  ar.album_pks.must_equal []
290
- ar.album_pks = [1,2,3]
291
+ ar.album_pks = ["1","2","3"]
291
292
  ar.album_pks.must_equal [1,2,3]
292
293
  @db.sqls.must_equal []
293
294
 
@@ -320,11 +321,12 @@ describe "Sequel::Plugins::AssociationPks" do
320
321
  it "should handle delaying setting of association pks until after saving for existing objects, if :delay=>:all plugin option is used" do
321
322
  @Artist.one_to_many :albums, :clone=>:albums, :delay_pks=>:always
322
323
  @Album.many_to_many :tags, :clone=>:tags, :delay_pks=>:always
324
+ @Album.db_schema[:id][:type] = :integer
323
325
 
324
326
  ar = @Artist.load(:id=>1)
325
327
  ar.album_pks.must_equal [1,2,3]
326
328
  @db.sqls
327
- ar.album_pks = [2,4]
329
+ ar.album_pks = ["2","4"]
328
330
  ar.album_pks.must_equal [2,4]
329
331
  @db.sqls.must_equal []
330
332
 
@@ -44,7 +44,7 @@ describe Sequel::Model, "caching" do
44
44
  end
45
45
 
46
46
  @dataset = @c.dataset = @c3.dataset = @c4.dataset
47
- @dataset._fetch = {:name => 'sharon', :id => 1}
47
+ @dataset._fetch = {:name => 'sharon'.dup, :id => 1}
48
48
  @dataset.numrows = 1
49
49
 
50
50
  @c2 = Class.new(@c) do
@@ -1,5 +1,11 @@
1
1
  require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
2
2
 
3
+ begin
4
+ csv_lib = RUBY_VERSION < '1.9' ? 'fastercsv' : 'csv'
5
+ require csv_lib
6
+ rescue LoadError => e
7
+ skip_warn "csv_serializer plugin: can't load #{csv_lib} (#{e.class}: #{e})"
8
+ else
3
9
  describe "Sequel::Plugins::CsvSerializer" do
4
10
  before do
5
11
  artist = @Artist = Class.new(Sequel::Model(:artists))
@@ -171,3 +177,4 @@ describe "Sequel::Plugins::CsvSerializer" do
171
177
  @album.to_csv(:except=>[:id, :artist_id]).must_equal "RF\n"
172
178
  end
173
179
  end
180
+ end