sequel 4.30.0 → 4.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
  # The mssql_emulate_lateral_with_apply extension converts
2
4
  # queries that use LATERAL into queries that use CROSS/OUTER
3
5
  # APPLY, allowing code that works on databases that support
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # Allows the use of named timezones via TZInfo (requires tzinfo).
2
4
  # Forces the use of DateTime as Sequel's datetime_class, since
3
5
  # ruby's Time class doesn't support timezones other than local
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The null_dataset extension adds the Dataset#nullify method, which
2
4
  # returns a cloned dataset that will never issue a query to the
3
5
  # database. It implements the null object pattern for datasets.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pagination extension adds the Sequel::Dataset#paginate and #each_page methods,
2
4
  # which return paginated (limited and offset) datasets with the following methods
3
5
  # added that make creating a paginated display easier:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_array extension adds support for Sequel to handle
2
4
  # PostgreSQL's array types.
3
5
  #
@@ -74,14 +76,17 @@
74
76
  # customize the array type handling. See the Sequel::Postgres::PGArray.register
75
77
  # method documentation.
76
78
  #
79
+ # While this extension can parse PostgreSQL arrays with explicit bounds, it
80
+ # currently ignores explicit bounds, so such values do not round
81
+ # trip.
82
+ #
77
83
  # If you want an easy way to call PostgreSQL array functions and
78
84
  # operators, look into the pg_array_ops extension.
79
85
  #
80
- # This extension requires the json, strscan, and delegate libraries.
86
+ # This extension requires the strscan and delegate libraries.
81
87
 
82
88
  require 'delegate'
83
89
  require 'strscan'
84
- require 'json'
85
90
  Sequel.require 'adapters/utils/pg_types'
86
91
 
87
92
  module Sequel
@@ -121,10 +126,6 @@ module Sequel
121
126
  # (usually a string), and should return the appropriate typecasted object.
122
127
  # :oid :: The PostgreSQL OID for the array type. This is used by the Sequel postgres adapter
123
128
  # to set up automatic type conversion on retrieval from the database.
124
- # :parser :: Can be set to :json to use the faster JSON-based parser. Note that the JSON-based
125
- # parser can only correctly handle integers values correctly. It doesn't handle
126
- # full precision for numeric types, and doesn't handle NaN/Infinity values for
127
- # floating point types.
128
129
  # :scalar_oid :: Should be the PostgreSQL OID for the scalar version of this array type. If given,
129
130
  # automatically sets the :converter option by looking for scalar conversion
130
131
  # proc.
@@ -163,7 +164,7 @@ module Sequel
163
164
  end
164
165
 
165
166
  array_type = (opts[:array_type] || db_type).to_s.dup.freeze
166
- creator = (opts[:parser] == :json ? JSONCreator : Creator).new(array_type, converter)
167
+ creator = Creator.new(array_type, converter)
167
168
 
168
169
  typecast_method_map[db_type] = :"#{type}_array"
169
170
 
@@ -343,7 +344,7 @@ module Sequel
343
344
  UNQUOTED_RE = /[{}",]|[^{}",]+/
344
345
  QUOTED_RE = /["\\]|[^"\\]+/
345
346
  NULL_RE = /NULL",/
346
- OPEN_RE = /\{/
347
+ OPEN_RE = /((\[\d+:\d+\])+=)?\{/
347
348
 
348
349
  # Set the source for the input, and any converter callable
349
350
  # to call with objects to be created. For nested parsers
@@ -353,7 +354,7 @@ module Sequel
353
354
  super(source)
354
355
  @converter = converter
355
356
  @stack = [[]]
356
- @recorded = ""
357
+ @recorded = String.new
357
358
  end
358
359
 
359
360
  # Take the buffer of recorded characters and add it to the array
@@ -367,7 +368,7 @@ module Sequel
367
368
  entry = @converter.call(entry)
368
369
  end
369
370
  @stack.last.push(entry)
370
- @recorded = ""
371
+ @recorded = String.new
371
372
  end
372
373
  end
373
374
 
@@ -460,27 +461,6 @@ module Sequel
460
461
  end
461
462
  end
462
463
 
463
- # Callable object that takes the input string and parses it using.
464
- # a JSON parser. This should be faster than the standard Creator,
465
- # but only handles integer types correctly.
466
- class JSONCreator < Creator
467
- # Character conversion map mapping input strings to JSON replacements
468
- SUBST = {'{'.freeze=>'['.freeze, '}'.freeze=>']'.freeze, 'NULL'.freeze=>'null'.freeze}
469
-
470
- # Regular expression matching input strings to convert
471
- SUBST_RE = %r[\{|\}|NULL].freeze
472
-
473
- # Parse the input string by using a gsub to convert non-JSON characters to
474
- # JSON, running it through a regular JSON parser. If a converter is used, a
475
- # recursive map of the output is done to make sure that the entires in the
476
- # correct type.
477
- def call(string)
478
- array = Sequel.parse_json(string.gsub(SUBST_RE){|m| SUBST[m]})
479
- array = Sequel.recursive_map(array, @converter) if @converter
480
- PGArray.new(array, @type)
481
- end
482
- end
483
-
484
464
  # The type of this array. May be nil if no type was given. If a type
485
465
  # is provided, the array is automatically casted to this type when
486
466
  # literalizing. This type is the underlying type, not the array type
@@ -532,9 +512,9 @@ module Sequel
532
512
 
533
513
  # Register all array types that this extension handles by default.
534
514
 
535
- register('text', :oid=>1009, :type_symbol=>:string)
536
- register('integer', :oid=>1007, :parser=>:json)
537
- register('bigint', :oid=>1016, :parser=>:json, :scalar_typecast=>:integer)
515
+ register('text', :oid=>1009, :scalar_oid=>25, :type_symbol=>:string)
516
+ register('integer', :oid=>1007, :scalar_oid=>23)
517
+ register('bigint', :oid=>1016, :scalar_oid=>20, :scalar_typecast=>:integer)
538
518
  register('numeric', :oid=>1231, :scalar_oid=>1700, :type_symbol=>:decimal)
539
519
  register('double precision', :oid=>1022, :scalar_oid=>701, :type_symbol=>:float)
540
520
 
@@ -546,8 +526,8 @@ module Sequel
546
526
  register('time with time zone', :oid=>1270, :scalar_oid=>1083, :type_symbol=>:time_timezone, :scalar_typecast=>:time)
547
527
  register('timestamp with time zone', :oid=>1185, :scalar_oid=>1184, :type_symbol=>:datetime_timezone, :scalar_typecast=>:datetime)
548
528
 
549
- register('smallint', :oid=>1005, :parser=>:json, :scalar_typecast=>:integer)
550
- register('oid', :oid=>1028, :parser=>:json, :scalar_typecast=>:integer)
529
+ register('smallint', :oid=>1005, :scalar_oid=>21, :scalar_typecast=>:integer)
530
+ register('oid', :oid=>1028, :scalar_oid=>26, :scalar_typecast=>:integer)
551
531
  register('real', :oid=>1021, :scalar_oid=>700, :scalar_typecast=>:float)
552
532
  register('character', :oid=>1014, :array_type=>:text, :scalar_typecast=>:string)
553
533
  register('character varying', :oid=>1015, :scalar_typecast=>:string, :type_symbol=>:varchar)
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_array_ops extension adds support to Sequel's DSL to make
2
4
  # it easier to call PostgreSQL array functions and operators.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_enum extension adds support for Sequel to handle PostgreSQL's enum
2
4
  # types. To use this extension, first load it into your Database instance:
3
5
  #
@@ -68,7 +70,8 @@ module Sequel
68
70
  # :before :: Add the new value before this existing value.
69
71
  # :if_not_exists :: Do not raise an error if the value already exists in the enum.
70
72
  def add_enum_value(enum, value, opts=OPTS)
71
- sql = "ALTER TYPE #{quote_schema_table(enum)} ADD VALUE#{' IF NOT EXISTS' if opts[:if_not_exists]} #{literal(value.to_s)}"
73
+ sql = String.new
74
+ sql << "ALTER TYPE #{quote_schema_table(enum)} ADD VALUE#{' IF NOT EXISTS' if opts[:if_not_exists]} #{literal(value.to_s)}"
72
75
  if v = opts[:before]
73
76
  sql << " BEFORE #{literal(v.to_s)}"
74
77
  elsif v = opts[:after]
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_hstore extension adds support for the PostgreSQL hstore type
2
4
  # to Sequel. hstore is an extension that ships with PostgreSQL, and
3
5
  # the hstore type stores an arbitrary key-value table, where the keys
@@ -265,7 +267,7 @@ module Sequel
265
267
  # literal version of the hstore. Separated out for use by
266
268
  # the bound argument code.
267
269
  def unquoted_literal
268
- str = ''
270
+ str = String.new
269
271
  comma = false
270
272
  commas = COMMA
271
273
  quote = QUOTE
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_hstore_ops extension adds support to Sequel's DSL to make
2
4
  # it easier to call PostgreSQL hstore functions and operators.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_inet extension adds support for Sequel to handle
2
4
  # PostgreSQL's inet and cidr types using ruby's IPAddr class.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_inet_ops extension adds support to Sequel's DSL to make
2
4
  # it easier to call PostgreSQL inet functions and operators.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_interval extension adds support for PostgreSQL's interval type.
2
4
  #
3
5
  # This extension integrates with Sequel's native postgres and jdbc/postgresql
@@ -49,7 +51,7 @@ module Sequel
49
51
  def self.literal_duration(duration)
50
52
  h = Hash.new(0)
51
53
  duration.parts.each{|unit, value| h[unit] += value}
52
- s = ''
54
+ s = String.new
53
55
 
54
56
  DURATION_UNITS.each do |unit|
55
57
  if (v = h[unit]) != 0
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_json extension adds support for Sequel to handle
2
4
  # PostgreSQL's json and jsonb types. It is slightly more strict than the
3
5
  # PostgreSQL json types in that the object returned should be an
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_json_ops extension adds support to Sequel's DSL to make
2
4
  # it easier to call PostgreSQL JSON functions and operators (added
3
5
  # first in PostgreSQL 9.3). It also supports the JSONB functions
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_loose_count extension looks at the table statistics
2
4
  # in the PostgreSQL system tables to get a fast approximate
3
5
  # count of the number of rows in a given table:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_range extension adds support for the PostgreSQL 9.2+ range
2
4
  # types to Sequel. PostgreSQL range types are similar to ruby's
3
5
  # Range class, representating an array of values. However, they
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_range_ops extension adds support to Sequel's DSL to make
2
4
  # it easier to call PostgreSQL range functions and operators.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_row extension adds support for Sequel to handle
2
4
  # PostgreSQL's row-valued/composite types.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_row_ops extension adds support to Sequel's DSL to make
2
4
  # it easier to deal with PostgreSQL row-valued/composite types.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pg_static_cache_updater extension is designed to
2
4
  # automatically update the caches in the models using the
3
5
  # static_cache plugin when changes to the underlying tables
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The pretty_table extension adds Sequel::Dataset#print and the
2
4
  # Sequel::PrettyTable class for creating nice-looking plain-text
3
5
  # tables. Example:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The query extension adds a query method which allows
2
4
  # a different way to construct queries instead of the usual
3
5
  # method chaining:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The query_literals extension changes Sequel's default behavior of
2
4
  # the select, order and group methods so that if the first argument
3
5
  # is a regular string, it is treated as a literal string, with the
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The round_timestamps extension will automatically round timestamp
2
4
  # values to the database's supported level of precision before literalizing
3
5
  # them.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The ruby18_symbol_extensions adds the <, <=, >, >= to Symbol
2
4
  # to reflect the mathmatical operators. It also adds the [] method
3
5
  # to Symbol for creating SQL functions.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The schema_caching extension adds a few methods to Sequel::Database
2
4
  # that make it easy to dump the parsed schema information to a file,
3
5
  # and load it from that file. Loading the schema information from a
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The schema_dumper extension supports dumping tables and indexes
2
4
  # in a Sequel::Migration format, so they can be restored on another
3
5
  # database (which can be the same type or a different type than
@@ -213,7 +215,8 @@ END_MIG
213
215
  # For the table and foreign key metadata array, return an alter_table
214
216
  # string that would add the foreign keys if run in a migration.
215
217
  def dump_add_fk_constraints(table, fks)
216
- sfks = "alter_table(#{table.inspect}) do\n"
218
+ sfks = String.new
219
+ sfks << "alter_table(#{table.inspect}) do\n"
217
220
  sfks << create_table_generator do
218
221
  fks.sort_by{|fk| fk[:columns].map(&:to_s)}.each do |fk|
219
222
  foreign_key fk[:columns], fk
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The select_remove extension adds Sequel::Dataset#select_remove for removing existing selected
2
4
  # columns from a dataset. It's not part of Sequel core as it is rarely needed and has
3
5
  # some corner cases where it can't work correctly.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # This adds the following dataset methods:
2
4
  #
3
5
  # []= :: filter with the first argument, update with the second
@@ -107,7 +109,7 @@ module Sequel
107
109
  def to_csv(include_column_titles = true)
108
110
  n = naked
109
111
  cols = n.columns
110
- csv = ''
112
+ csv = String.new
111
113
  csv << "#{cols.join(COMMA)}\r\n" if include_column_titles
112
114
  n.each{|r| csv << "#{cols.collect{|c| r[c]}.join(COMMA)}\r\n"}
113
115
  csv
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The server_block extension adds the Database#with_server method, which takes a shard
2
4
  # argument and a block, and makes it so that access inside the block will use the
3
5
  # specified shard by default.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The set_overrides extension adds the Dataset#set_overrides and
2
4
  # Dataset#set_defaults methods which provide a crude way to
3
5
  # control the values used in INSERT/UPDATE statements if a hash
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The split_array_nil extension overrides Sequel's default handling of
2
4
  # IN/NOT IN with arrays of values to do specific nil checking. For example,
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The sql_expr extension adds the sql_expr method to every object, which
2
4
  # returns an wrapped object that works nicely with Sequel's DSL by calling
3
5
  # Sequel.expr:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The string_date_time extension provides String instance methods
2
4
  # for converting the strings to a date (e.g. String#to_date), allowing
3
5
  # for backwards compatibility with legacy Sequel code.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The thread_local_timezones extension allows you to set a per-thread timezone that
2
4
  # will override the default global timezone while the thread is executing. The
3
5
  # main use case is for web applications that execute each request in its own thread,
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # This adds a <tt>Sequel::Dataset#to_dot</tt> method. The +to_dot+ method
2
4
  # returns a string that can be processed by graphviz's +dot+ program in
3
5
  # order to get a visualization of the dataset. Basically, it shows a version
@@ -123,7 +125,7 @@ module Sequel
123
125
  dot "PlaceholderLiteralString: #{str.inspect}"
124
126
  v(e.args, :args)
125
127
  when SQL::JoinClause
126
- str = "#{e.join_type.to_s.upcase} JOIN"
128
+ str = "#{e.join_type.to_s.upcase} JOIN".dup
127
129
  if e.is_a?(SQL::JoinOnClause)
128
130
  str << " ON"
129
131
  elsif e.is_a?(SQL::JoinUsingClause)
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  require 'sequel/core'
2
4
 
3
5
  module Sequel
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Model
3
5
  # Associations are used in order to specify relationships between model classes
@@ -2553,7 +2555,7 @@ END
2553
2555
  # create large cartesian products. If you must graph multiple one_to_many and many_to_many associations,
2554
2556
  # make sure your filters are narrow if you have a large database.
2555
2557
  #
2556
- # Each association's order, if definied, is respected. +eager_graph+ probably
2558
+ # Each association's order, if defined, is respected. +eager_graph+ probably
2557
2559
  # won't work correctly on a limited dataset, unless you are
2558
2560
  # only graphing many_to_one, one_to_one, and one_through_one associations.
2559
2561
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Model
3
5
  extend Enumerable
@@ -1134,7 +1136,9 @@ module Sequel
1134
1136
  attr_writer(*BOOLEAN_SETTINGS)
1135
1137
 
1136
1138
  # The hash of attribute values. Keys are symbols with the names of the
1137
- # underlying database columns.
1139
+ # underlying database columns. The returned hash is a reference to the
1140
+ # receiver's values hash, and modifying it will also modify the receiver's
1141
+ # values.
1138
1142
  #
1139
1143
  # Artist.new(:name=>'Bob').values # => {:name=>'Bob'}
1140
1144
  # Artist[1].values # => {:id=>1, :name=>'Jim', ...}