sequel 5.39.0 → 5.62.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +294 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +57 -25
  5. data/bin/sequel +11 -3
  6. data/doc/advanced_associations.rdoc +13 -13
  7. data/doc/association_basics.rdoc +89 -24
  8. data/doc/cheat_sheet.rdoc +11 -3
  9. data/doc/migration.rdoc +12 -6
  10. data/doc/model_hooks.rdoc +1 -1
  11. data/doc/object_model.rdoc +8 -8
  12. data/doc/opening_databases.rdoc +18 -11
  13. data/doc/postgresql.rdoc +16 -8
  14. data/doc/querying.rdoc +5 -3
  15. data/doc/release_notes/5.40.0.txt +40 -0
  16. data/doc/release_notes/5.41.0.txt +25 -0
  17. data/doc/release_notes/5.42.0.txt +136 -0
  18. data/doc/release_notes/5.43.0.txt +98 -0
  19. data/doc/release_notes/5.44.0.txt +32 -0
  20. data/doc/release_notes/5.45.0.txt +34 -0
  21. data/doc/release_notes/5.46.0.txt +87 -0
  22. data/doc/release_notes/5.47.0.txt +59 -0
  23. data/doc/release_notes/5.48.0.txt +14 -0
  24. data/doc/release_notes/5.49.0.txt +59 -0
  25. data/doc/release_notes/5.50.0.txt +78 -0
  26. data/doc/release_notes/5.51.0.txt +47 -0
  27. data/doc/release_notes/5.52.0.txt +87 -0
  28. data/doc/release_notes/5.53.0.txt +23 -0
  29. data/doc/release_notes/5.54.0.txt +27 -0
  30. data/doc/release_notes/5.55.0.txt +21 -0
  31. data/doc/release_notes/5.56.0.txt +51 -0
  32. data/doc/release_notes/5.57.0.txt +23 -0
  33. data/doc/release_notes/5.58.0.txt +31 -0
  34. data/doc/release_notes/5.59.0.txt +73 -0
  35. data/doc/release_notes/5.60.0.txt +22 -0
  36. data/doc/release_notes/5.61.0.txt +43 -0
  37. data/doc/release_notes/5.62.0.txt +132 -0
  38. data/doc/schema_modification.rdoc +1 -1
  39. data/doc/security.rdoc +9 -9
  40. data/doc/sql.rdoc +27 -15
  41. data/doc/testing.rdoc +22 -11
  42. data/doc/transactions.rdoc +6 -6
  43. data/doc/virtual_rows.rdoc +2 -2
  44. data/lib/sequel/adapters/ado/access.rb +1 -1
  45. data/lib/sequel/adapters/ado.rb +17 -17
  46. data/lib/sequel/adapters/amalgalite.rb +3 -5
  47. data/lib/sequel/adapters/ibmdb.rb +2 -2
  48. data/lib/sequel/adapters/jdbc/derby.rb +8 -0
  49. data/lib/sequel/adapters/jdbc/h2.rb +60 -10
  50. data/lib/sequel/adapters/jdbc/hsqldb.rb +6 -0
  51. data/lib/sequel/adapters/jdbc/postgresql.rb +4 -4
  52. data/lib/sequel/adapters/jdbc.rb +16 -18
  53. data/lib/sequel/adapters/mysql.rb +80 -67
  54. data/lib/sequel/adapters/mysql2.rb +54 -49
  55. data/lib/sequel/adapters/odbc.rb +6 -2
  56. data/lib/sequel/adapters/oracle.rb +3 -3
  57. data/lib/sequel/adapters/postgres.rb +83 -40
  58. data/lib/sequel/adapters/shared/access.rb +11 -1
  59. data/lib/sequel/adapters/shared/db2.rb +30 -0
  60. data/lib/sequel/adapters/shared/mssql.rb +58 -7
  61. data/lib/sequel/adapters/shared/mysql.rb +40 -2
  62. data/lib/sequel/adapters/shared/oracle.rb +76 -0
  63. data/lib/sequel/adapters/shared/postgres.rb +418 -174
  64. data/lib/sequel/adapters/shared/sqlanywhere.rb +10 -0
  65. data/lib/sequel/adapters/shared/sqlite.rb +102 -11
  66. data/lib/sequel/adapters/sqlanywhere.rb +1 -1
  67. data/lib/sequel/adapters/sqlite.rb +60 -18
  68. data/lib/sequel/adapters/tinytds.rb +1 -1
  69. data/lib/sequel/adapters/utils/columns_limit_1.rb +22 -0
  70. data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -1
  71. data/lib/sequel/ast_transformer.rb +6 -0
  72. data/lib/sequel/connection_pool/sharded_single.rb +5 -7
  73. data/lib/sequel/connection_pool/single.rb +6 -8
  74. data/lib/sequel/connection_pool.rb +42 -28
  75. data/lib/sequel/core.rb +28 -18
  76. data/lib/sequel/database/connecting.rb +26 -2
  77. data/lib/sequel/database/misc.rb +69 -14
  78. data/lib/sequel/database/query.rb +38 -1
  79. data/lib/sequel/database/schema_generator.rb +45 -52
  80. data/lib/sequel/database/schema_methods.rb +17 -1
  81. data/lib/sequel/dataset/actions.rb +82 -13
  82. data/lib/sequel/dataset/features.rb +20 -0
  83. data/lib/sequel/dataset/misc.rb +1 -1
  84. data/lib/sequel/dataset/prepared_statements.rb +2 -0
  85. data/lib/sequel/dataset/query.rb +118 -16
  86. data/lib/sequel/dataset/sql.rb +177 -47
  87. data/lib/sequel/extensions/_model_pg_row.rb +0 -12
  88. data/lib/sequel/extensions/_pretty_table.rb +1 -1
  89. data/lib/sequel/extensions/any_not_empty.rb +1 -1
  90. data/lib/sequel/extensions/async_thread_pool.rb +438 -0
  91. data/lib/sequel/extensions/auto_literal_strings.rb +1 -1
  92. data/lib/sequel/extensions/blank.rb +8 -0
  93. data/lib/sequel/extensions/constraint_validations.rb +1 -1
  94. data/lib/sequel/extensions/core_refinements.rb +36 -11
  95. data/lib/sequel/extensions/date_arithmetic.rb +71 -31
  96. data/lib/sequel/extensions/date_parse_input_handler.rb +67 -0
  97. data/lib/sequel/extensions/datetime_parse_to_time.rb +5 -1
  98. data/lib/sequel/extensions/duplicate_columns_handler.rb +1 -1
  99. data/lib/sequel/extensions/eval_inspect.rb +2 -0
  100. data/lib/sequel/extensions/inflector.rb +9 -1
  101. data/lib/sequel/extensions/is_distinct_from.rb +141 -0
  102. data/lib/sequel/extensions/looser_typecasting.rb +3 -0
  103. data/lib/sequel/extensions/migration.rb +7 -2
  104. data/lib/sequel/extensions/named_timezones.rb +22 -6
  105. data/lib/sequel/extensions/pagination.rb +1 -1
  106. data/lib/sequel/extensions/pg_array.rb +23 -3
  107. data/lib/sequel/extensions/pg_array_ops.rb +2 -2
  108. data/lib/sequel/extensions/pg_auto_parameterize.rb +478 -0
  109. data/lib/sequel/extensions/pg_enum.rb +1 -1
  110. data/lib/sequel/extensions/pg_extended_date_support.rb +28 -25
  111. data/lib/sequel/extensions/pg_extended_integer_support.rb +116 -0
  112. data/lib/sequel/extensions/pg_hstore.rb +6 -1
  113. data/lib/sequel/extensions/pg_hstore_ops.rb +53 -3
  114. data/lib/sequel/extensions/pg_inet.rb +10 -11
  115. data/lib/sequel/extensions/pg_inet_ops.rb +1 -1
  116. data/lib/sequel/extensions/pg_interval.rb +45 -19
  117. data/lib/sequel/extensions/pg_json.rb +13 -15
  118. data/lib/sequel/extensions/pg_json_ops.rb +73 -2
  119. data/lib/sequel/extensions/pg_loose_count.rb +3 -1
  120. data/lib/sequel/extensions/pg_multirange.rb +367 -0
  121. data/lib/sequel/extensions/pg_range.rb +10 -23
  122. data/lib/sequel/extensions/pg_range_ops.rb +37 -9
  123. data/lib/sequel/extensions/pg_row.rb +19 -13
  124. data/lib/sequel/extensions/pg_row_ops.rb +1 -1
  125. data/lib/sequel/extensions/query.rb +2 -0
  126. data/lib/sequel/extensions/s.rb +2 -1
  127. data/lib/sequel/extensions/schema_dumper.rb +13 -2
  128. data/lib/sequel/extensions/server_block.rb +8 -12
  129. data/lib/sequel/extensions/sql_comments.rb +110 -3
  130. data/lib/sequel/extensions/sql_log_normalizer.rb +108 -0
  131. data/lib/sequel/extensions/sqlite_json_ops.rb +255 -0
  132. data/lib/sequel/extensions/string_agg.rb +1 -1
  133. data/lib/sequel/extensions/string_date_time.rb +19 -23
  134. data/lib/sequel/extensions/symbol_aref.rb +2 -0
  135. data/lib/sequel/model/associations.rb +324 -95
  136. data/lib/sequel/model/base.rb +51 -27
  137. data/lib/sequel/model/errors.rb +10 -1
  138. data/lib/sequel/model/inflections.rb +1 -1
  139. data/lib/sequel/model/plugins.rb +5 -0
  140. data/lib/sequel/plugins/association_proxies.rb +2 -0
  141. data/lib/sequel/plugins/async_thread_pool.rb +39 -0
  142. data/lib/sequel/plugins/auto_restrict_eager_graph.rb +62 -0
  143. data/lib/sequel/plugins/auto_validations.rb +87 -15
  144. data/lib/sequel/plugins/auto_validations_constraint_validations_presence_message.rb +68 -0
  145. data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
  146. data/lib/sequel/plugins/column_encryption.rb +728 -0
  147. data/lib/sequel/plugins/composition.rb +10 -4
  148. data/lib/sequel/plugins/concurrent_eager_loading.rb +174 -0
  149. data/lib/sequel/plugins/constraint_validations.rb +2 -1
  150. data/lib/sequel/plugins/dataset_associations.rb +4 -1
  151. data/lib/sequel/plugins/dirty.rb +1 -1
  152. data/lib/sequel/plugins/enum.rb +124 -0
  153. data/lib/sequel/plugins/finder.rb +3 -1
  154. data/lib/sequel/plugins/insert_conflict.rb +4 -0
  155. data/lib/sequel/plugins/instance_specific_default.rb +1 -1
  156. data/lib/sequel/plugins/json_serializer.rb +39 -24
  157. data/lib/sequel/plugins/lazy_attributes.rb +3 -0
  158. data/lib/sequel/plugins/list.rb +3 -1
  159. data/lib/sequel/plugins/many_through_many.rb +108 -9
  160. data/lib/sequel/plugins/nested_attributes.rb +12 -7
  161. data/lib/sequel/plugins/pg_array_associations.rb +56 -38
  162. data/lib/sequel/plugins/pg_auto_constraint_validations.rb +3 -1
  163. data/lib/sequel/plugins/prepared_statements.rb +10 -1
  164. data/lib/sequel/plugins/primary_key_lookup_check_values.rb +154 -0
  165. data/lib/sequel/plugins/rcte_tree.rb +27 -19
  166. data/lib/sequel/plugins/require_valid_schema.rb +67 -0
  167. data/lib/sequel/plugins/serialization.rb +9 -3
  168. data/lib/sequel/plugins/serialization_modification_detection.rb +2 -1
  169. data/lib/sequel/plugins/sql_comments.rb +189 -0
  170. data/lib/sequel/plugins/static_cache.rb +1 -1
  171. data/lib/sequel/plugins/subclasses.rb +28 -11
  172. data/lib/sequel/plugins/tactical_eager_loading.rb +15 -2
  173. data/lib/sequel/plugins/timestamps.rb +1 -1
  174. data/lib/sequel/plugins/unused_associations.rb +521 -0
  175. data/lib/sequel/plugins/update_or_create.rb +1 -1
  176. data/lib/sequel/plugins/validation_helpers.rb +38 -11
  177. data/lib/sequel/plugins/xml_serializer.rb +1 -1
  178. data/lib/sequel/sql.rb +1 -1
  179. data/lib/sequel/timezones.rb +12 -14
  180. data/lib/sequel/version.rb +1 -1
  181. metadata +94 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b995589f8bb51611b490ae4cd1d84c2ecfbb5889cb4f940dd786a841fe9ecf9f
4
- data.tar.gz: afa86ae9dfc39cd21138aff35955fb4194c359a1ea56c9a80026f04b85b79a4a
3
+ metadata.gz: df5fea5cf2d6dae7a5721c549c89a190df5a1cf79f2e7d48921dcdaeae398839
4
+ data.tar.gz: e1155c60bb4c2845a96cddf0a7d5498358f1cba826fdc9d7f00754a017b4310f
5
5
  SHA512:
6
- metadata.gz: 553d5c2b92a49d079503c9e8e0f8dfecef1a4abf2ed2fe242c8aec19d53c918912de4f5d1453626a05c1b654c5582c508199df10aa7540ec590331b3ecb355da
7
- data.tar.gz: f0fc7bceadccc74651573f82ed957ab91061ecb05f5f30050d0814a0142b915a79175d146b3bcac6f7269cd4f3b3b69eb58a92a4df439a944c081b45f1deaa2c
6
+ metadata.gz: 8e52498bbcc1c2d472592b213be8e6e508f5881de5c1ae0579b426211aa448960e06bdb297f43eb26ee3024923f78e54bb17f9a886710c3ffe60f0c134746029
7
+ data.tar.gz: 0d5ae732cde0ad90a4c331f40628628e346386c483267173eb50eaad067d7de14ba6ff3c83f598d7440a6fcc752e4439cf1856706489cc3d3b7cffaf5b6d8de8
data/CHANGELOG CHANGED
@@ -1,3 +1,297 @@
1
+ === 5.62.0 (2022-11-01)
2
+
3
+ * Add back the pg_auto_parameterize extension for automatically using bound variables when using postgres adapter with pg driver (jeremyevans)
4
+
5
+ * Add pg_extended_integer_support extension for customizing behavior when literalizing a Ruby integer outside PostgreSQL bigint range (jeremyevans)
6
+
7
+ * Raise Postgres::IntegerOutsideBigintRange if attempting to literalize a Ruby integer outside PostgreSQL bigint range (jeremyevans)
8
+
9
+ * Add primary_key_lookup_check_values plugin for typecasting and checking primary key values during lookup (jeremyevans)
10
+
11
+ * Setup validation of minimum and maximum values for integer columns in auto_validations (jeremyevans)
12
+
13
+ * Add validates_max_value and validates_min_value to validation_helpers (jeremyevans)
14
+
15
+ * Include :min_value and :max_value schema entries for integer columns on most databases (jeremyevans)
16
+
17
+ * Don't wrap multi-inserts in a transaction when it's not required (shannoncole, jeremyevans) (#1945)
18
+
19
+ * Update mock PostgreSQL adapter to default to PostgreSQL 15 instead of PostgreSQL 14 (jeremyevans)
20
+
21
+ * Support fractional seconds in the named_timezones extension (jeremyevans) (#1943)
22
+
23
+ * Cache reflection datasets in the postgres adapter to improve performance (jeremyevans)
24
+
25
+ * Handle BC dates and timestamps in bound variables when using the pg_extended_date_support extension (jeremyevans)
26
+
27
+ * Correctly format hstore[] types in bound variables on PostgreSQL (jeremyevans)
28
+
29
+ * Fix corner case in eager loading where window function eager limit strategy is used, but row number entry is not removed (jeremyevans)
30
+
31
+ * Support server/shard specific :after_connect and :connect_sqls Database options (jeremyevans) (#1935)
32
+
33
+ === 5.61.0 (2022-10-01)
34
+
35
+ * Make Database#foreign_key_list on PostgreSQL return results for partitioned tables (jeremyevans)
36
+
37
+ * Add Database#check_string_typecast_bytesize for checking bytesize of strings before typecasting (jeremyevans)
38
+
39
+ * Treat negative hexidecimal strings similar to positive hexidecimal strings when typecasting to integer (jeremyevans)
40
+
41
+ * Remove is_json and is_not_json methods from the pg_json_ops extension, as the support was removed in PostgreSQL 15 beta 4 (jeremyevans)
42
+
43
+ * Fix handling of timestamps before the date of calendar reform when using pg_extended_date_support extension on Ruby 3.2 (jeremyevans)
44
+
45
+ === 5.60.1 (2022-09-02)
46
+
47
+ * Revert conversion of respond_to? to defined?, as it breaks with unused refinements on Ruby 2 (jeremyevans) (#1919)
48
+
49
+ === 5.60.0 (2022-09-01)
50
+
51
+ * Support arbitrary expressions for date_arithmetic interval values on PostgreSQL 9.4+ (jeremyevans)
52
+
53
+ * Support native IS DISTINCT FROM on SQLite 3.39+ instead of emulating support in the is_distinct_from extension (jeremyevans)
54
+
55
+ * Support HAVING without GROUP BY on SQLite 3.39+ (jeremyevans)
56
+
57
+ * Convert most respond_to? calls to equivalent defined? for better performance (jeremyevans)
58
+
59
+ === 5.59.0 (2022-08-01)
60
+
61
+ * Set :allow_eager association option to false for instance specific associations without eager loaders (jeremyevans)
62
+
63
+ * Add require_valid_schema plugin for checking that model classes have schema parsed as expected (jeremyevans)
64
+
65
+ * Model classes created from aliased expressions and literal strings no longer use the simple table optimization (jeremyevans)
66
+
67
+ * Model code that does not swallow connection errors will now also not swallow disconnect errors (jeremyevans) (#1892)
68
+
69
+ * Add is_json and is_not_json methods to the pg_json_ops extension, for the PostgreSQL 15+ IS [NOT] JSON operator (jeremyevans)
70
+
71
+ * Support :security_invoker view option on PostgreSQL 15+, for views where access uses permissions of user instead of owner (jeremyevans)
72
+
73
+ * Support :nulls_distinct index option on PostgreSQL 15+, for NULLS [NOT] DISTINCT (jeremyevans)
74
+
75
+ * Support sequel-postgres-pr driver in the postgres adapter (jeremyevans)
76
+
77
+ === 5.58.0 (2022-07-01)
78
+
79
+ * Support :disable_split_materialized Database option on MySQL to work around optimizer bug in MariaDB 10.5+ affecting association tests (jeremyevans)
80
+
81
+ * Add Dataset#merge* methods to support MERGE statement on PostgreSQL 15+, MSSQL, Oracle, DB2, H2, HSQLDB, and Derby (jeremyevans)
82
+
83
+ === 5.57.0 (2022-06-01)
84
+
85
+ * Make Database#create_function on PostgreSQL accept :parallel option (bananarne) (#1870)
86
+
87
+ * Add support for :on_update_current_timestamp column option on MySQL (jeremyevans)
88
+
89
+ * Add is_distinct_from extension with support for the IS DISTINCT FROM operator (jeremyevans)
90
+
91
+ === 5.56.0 (2022-05-01)
92
+
93
+ * Make alter_table add_column/add_foreign_key methods support :index option to create an index on the column (jeremyevans)
94
+
95
+ * Support creation of STRICT tables on SQLite 3.37.0+ via create_table :strict option (jeremyevans)
96
+
97
+ * Add sqlite_json_ops extension for DSL support for JSON functions and operators added in SQLite 3.38.0 (jeremyevans)
98
+
99
+ * Recognize "INTEGER" type same as "integer" type in the schema dumper, helpful on SQLite 3.37.0+ (jeremyevans)
100
+
101
+ === 5.55.0 (2022-04-01)
102
+
103
+ * Support :setup_regexp_function Database option in the sqlite adapter to allow the use of regexps when querying (jeremyevans)
104
+
105
+ * Add auto_restrict_eager_graph plugin for automatically disallow eager_graph with associations needing but lacking graph options (jeremyevans)
106
+
107
+ * Fix placeholder literalizer optimization for dataset aggregate methods on a model dataset (belousovAV) (#1847, #1848)
108
+
109
+ === 5.54.0 (2022-03-01)
110
+
111
+ * Add enum plugin for treating columns as enums in a model (jeremyevans) (#1839)
112
+
113
+ === 5.53.0 (2022-02-01)
114
+
115
+ * Make Dataset#_sql_comment private when using the Database sql_comments extension (jeremyevans)
116
+
117
+ * Fix prepared statements in the mysql2 adapter to reuse native prepared statements (jeremyevans) (#1832)
118
+
119
+ * Support H2 version 2+ in the jdbc/h2 adapter (jeremyevans) (#1817)
120
+
121
+ * Work around active_support breaking subclasses plugin on Ruby <3.1 (jeremyevans) (#1816)
122
+
123
+ * Fix error handling if trying to setup column_encryption plugin without keys (jeremyevans) (#1815)
124
+
125
+ === 5.52.0 (2022-01-01)
126
+
127
+ * Use Class#subclasses if available in the subclasses plugin, instead of a custom Model.subclasses accessor (jeremyevans)
128
+
129
+ * Add Model.descendants and .freeze_descendants to subclasses plugin (jeremyevans)
130
+
131
+ * Avoid use of deprecated Refinement#include on Ruby 3.1+ (jeremyevans)
132
+
133
+ * Add date_parse_input_handler extension for custom handling of input to date parsing methods (jeremyevans)
134
+
135
+ * Make postgres adapter respect Database#default_string_column_size (jeremyevans)
136
+
137
+ * Make pg_interval extension work with ActiveSupport 7.0 (jeremyevans)
138
+
139
+ * Make :ruby_default schema entry for type: :datetime respect Sequel.datetime_class (jeremyevans)
140
+
141
+ * Make alter_table drop_constraint have an effect on MySQL 8.0.19+ (jeremyevans)
142
+
143
+ * Make mysql adapter support ruby-mysql 3 API (jeremyevans) (#1795)
144
+
145
+ * Make mysql adapter no longer use connection's server_version, since it isn't accurate when using the ruby-mysql driver (jeremyevans)
146
+
147
+ * Add sql_comments plugin for automatically including comments on queries generated by model class, instance, and dataset methods (jeremyevans)
148
+
149
+ * Make sql_comments Database extension support Database#with_comments, for automatically including comments for queries executed inside the block (jeremyevans)
150
+
151
+ * Fix sql_comments extension to not modify cached SQL for a dataset (jeremyevans)
152
+
153
+ === 5.51.0 (2021-12-01)
154
+
155
+ * Make eager loading via tactical_eager_loading no longer modify objects who already have a cached value for the association (jeremyevans)
156
+
157
+ * Make association cloning handle cases where clone association sets different :class option than cloned association (jeremyevans)
158
+
159
+ * Make column schema entries on MySQL include an :extra entry for the Extra column in DESCRIBE output (bschmeck) (#1791)
160
+
161
+ * Update mock PostgreSQL adapter to default to PostgreSQL 14 instead of PostgreSQL 9.5 (jeremyevans)
162
+
163
+ * Support Dataset#with_recursive :search and :cycle options on PostgreSQL 14+ for result ordering and cycle detection (jeremyevans)
164
+
165
+ * Avoid method redefined verbose mode warnings in lazy_attributes plugin (jeremyevans)
166
+
167
+ === 5.50.0 (2021-11-01)
168
+
169
+ * Make Migrator :allow_missing_migration_files also allow down migrations where the current database version is greater than the last migration file version (francisconeves97) (#1789)
170
+
171
+ * Fix Model#freeze in composition, serialization, and serialization_modification_detection plugins to return self (jeremyevans) (#1788)
172
+
173
+ * Fix typecasting of lazy columns when using lazy_attributes plugin in model where dataset selects from subquery (jeremyevans)
174
+
175
+ * Add :before_preconnect Database option, for configuring extensions loaded via :preconnect_extensions (MarcPer, jeremyevans) (#1786)
176
+
177
+ * Change Dataset#columns! to use a LIMIT 0 query instead of a LIMIT 1 query (jeremyevans)
178
+
179
+ * Add sql_log_normalizer extension for normalizing logged SQL, helpful for analytics and sensitive data (jeremyevans)
180
+
181
+ * Add support for range_merge, multirange, and unnest, and PGMultiRange#op to pg_range_ops extension (jeremyevans)
182
+
183
+ * Add pg_multirange extension with support for PostgreSQL 14+ multirange types (jeremyevans)
184
+
185
+ === 5.49.0 (2021-10-01)
186
+
187
+ * Switch block_given? usage to defined?(yield) (jeremyevans)
188
+
189
+ * Support table aliases for JOIN USING columns on PostgreSQL 14+ (jeremyevans)
190
+
191
+ * Support calling PostgreSQL procedures without arguments (jeremyevans)
192
+
193
+ * Support hstore subscripts in pg_hstore_ops on PostgreSQL 14+, for updating only part of an hstore value (jeremyevans)
194
+
195
+ * Support JSONB subscripts in pg_json_ops on PostgreSQL 14+, for updating only part of a JSONB value (jeremyevans)
196
+
197
+ * Support SQL::Expression#sequel_ast_transform for custom AST transforms on arbitrary expressions (jeremyevans)
198
+
199
+ * Add Database#create_trigger :replace option on PostgreSQL 14+ for CREATE OR REPLACE TRIGGER (jeremyevans)
200
+
201
+ * Make auto_validations plugin automatically setup no_null_byte validations (jeremyevans)
202
+
203
+ * Add Model#validates_no_null_byte to validation_helpers plugin (jeremyevans)
204
+
205
+ === 5.48.0 (2021-09-01)
206
+
207
+ * Make the unused_associations plugin association reflection tracking work correctly when combining coverage runs (jeremyevans)
208
+
209
+ * Add Database#like_without_collate on MSSQL, to avoid using COLLATE on LIKE arguments, which can significantly improve performance (jeremyevans)
210
+
211
+ * Add Model::Errors#full_message private method for easiest i18n support for errors with multiple attributes (jeremyevans) (#1779)
212
+
213
+ === 5.47.0 (2021-08-01)
214
+
215
+ * Make the unused_associations plugin track access to association reflections to determine whether associations are used (jeremyevans)
216
+
217
+ * Support :db option for join tables in {many,one}_through_many to use a separate query for each join table (jeremyevans)
218
+
219
+ * Support :join_table_db option for many_to_many/one_through_one associations, to use a separate query for the join table (jeremyevans)
220
+
221
+ * Support :allow_eager_graph and :allow_filtering_by association options (jeremyevans)
222
+
223
+ * Add Database#rename_tables on MySQL, for renaming multiple tables in a single call (nick96) (#1774)
224
+
225
+ * Support Dataset#returning on SQLite 3.35+ (jeremyevans)
226
+
227
+ === 5.46.0 (2021-07-01)
228
+
229
+ * Add unused_associations plugin, for determining which associations and association methods are not used (jeremyevans)
230
+
231
+ * Make nil :setter/:adder/:remover/:clearer association options not create related methods (jeremyevans)
232
+
233
+ === 5.45.0 (2021-06-01)
234
+
235
+ * Fix handling of NULL values in boolean columns in the ODBC adapter (jeremyevans) (#1765)
236
+
237
+ * Add auto_validations_constraint_validations_presence_message plugin for auto_validations/constraint_validations presence message integration (jeremyevans)
238
+
239
+ * Support Dataset#with :materialized option on SQLite 3.35+ for [NOT] MATERIALIZED (jeremyevans)
240
+
241
+ * Use ALTER TABLE DROP COLUMN for dropping columns on SQLite 3.35+ (jeremyevans)
242
+
243
+ === 5.44.0 (2021-05-01)
244
+
245
+ * Add concurrent_eager_loading plugin, for eager loading multiple associations concurrently using separate threads (jeremyevans)
246
+
247
+ * Support :weeks as a interval unit in the date_arithmetic extension (jeremyevans) (#1759)
248
+
249
+ * Raise an exception if an interval hash with an unsupported key is passed in the date_arithmetic extension (jeremyevans) (#1759)
250
+
251
+ * Support dropping non-composite unique constraints on SQLite (jeremyevans) (#1755)
252
+
253
+ === 5.43.0 (2021-04-01)
254
+
255
+ * Add column_encryption plugin, for encrypting column values (jeremyevans)
256
+
257
+ === 5.42.0 (2021-03-01)
258
+
259
+ * Make the ado timestamp conversion proc a normal conversion proc that can be overridden similar to other conversion procs (jeremyevans)
260
+
261
+ * Add :reject_nil option to the nested_attributes method, to ignore calls where nil is passed as the associated object data (jeremyevans)
262
+
263
+ * Add async_thread_pool plugin for easier async usage with model classes and support for async destroy, with_pk, and with_pk! methods (jeremyevans)
264
+
265
+ * Add async_thread_pool Database extension for executing queries asynchronously using a thread pool (jeremyevans)
266
+
267
+ * Fix possible thread safety issue in Database#extension that could allow Module#extended to be called twice with the same Database instance (jeremyevans)
268
+
269
+ * Support cases where validations make modifications beyond setting errors in Model#freeze (jeremyevans)
270
+
271
+ * Add Model#to_json_data to the json_serializer plugin, returning a JSON data structure (jeremyevans)
272
+
273
+ === 5.41.0 (2021-02-01)
274
+
275
+ * Have explicit :text option for a String column take priority over :size option on PostgreSQL (jeremyevans) (#1750)
276
+
277
+ * Support a :skip_invalid option in auto_validations plugin for not adding errors to a column that already has an error (jeremyevans)
278
+
279
+ * Support a :skip_invalid option in validation_helpers for not adding an error to a column that already has an error (jeremyevans)
280
+
281
+ * Support :adder, :remover, and :clearer association options that use keyword arguments in Ruby 2.7+ (jeremyevans)
282
+
283
+ * Make pg_interval use the same number of seconds per year and per month as ActiveSupport::Duration when using ActiveSupport 5.1+ (jeremyevans)
284
+
285
+ === 5.40.0 (2021-01-01)
286
+
287
+ * Support UPDATE FROM syntax in SQLite 3.33.0+ (jeremyevans)
288
+
289
+ * Have pg_interval extension work with ActiveSupport 6.1 (jeremyevans)
290
+
291
+ * Have date_arithmetic extension work with ActiveSupport 6.1 (jeremyevans)
292
+
293
+ * Avoid method redefinition warnings in verbose warning mode (jeremyevans)
294
+
1
295
  === 5.39.0 (2020-12-01)
2
296
 
3
297
  * Support :clustered option for primary key and unique constraints on Microsoft SQL Server (jeremyevans)
data/MIT-LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2007-2008 Sharon Rosner
2
- Copyright (c) 2008-2020 Jeremy Evans
2
+ Copyright (c) 2008-2022 Jeremy Evans
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to
data/README.rdoc CHANGED
@@ -17,15 +17,16 @@ toolkit for Ruby.
17
17
 
18
18
  == Resources
19
19
 
20
- Website :: http://sequel.jeremyevans.net
21
- RDoc Documentation :: http://sequel.jeremyevans.net/rdoc
20
+ Website :: https://sequel.jeremyevans.net
21
+ RDoc Documentation :: https://sequel.jeremyevans.net/rdoc
22
22
  Source Code :: https://github.com/jeremyevans/sequel
23
- Bug tracking (GitHub Issues) :: http://github.com/jeremyevans/sequel/issues
24
- Discussion Forum (sequel-talk Google Group) :: http://groups.google.com/group/sequel-talk
25
- IRC Channel (#sequel) :: irc://irc.freenode.net/sequel
23
+ Bug tracking (GitHub Issues) :: https://github.com/jeremyevans/sequel/issues
24
+ Discussion Forum (GitHub Discussions) :: https://github.com/jeremyevans/sequel/discussions
25
+ Alternate Discussion Forum (sequel-talk Google Group) :: http://groups.google.com/group/sequel-talk
26
26
 
27
- If you have questions about how to use Sequel, please ask on the
28
- sequel-talk Google Group or IRC. Only use the the bug tracker to report
27
+ If you have questions about how to use Sequel, please ask on
28
+ GitHub Discussions or the sequel-talk Google Group.
29
+ Only use the the bug tracker to report
29
30
  bugs in Sequel, not to ask for help on using Sequel.
30
31
 
31
32
  To check out the source code:
@@ -55,9 +56,9 @@ If you have any comments or suggestions please post to the Google group.
55
56
  items = DB[:items] # Create a dataset
56
57
 
57
58
  # Populate the table
58
- items.insert(:name => 'abc', :price => rand * 100)
59
- items.insert(:name => 'def', :price => rand * 100)
60
- items.insert(:name => 'ghi', :price => rand * 100)
59
+ items.insert(name: 'abc', price: rand * 100)
60
+ items.insert(name: 'def', price: rand * 100)
61
+ items.insert(name: 'ghi', price: rand * 100)
61
62
 
62
63
  # Print out the number of records
63
64
  puts "Item count: #{items.count}"
@@ -83,7 +84,7 @@ Sequel uses the concept of datasets to retrieve data. A Dataset object encapsula
83
84
 
84
85
  For example, the following one-liner returns the average GDP for countries in the middle east region:
85
86
 
86
- DB[:countries].where(:region => 'Middle East').avg(:GDP)
87
+ DB[:countries].where(region: 'Middle East').avg(:GDP)
87
88
 
88
89
  Which is equivalent to:
89
90
 
@@ -91,7 +92,7 @@ Which is equivalent to:
91
92
 
92
93
  Since datasets retrieve records only when needed, they can be stored and later reused. Records are fetched as hashes, and are accessed using an +Enumerable+ interface:
93
94
 
94
- middle_east = DB[:countries].where(:region => 'Middle East')
95
+ middle_east = DB[:countries].where(region: 'Middle East')
95
96
  middle_east.order(:name).each{|r| puts r[:name]}
96
97
 
97
98
  Sequel also offers convenience methods for extracting data from Datasets, such as an extended +map+ method:
@@ -209,12 +210,12 @@ If the dataset is ordered, you can also ask for the last record:
209
210
 
210
211
  You can also provide a filter when asking for a single record:
211
212
 
212
- posts.first(:id => 1)
213
+ posts.first(id: 1)
213
214
  # SELECT * FROM posts WHERE id = 1 LIMIT 1
214
215
 
215
216
  Or retrieve a single value for a specific record:
216
217
 
217
- posts.where(:id => 1).get(:name)
218
+ posts.where(id: 1).get(:name)
218
219
  # SELECT name FROM posts WHERE id = 1 LIMIT 1
219
220
 
220
221
  === Filtering Records
@@ -410,9 +411,34 @@ As with +delete+, +update+ affects all rows in the dataset, so +where+ first,
410
411
  +update+ second:
411
412
 
412
413
  # DO THIS:
413
- posts.where(Sequel[:stamp] < Date.today - 7).update(:state => 'archived')
414
+ posts.where(Sequel[:stamp] < Date.today - 7).update(state: 'archived')
414
415
  # NOT THIS:
415
- posts.update(:state => 'archived').where(Sequel[:stamp] < Date.today - 7)
416
+ posts.update(state: 'archived').where(Sequel[:stamp] < Date.today - 7)
417
+
418
+ === Merging records
419
+
420
+ Merging records using the SQL MERGE statement is done using <tt>merge*</tt> methods.
421
+ You use +merge_using+ to specify the merge source and join conditions.
422
+ You can use +merge_insert+, +merge_delete+, and/or +merge_update+ to set the
423
+ INSERT, DELETE, and UPDATE clauses for the merge. +merge_insert+ takes the same
424
+ arguments as +insert+, and +merge_update+ takes the same arguments as +update+.
425
+ +merge_insert+, +merge_delete+, and +merge_update+ can all be called with blocks,
426
+ to set the conditions for the related INSERT, DELETE, or UPDATE.
427
+
428
+ Finally, after calling all of the other <tt>merge_*</tt> methods, you call +merge+
429
+ to run the MERGE statement on the database.
430
+
431
+ ds = DB[:m1]
432
+ merge_using(:m2, i1: :i2).
433
+ merge_insert(i1: :i2, a: Sequel[:b]+11).
434
+ merge_delete{a > 30}.
435
+ merge_update(i1: Sequel[:i1]+:i2+10, a: Sequel[:a]+:b+20)
436
+
437
+ ds.merge
438
+ # MERGE INTO m1 USING m2 ON (i1 = i2)
439
+ # WHEN NOT MATCHED THEN INSERT (i1, a) VALUES (i2, (b + 11))
440
+ # WHEN MATCHED AND (a > 30) THEN DELETE
441
+ # WHEN MATCHED THEN UPDATE SET i1 = (i1 + i2 + 10), a = (a + b + 20)
416
442
 
417
443
  === Transactions
418
444
 
@@ -422,7 +448,7 @@ You can wrap a block of code in a database transaction using the <tt>Database#tr
422
448
  # BEGIN
423
449
  posts.insert(category: 'ruby', author: 'david')
424
450
  # INSERT
425
- posts.where(Sequel[:stamp] < Date.today - 7).update(:state => 'archived')
451
+ posts.where(Sequel[:stamp] < Date.today - 7).update(state: 'archived')
426
452
  # UPDATE
427
453
  end
428
454
  # COMMIT
@@ -435,9 +461,9 @@ and not raise an exception outside the block, you can raise the
435
461
 
436
462
  DB.transaction do
437
463
  # BEGIN
438
- posts.insert(:category => 'ruby', :author => 'david')
464
+ posts.insert(category: 'ruby', author: 'david')
439
465
  # INSERT
440
- if posts.where('stamp < ?', Date.today - 7).update(:state => 'archived') == 0
466
+ if posts.where('stamp < ?', Date.today - 7).update(state: 'archived') == 0
441
467
  # UPDATE
442
468
  raise Sequel::Rollback
443
469
  end
@@ -680,8 +706,8 @@ You can delete individual records by calling +delete+ or +destroy+. The only dif
680
706
 
681
707
  Records can also be deleted en-masse by calling <tt>delete</tt> and <tt>destroy</tt> on the model's dataset. As stated above, you can specify filters for the deleted records:
682
708
 
683
- Post.where(:category => 32).delete # => bypasses hooks
684
- Post.where(:category => 32).destroy # => runs hooks
709
+ Post.where(category: 32).delete # => bypasses hooks
710
+ Post.where(category: 32).destroy # => runs hooks
685
711
 
686
712
  Please note that if <tt>destroy</tt> is called, each record is deleted
687
713
  separately, but <tt>delete</tt> deletes all matching records with a single
@@ -694,9 +720,9 @@ Associations are used in order to specify relationships between model classes th
694
720
  class Post < Sequel::Model
695
721
  many_to_one :author
696
722
  one_to_many :comments
697
- one_to_one :first_comment, :class=>:Comment, :order=>:id
723
+ one_to_one :first_comment, class: :Comment, order: :id
698
724
  many_to_many :tags
699
- one_through_one :first_tag, :class=>:Tag, :order=>:name, :right_key=>:tag_id
725
+ one_through_one :first_tag, class: :Tag, order: :name, right_key: :tag_id
700
726
  end
701
727
 
702
728
  +many_to_one+ and +one_to_one+ create a getter and setter for each model object:
@@ -735,7 +761,7 @@ All associations add a dataset method that can be used to further filter or reor
735
761
  Associations can be eagerly loaded via +eager+ and the <tt>:eager</tt> association option. Eager loading is used when loading a group of objects. It loads all associated objects for all of the current objects in one query, instead of using a separate query to get the associated objects for each current object. Eager loading requires that you retrieve all model objects at once via +all+ (instead of individually by +each+). Eager loading can be cascaded, loading association's associated objects.
736
762
 
737
763
  class Person < Sequel::Model
738
- one_to_many :posts, :eager=>[:tags]
764
+ one_to_many :posts, eager: [:tags]
739
765
  end
740
766
 
741
767
  class Post < Sequel::Model
@@ -880,6 +906,11 @@ raise an error by default:
880
906
  end
881
907
  end
882
908
 
909
+ == Testing Sequel
910
+
911
+ Please see the {testing guide}[rdoc-ref:doc/testing.rdoc] for recommendations on testing
912
+ applications that use Sequel, as well as the how to run the tests for Sequel itself.
913
+
883
914
  == Sequel Release Policy
884
915
 
885
916
  New major versions of Sequel do not have a defined release policy, but historically have
@@ -895,7 +926,8 @@ in the most current release.
895
926
  Sequel fully supports the currently supported versions of Ruby (MRI) and JRuby. It may
896
927
  support unsupported versions of Ruby or JRuby, but such support may be dropped in any
897
928
  minor version if keeping it becomes a support issue. The minimum Ruby version
898
- required to run the current version of Sequel is 1.9.2.
929
+ required to run the current version of Sequel is 1.9.2, and the minimum JRuby version is
930
+ 9.0.0.0.
899
931
 
900
932
  == Maintainer
901
933
 
data/bin/sequel CHANGED
@@ -194,7 +194,11 @@ begin
194
194
  TO_DB = connect_proc[db2]
195
195
  same_db = DB.database_type==TO_DB.database_type
196
196
  index_opts = {:same_db=>same_db}
197
+
198
+ # :nocov:
197
199
  index_opts[:index_names] = :namespace if !DB.global_index_namespace? && TO_DB.global_index_namespace?
200
+ # :nocov:
201
+
198
202
  if DB.database_type == :sqlite && !same_db
199
203
  # SQLite integer types allows 64-bit integers
200
204
  TO_DB.extension :integer64
@@ -212,18 +216,20 @@ begin
212
216
  puts "Begin copying data"
213
217
  DB.transaction do
214
218
  TO_DB.transaction do
219
+ all_status_lines = ENV['SEQUEL_BIN_STATUS_ALL_LINES']
220
+
215
221
  DB.tables.each do |table|
216
222
  puts "Begin copying records for table: #{table}"
217
223
  time = Time.now
218
224
  to_ds = TO_DB.from(table)
219
225
  j = 0
220
226
  DB.from(table).each do |record|
221
- if Time.now - time > 5
227
+ to_ds.insert(record)
228
+ j += 1
229
+ if Time.now - time > 5 || all_status_lines
222
230
  puts "Status: #{j} records copied"
223
231
  time = Time.now
224
232
  end
225
- to_ds.insert(record)
226
- j += 1
227
233
  end
228
234
  puts "Finished copying #{j} records for table: #{table}"
229
235
  end
@@ -260,8 +266,10 @@ if !ARGV.empty?
260
266
  ARGV.each{|v| load(v)}
261
267
  elsif !$stdin.isatty
262
268
  eval($stdin.read)
269
+ # :nocov:
263
270
  else
264
271
  require 'irb'
265
272
  puts "Your database is stored in DB..."
266
273
  IRB.start
267
274
  end
275
+ # :nocov:
@@ -115,7 +115,7 @@ These two approaches can also be nested, with +eager+ -> +eager_graph+ -> +eager
115
115
 
116
116
  Or with 2 separate +eager_graph+ queries:
117
117
 
118
- Artist.eager_graph(:albums).eager_graph_eager([:albums], :tracks=>proc{|ds| ds.eager_graph(:lyric)})
118
+ Artist.eager_graph(:albums).eager_graph_eager([:albums], tracks: proc{|ds| ds.eager_graph(:lyric)})
119
119
  # 2 Queries:
120
120
  # SELECT artists.id, artists.name, ...
121
121
  # albums.id AS albums_id, albums.name AS albums_name, ...
@@ -238,9 +238,9 @@ have the following associations
238
238
 
239
239
  and the following three albums in the database:
240
240
 
241
- album1 = Album.create(:artist_id=>3) # id: 1
242
- album2 = Album.create(:artist_id=>3) # id: 2
243
- album3 = Album.create(:artist_id=>2) # id: 3
241
+ album1 = Album.create(artist_id: 3) # id: 1
242
+ album2 = Album.create(artist_id: 3) # id: 2
243
+ album3 = Album.create(artist_id: 2) # id: 3
244
244
 
245
245
  If you try to eager load this dataset:
246
246
 
@@ -256,7 +256,7 @@ the are both in the array related to that key. album3 has a different
256
256
  artist_id, so it is in a different array. Eager loading of artists is
257
257
  done by looking for any artist having one of the keys in the hash:
258
258
 
259
- artists = Artist.where(:id=>id_map.keys).all
259
+ artists = Artist.where(id: id_map.keys).all
260
260
 
261
261
  When the artists are retrieved, you can iterate over them, find entries
262
262
  with matching keys, and manually associate them to the albums:
@@ -281,7 +281,7 @@ case each array only has a single object, because id is the primary key). So wh
281
281
  looking for tracks to eagerly load, you only need to look for ones that have an
282
282
  album_id with one of the keys in the hash:
283
283
 
284
- tracks = Track.where(:album_id=>id_map.keys).all
284
+ tracks = Track.where(album_id: id_map.keys).all
285
285
 
286
286
  When the tracks are retrieved, you can iterate over them, find entries with matching
287
287
  keys, and manually associate them to the albums:
@@ -314,10 +314,10 @@ artist or tracks method on the album will not do another database lookup.
314
314
 
315
315
  So putting everything together, the artist eager loader looks like:
316
316
 
317
- Album.many_to_one :artist, :eager_loader=>(proc do |eo_opts|
317
+ Album.many_to_one :artist, eager_loader: (proc do |eo_opts|
318
318
  eo_opts[:rows].each{|album| album.associations[:artist] = nil}
319
319
  id_map = eo_opts[:id_map]
320
- Artist.where(:id=>id_map.keys).all do |artist|
320
+ Artist.where(id: id_map.keys).all do |artist|
321
321
  if albums = id_map[artist.id]
322
322
  albums.each do |album|
323
323
  album.associations[:artist] = artist
@@ -328,10 +328,10 @@ So putting everything together, the artist eager loader looks like:
328
328
 
329
329
  and the tracks eager loader looks like:
330
330
 
331
- Album.one_to_many :tracks, :eager_loader=>(proc do |eo_opts|
331
+ Album.one_to_many :tracks, eager_loader: (proc do |eo_opts|
332
332
  eo_opts[:rows].each{|album| album.associations[:tracks] = []}
333
333
  id_map = eo_opts[:id_map]
334
- Track.where(:album_id=>id_map.keys).all do |track|
334
+ Track.where(album_id: id_map.keys).all do |track|
335
335
  if albums = id_map[track.album_id]
336
336
  albums.each do |album|
337
337
  album.associations[:tracks] << track
@@ -405,7 +405,7 @@ the window function strategy:
405
405
 
406
406
  Artist.one_to_many :first_10_albums, class: :Album, order: :release_date, limit: 10,
407
407
  eager_limit_strategy: :window_function
408
- Artist.where(:id=>[1,2]).eager(:first_10_albums).all
408
+ Artist.where(id: [1,2]).eager(:first_10_albums).all
409
409
  # SELECT * FROM (
410
410
  # SELECT *, row_number() OVER (PARTITION BY albums.artist_id ORDER BY release_date) AS x_sequel_row_number_x
411
411
  # FROM albums
@@ -483,7 +483,7 @@ function:
483
483
  The :correlated_subquery approach JOINs to a nested subquery using a correlated
484
484
  subquery:
485
485
 
486
- Artist.eager_graph_with_options(:first_10_albums, :limit_strategy=>:correlated_subquery).all
486
+ Artist.eager_graph_with_options(:first_10_albums, limit_strategy: :correlated_subquery).all
487
487
  # SELECT artists.id, artists.name, first_10_albums.id AS first_10_albums_id,
488
488
  # first_10_albums.name AS first_10_albums_name, first_10_albums.artist_id,
489
489
  # first_10_albums.release_date
@@ -853,7 +853,7 @@ associated tickets.
853
853
  class Project < Sequel::Model
854
854
  one_to_many :tickets
855
855
  many_to_one :ticket_hours, read_only: true, key: :id,
856
- dataset: proc{Ticket.where(:project_id=>id).select{sum(hours).as(hours)}},
856
+ dataset: proc{Ticket.where(project_id: id).select{sum(hours).as(hours)}},
857
857
  eager_loader: (lambda do |eo|
858
858
  eo[:rows].each{|p| p.associations[:ticket_hours] = nil}
859
859
  Ticket.where(project_id: eo[:id_map].keys).