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
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  # The Schema module holds the schema generators.
3
5
  module Schema
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -530,7 +532,8 @@ module Sequel
530
532
 
531
533
  # SQL DDL fragment containing the column creation SQL for the given column.
532
534
  def column_definition_sql(column)
533
- sql = "#{quote_identifier(column[:name])} #{type_literal(column)}"
535
+ sql = String.new
536
+ sql << "#{quote_identifier(column[:name])} #{type_literal(column)}"
534
537
  column_definition_order.each{|m| send(:"column_definition_#{m}_sql", sql, column)}
535
538
  sql
536
539
  end
@@ -601,7 +604,8 @@ module Sequel
601
604
 
602
605
  # SQL DDL fragment for column foreign key references
603
606
  def column_references_sql(column)
604
- sql = " REFERENCES #{quote_schema_table(column[:table])}"
607
+ sql = String.new
608
+ sql << " REFERENCES #{quote_schema_table(column[:table])}"
605
609
  sql << "(#{Array(column[:key]).map{|x| quote_identifier(x)}.join(COMMA_SEPARATOR)})" if column[:key]
606
610
  sql << " ON DELETE #{on_delete_clause(column[:on_delete])}" if column[:on_delete]
607
611
  sql << " ON UPDATE #{on_update_clause(column[:on_update])}" if column[:on_update]
@@ -622,7 +626,8 @@ module Sequel
622
626
 
623
627
  # SQL DDL fragment specifying a constraint on a table.
624
628
  def constraint_definition_sql(constraint)
625
- sql = constraint[:name] ? "CONSTRAINT #{quote_identifier(constraint[:name])} " : ""
629
+ sql = String.new
630
+ sql << "CONSTRAINT #{quote_identifier(constraint[:name])} " if constraint[:name]
626
631
  case constraint[:type]
627
632
  when :check
628
633
  check = constraint[:check]
@@ -726,7 +731,8 @@ module Sequel
726
731
  # DDL statement for creating a view.
727
732
  def create_view_sql(name, source, options)
728
733
  source = source.sql if source.is_a?(Dataset)
729
- sql = "#{create_view_prefix_sql(name, options)} AS #{source}"
734
+ sql = String.new
735
+ sql << "#{create_view_prefix_sql(name, options)} AS #{source}"
730
736
  if check = options[:check]
731
737
  sql << " WITH#{' LOCAL' if check == :local} CHECK OPTION"
732
738
  end
@@ -735,6 +741,7 @@ module Sequel
735
741
 
736
742
  # Append the column list to the SQL, if a column list is given.
737
743
  def create_view_sql_append_columns(sql, columns)
744
+ sql = sql.dup
738
745
  if columns
739
746
  sql << ' ('
740
747
  schema_utility_dataset.send(:identifier_list_append, sql, columns)
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Database
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  # A dataset represents an SQL query, or more generally, an abstract
3
5
  # set of rows in the database. Datasets
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # PlaceholderLiteralizer allows you to record the application of arbitrary changes
@@ -157,7 +159,7 @@ module Sequel
157
159
  # Return the SQL query to use for the given arguments.
158
160
  def sql(*args)
159
161
  raise Error, "wrong number of arguments (#{args.length} for #{@arity})" unless args.length == @arity
160
- s = ''
162
+ s = String.new
161
163
  ds = @dataset
162
164
  @fragments.each do |sql, i, transformer|
163
165
  s << sql
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  class Dataset
3
5
  # ---------------------
@@ -61,7 +63,7 @@ module Sequel
61
63
  literal_symbol_append(sql, v)
62
64
  else
63
65
  unless l = db.literal_symbol(v)
64
- l = ''
66
+ l = String.new
65
67
  literal_symbol_append(l, v)
66
68
  db.literal_symbol_set(v, l)
67
69
  end
@@ -121,7 +123,7 @@ module Sequel
121
123
  [insert_sql(columns, sql)]
122
124
  when :union
123
125
  c = false
124
- sql = LiteralString.new('')
126
+ sql = LiteralString.new
125
127
  u = UNION_ALL_SELECT
126
128
  f = empty_from_sql
127
129
  values.each do |v|
@@ -154,7 +156,7 @@ module Sequel
154
156
  else
155
157
  check_truncation_allowed!
156
158
  raise(InvalidOperation, "Can't truncate filtered datasets") if opts[:where] || opts[:having]
157
- t = ''
159
+ t = String.new
158
160
  source_list_append(t, opts[:from])
159
161
  _truncate_sql(t)
160
162
  end
@@ -339,7 +341,7 @@ module Sequel
339
341
  [:literal, :quote_identifier, :quote_schema_table].each do |meth|
340
342
  class_eval(<<-END, __FILE__, __LINE__ + 1)
341
343
  def #{meth}(*args, &block)
342
- s = ''
344
+ s = ''.dup
343
345
  #{meth}_append(s, *args, &block)
344
346
  s
345
347
  end
@@ -1511,7 +1513,7 @@ module Sequel
1511
1513
  # The string that is appended to to create the SQL query, the empty
1512
1514
  # string by default
1513
1515
  def sql_string_origin
1514
- ''
1516
+ String.new
1515
1517
  end
1516
1518
 
1517
1519
  # SQL to use if this dataset uses static SQL. Since static SQL
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  # This module makes it easy to print deprecation warnings with optional backtraces to a given stream.
3
5
  # There are a two accessors you can use to change how/where the deprecation methods are printed
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  module Sequel
2
4
  # The default exception class for exceptions raised by Sequel.
3
5
  # All exception classes defined by Sequel are descendants of this class.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # This _pretty_table extension is only for internal use.
2
4
  # It adds the Sequel::PrettyTable class without modifying
3
5
  # Sequel::Dataset.
@@ -53,7 +55,7 @@ module Sequel
53
55
 
54
56
  # String for each data line
55
57
  def self.data_line(columns, sizes, record) # :nodoc:
56
- '|' << columns.map {|c| format_cell(sizes[c], record[c])}.join('|') << '|'
58
+ String.new << '|' << columns.map {|c| format_cell(sizes[c], record[c])}.join('|') << '|'
57
59
  end
58
60
 
59
61
  # Format the value so it takes up exactly size characters
@@ -70,12 +72,12 @@ module Sequel
70
72
 
71
73
  # String for header line
72
74
  def self.header_line(columns, sizes) # :nodoc:
73
- '|' << columns.map {|c| "%-#{sizes[c]}s" % c.to_s}.join('|') << '|'
75
+ String.new << '|' << columns.map {|c| "%-#{sizes[c]}s" % c.to_s}.join('|') << '|'
74
76
  end
75
77
 
76
78
  # String for separtor line
77
79
  def self.separator_line(columns, sizes) # :nodoc:
78
- '+' << columns.map {|c| '-' * sizes[c]}.join('+') << '+'
80
+ String.new << '+' << columns.map {|c| '-' * sizes[c]}.join('+') << '+'
79
81
  end
80
82
 
81
83
  private_class_method :column_sizes, :data_line, :format_cell, :header_line, :separator_line
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The arbitrary_servers extension allows you to connect to arbitrary
2
4
  # servers/shards that were not defined when you created the database.
3
5
  # To use it, you first load the extension into the Database object:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The blank extension adds the blank? method to all objects (e.g. Object#blank?).
2
4
  #
3
5
  # To load the extension:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The columns_introspection extension attempts to introspect the
2
4
  # selected columns for a dataset before issuing a query. If it
3
5
  # thinks it can guess correctly at the columns the query will use,
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The connection_validator extension modifies a database's
2
4
  # connection pool to validate that connections checked out
3
5
  # from the pool are still valid, before yielding them for
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The constraint_validations extension is designed to easily create database
2
4
  # constraints inside create_table and alter_table blocks. It also adds
3
5
  # relevant metadata about the constraints to a separate table, which the
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # These are extensions to core classes that Sequel enables by default.
2
4
  # They make using Sequel's DSL easier by adding methods to Array,
3
5
  # Hash, String, and Symbol to add methods that return Sequel
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # These are refinements to core classes that allow the Sequel
2
4
  # DSL to be used without modifying the core classes directly.
3
5
  # After loading the extension via:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The current_datetime_timestamp extension makes Dataset#current_datetime
2
4
  # return an object that operates like Sequel.datetime_class.now, but will
3
5
  # be literalized as CURRENT_TIMESTAMP.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The dataset_source_alias extension changes Sequel's
2
4
  # default behavior of automatically aliasing datasets
3
5
  # from using t1, t2, etc. to using an alias based on
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The date_arithmetic extension adds the ability to perform database-independent
2
4
  # addition/substraction of intervals to/from dates and timestamps.
3
5
  #
@@ -73,7 +75,7 @@ module Sequel
73
75
  expr = da.expr
74
76
  cast = case db_type = db.database_type
75
77
  when :postgres
76
- interval = ""
78
+ interval = String.new
77
79
  each_valid_interval_unit(h, DEF_DURATION_UNITS) do |value, sql_unit|
78
80
  interval << "#{value} #{sql_unit} "
79
81
  end
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # This changes Sequel's literalization of IN/NOT IN with an empty
2
4
  # array value to consider NULL values if one of the referenced
3
5
  # columns is NULL:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # This only exists for backwards compatibility, as the behavior
2
4
  # added by this extension is now the default Sequel behavior.
3
5
  Sequel::Dataset.register_extension(:empty_array_ignore_nulls){}
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The error_sql extension adds a DatabaseError#sql method
2
4
  # that you can use to get the sql that caused the error
3
5
  # to be raised.
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The eval_inspect extension changes #inspect for Sequel::SQL::Expression
2
4
  # subclasses to return a string suitable for ruby's eval, such that
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The filter_having extension allows Dataset#filter, #and, #or
2
4
  # and #exclude to operate on the HAVING clause if the dataset
3
5
  # already has a HAVING clause, which was the historical behavior
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The from_block extension changes Database#from so that blocks given
2
4
  # to it are treated as virtual rows applying to the FROM clause,
3
5
  # instead of virtual rows applying to the WHERE clause. This will
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The graph_each extension adds Dataset#graph_each and
2
4
  # makes Dataset#each call #graph_each if the dataset has been graphed.
3
5
  # Dataset#graph_each splits result hashes into subhashes per table:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The hash_aliases extension allows Dataset#select and Dataset#from
2
4
  # to treat a hash argument as an alias specification, with keys
3
5
  # being the expressions and values being the aliases,
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The inflector extension adds inflection instance methods to String, which allows the easy transformation of
2
4
  # words from singular to plural, class names to table names, modularized class
3
5
  # names to ones without, and class names to foreign keys. It exists for
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The LooserTypecasting extension loosens the default database typecasting
2
4
  # for the following types:
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # The meta_def extension is designed for backwards compatibility
2
4
  # with older Sequel code that uses the meta_def method on
3
5
  # Database, Dataset, and Model classes and/or instances. It is
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+ #
1
3
  # Adds the Sequel::Migration and Sequel::Migrator classes, which allow
2
4
  # the user to easily group schema changes and migrate the database
3
5
  # to a newer version or revert to a previous version.
@@ -467,6 +469,14 @@ module Sequel
467
469
  end
468
470
  end
469
471
 
472
+ # Load the migration file, raising an exception if the file does not define
473
+ # a single migration.
474
+ def load_migration_file(file)
475
+ n = Migration.descendants.length
476
+ load(file)
477
+ raise Error, "Migration file not containing a single migration detected" unless n + 1 == Migration.descendants.length
478
+ end
479
+
470
480
  # Remove all migration classes. Done by the migrator to ensure that
471
481
  # the correct migration classes are picked up.
472
482
  def remove_migration_classes
@@ -564,7 +574,7 @@ module Sequel
564
574
  remove_migration_classes
565
575
 
566
576
  # load migration files
567
- version_numbers.each{|n| load(files[n])}
577
+ version_numbers.each{|n| load_migration_file(files[n])}
568
578
 
569
579
  # get migration classes
570
580
  Migration.descendants
@@ -705,15 +715,15 @@ module Sequel
705
715
  if target
706
716
  if migration_version_from_file(f) > target
707
717
  if applied_migrations.include?(fi)
708
- load(path)
718
+ load_migration_file(path)
709
719
  down_mts << [ms.last, f, :down]
710
720
  end
711
721
  elsif !applied_migrations.include?(fi)
712
- load(path)
722
+ load_migration_file(path)
713
723
  up_mts << [ms.last, f, :up]
714
724
  end
715
725
  elsif !applied_migrations.include?(fi)
716
- load(path)
726
+ load_migration_file(path)
717
727
  up_mts << [ms.last, f, :up]
718
728
  end
719
729
  end