sequel 5.39.0 → 5.65.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.
- checksums.yaml +4 -4
- data/CHANGELOG +326 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +57 -25
- data/bin/sequel +11 -3
- data/doc/advanced_associations.rdoc +13 -13
- data/doc/association_basics.rdoc +119 -24
- data/doc/cheat_sheet.rdoc +11 -3
- data/doc/migration.rdoc +12 -6
- data/doc/model_hooks.rdoc +1 -1
- data/doc/object_model.rdoc +8 -8
- data/doc/opening_databases.rdoc +18 -11
- data/doc/postgresql.rdoc +16 -8
- data/doc/querying.rdoc +5 -3
- data/doc/release_notes/5.40.0.txt +40 -0
- data/doc/release_notes/5.41.0.txt +25 -0
- data/doc/release_notes/5.42.0.txt +136 -0
- data/doc/release_notes/5.43.0.txt +98 -0
- data/doc/release_notes/5.44.0.txt +32 -0
- data/doc/release_notes/5.45.0.txt +34 -0
- data/doc/release_notes/5.46.0.txt +87 -0
- data/doc/release_notes/5.47.0.txt +59 -0
- data/doc/release_notes/5.48.0.txt +14 -0
- data/doc/release_notes/5.49.0.txt +59 -0
- data/doc/release_notes/5.50.0.txt +78 -0
- data/doc/release_notes/5.51.0.txt +47 -0
- data/doc/release_notes/5.52.0.txt +87 -0
- data/doc/release_notes/5.53.0.txt +23 -0
- data/doc/release_notes/5.54.0.txt +27 -0
- data/doc/release_notes/5.55.0.txt +21 -0
- data/doc/release_notes/5.56.0.txt +51 -0
- data/doc/release_notes/5.57.0.txt +23 -0
- data/doc/release_notes/5.58.0.txt +31 -0
- data/doc/release_notes/5.59.0.txt +73 -0
- data/doc/release_notes/5.60.0.txt +22 -0
- data/doc/release_notes/5.61.0.txt +43 -0
- data/doc/release_notes/5.62.0.txt +132 -0
- data/doc/release_notes/5.63.0.txt +33 -0
- data/doc/release_notes/5.64.0.txt +50 -0
- data/doc/release_notes/5.65.0.txt +21 -0
- data/doc/schema_modification.rdoc +1 -1
- data/doc/security.rdoc +9 -9
- data/doc/sql.rdoc +28 -16
- data/doc/testing.rdoc +22 -11
- data/doc/transactions.rdoc +6 -6
- data/doc/virtual_rows.rdoc +2 -2
- data/lib/sequel/adapters/ado/access.rb +1 -1
- data/lib/sequel/adapters/ado.rb +17 -17
- data/lib/sequel/adapters/amalgalite.rb +3 -5
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc/derby.rb +8 -0
- data/lib/sequel/adapters/jdbc/h2.rb +60 -10
- data/lib/sequel/adapters/jdbc/hsqldb.rb +6 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +4 -4
- data/lib/sequel/adapters/jdbc.rb +16 -18
- data/lib/sequel/adapters/mysql.rb +80 -67
- data/lib/sequel/adapters/mysql2.rb +54 -49
- data/lib/sequel/adapters/odbc.rb +6 -2
- data/lib/sequel/adapters/oracle.rb +4 -3
- data/lib/sequel/adapters/postgres.rb +83 -40
- data/lib/sequel/adapters/shared/access.rb +11 -1
- data/lib/sequel/adapters/shared/db2.rb +30 -0
- data/lib/sequel/adapters/shared/mssql.rb +58 -7
- data/lib/sequel/adapters/shared/mysql.rb +47 -2
- data/lib/sequel/adapters/shared/oracle.rb +76 -0
- data/lib/sequel/adapters/shared/postgres.rb +418 -174
- data/lib/sequel/adapters/shared/sqlanywhere.rb +11 -1
- data/lib/sequel/adapters/shared/sqlite.rb +103 -11
- data/lib/sequel/adapters/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/sqlite.rb +60 -18
- data/lib/sequel/adapters/tinytds.rb +1 -1
- data/lib/sequel/adapters/utils/columns_limit_1.rb +22 -0
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -1
- data/lib/sequel/ast_transformer.rb +6 -0
- data/lib/sequel/connection_pool/sharded_single.rb +5 -7
- data/lib/sequel/connection_pool/sharded_threaded.rb +5 -1
- data/lib/sequel/connection_pool/single.rb +6 -8
- data/lib/sequel/connection_pool/threaded.rb +8 -8
- data/lib/sequel/connection_pool/timed_queue.rb +257 -0
- data/lib/sequel/connection_pool.rb +47 -30
- data/lib/sequel/core.rb +28 -18
- data/lib/sequel/database/connecting.rb +26 -2
- data/lib/sequel/database/misc.rb +69 -14
- data/lib/sequel/database/query.rb +73 -2
- data/lib/sequel/database/schema_generator.rb +45 -52
- data/lib/sequel/database/schema_methods.rb +17 -1
- data/lib/sequel/dataset/actions.rb +107 -13
- data/lib/sequel/dataset/features.rb +20 -0
- data/lib/sequel/dataset/misc.rb +12 -2
- data/lib/sequel/dataset/placeholder_literalizer.rb +20 -9
- data/lib/sequel/dataset/prepared_statements.rb +2 -0
- data/lib/sequel/dataset/query.rb +118 -16
- data/lib/sequel/dataset/sql.rb +177 -47
- data/lib/sequel/extensions/_model_pg_row.rb +0 -12
- data/lib/sequel/extensions/_pretty_table.rb +1 -1
- data/lib/sequel/extensions/any_not_empty.rb +1 -1
- data/lib/sequel/extensions/async_thread_pool.rb +438 -0
- data/lib/sequel/extensions/auto_literal_strings.rb +1 -1
- data/lib/sequel/extensions/blank.rb +8 -0
- data/lib/sequel/extensions/constraint_validations.rb +1 -1
- data/lib/sequel/extensions/core_refinements.rb +36 -11
- data/lib/sequel/extensions/date_arithmetic.rb +71 -31
- data/lib/sequel/extensions/date_parse_input_handler.rb +67 -0
- data/lib/sequel/extensions/datetime_parse_to_time.rb +5 -1
- data/lib/sequel/extensions/duplicate_columns_handler.rb +1 -1
- data/lib/sequel/extensions/eval_inspect.rb +2 -0
- data/lib/sequel/extensions/inflector.rb +9 -1
- data/lib/sequel/extensions/is_distinct_from.rb +141 -0
- data/lib/sequel/extensions/looser_typecasting.rb +3 -0
- data/lib/sequel/extensions/migration.rb +7 -2
- data/lib/sequel/extensions/named_timezones.rb +26 -6
- data/lib/sequel/extensions/pagination.rb +1 -1
- data/lib/sequel/extensions/pg_array.rb +23 -3
- data/lib/sequel/extensions/pg_array_ops.rb +2 -2
- data/lib/sequel/extensions/pg_auto_parameterize.rb +509 -0
- data/lib/sequel/extensions/pg_enum.rb +1 -1
- data/lib/sequel/extensions/pg_extended_date_support.rb +28 -25
- data/lib/sequel/extensions/pg_extended_integer_support.rb +116 -0
- data/lib/sequel/extensions/pg_hstore.rb +6 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +53 -3
- data/lib/sequel/extensions/pg_inet.rb +10 -11
- data/lib/sequel/extensions/pg_inet_ops.rb +1 -1
- data/lib/sequel/extensions/pg_interval.rb +45 -19
- data/lib/sequel/extensions/pg_json.rb +13 -15
- data/lib/sequel/extensions/pg_json_ops.rb +73 -2
- data/lib/sequel/extensions/pg_loose_count.rb +3 -1
- data/lib/sequel/extensions/pg_multirange.rb +367 -0
- data/lib/sequel/extensions/pg_range.rb +10 -23
- data/lib/sequel/extensions/pg_range_ops.rb +37 -9
- data/lib/sequel/extensions/pg_row.rb +19 -13
- data/lib/sequel/extensions/pg_row_ops.rb +1 -1
- data/lib/sequel/extensions/query.rb +2 -0
- data/lib/sequel/extensions/s.rb +2 -1
- data/lib/sequel/extensions/schema_dumper.rb +13 -2
- data/lib/sequel/extensions/server_block.rb +8 -12
- data/lib/sequel/extensions/sql_comments.rb +110 -3
- data/lib/sequel/extensions/sql_log_normalizer.rb +108 -0
- data/lib/sequel/extensions/sqlite_json_ops.rb +255 -0
- data/lib/sequel/extensions/string_agg.rb +1 -1
- data/lib/sequel/extensions/string_date_time.rb +19 -23
- data/lib/sequel/extensions/symbol_aref.rb +2 -0
- data/lib/sequel/model/associations.rb +345 -101
- data/lib/sequel/model/base.rb +51 -27
- data/lib/sequel/model/errors.rb +10 -1
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/model/plugins.rb +5 -0
- data/lib/sequel/plugins/association_proxies.rb +2 -0
- data/lib/sequel/plugins/async_thread_pool.rb +39 -0
- data/lib/sequel/plugins/auto_restrict_eager_graph.rb +62 -0
- data/lib/sequel/plugins/auto_validations.rb +87 -15
- data/lib/sequel/plugins/auto_validations_constraint_validations_presence_message.rb +68 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
- data/lib/sequel/plugins/column_encryption.rb +728 -0
- data/lib/sequel/plugins/composition.rb +10 -4
- data/lib/sequel/plugins/concurrent_eager_loading.rb +174 -0
- data/lib/sequel/plugins/constraint_validations.rb +2 -1
- data/lib/sequel/plugins/dataset_associations.rb +4 -1
- data/lib/sequel/plugins/dirty.rb +1 -1
- data/lib/sequel/plugins/enum.rb +124 -0
- data/lib/sequel/plugins/finder.rb +4 -2
- data/lib/sequel/plugins/insert_conflict.rb +4 -0
- data/lib/sequel/plugins/instance_specific_default.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +39 -24
- data/lib/sequel/plugins/lazy_attributes.rb +3 -0
- data/lib/sequel/plugins/list.rb +3 -1
- data/lib/sequel/plugins/many_through_many.rb +109 -10
- data/lib/sequel/plugins/nested_attributes.rb +12 -7
- data/lib/sequel/plugins/pg_array_associations.rb +56 -38
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +3 -1
- data/lib/sequel/plugins/prepared_statements.rb +10 -1
- data/lib/sequel/plugins/primary_key_lookup_check_values.rb +154 -0
- data/lib/sequel/plugins/rcte_tree.rb +27 -19
- data/lib/sequel/plugins/require_valid_schema.rb +67 -0
- data/lib/sequel/plugins/serialization.rb +9 -3
- data/lib/sequel/plugins/serialization_modification_detection.rb +2 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +8 -0
- data/lib/sequel/plugins/sql_comments.rb +189 -0
- data/lib/sequel/plugins/static_cache.rb +1 -1
- data/lib/sequel/plugins/subclasses.rb +28 -11
- data/lib/sequel/plugins/tactical_eager_loading.rb +23 -10
- data/lib/sequel/plugins/timestamps.rb +1 -1
- data/lib/sequel/plugins/unused_associations.rb +521 -0
- data/lib/sequel/plugins/update_or_create.rb +1 -1
- data/lib/sequel/plugins/validate_associated.rb +22 -12
- data/lib/sequel/plugins/validation_helpers.rb +38 -11
- data/lib/sequel/plugins/xml_serializer.rb +1 -1
- data/lib/sequel/sql.rb +1 -1
- data/lib/sequel/timezones.rb +12 -14
- data/lib/sequel/version.rb +1 -1
- metadata +101 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24bfe7c123337539140b0385dd9a828fe0fec4d6ad4e39e5fd8f150258ae7a03
|
|
4
|
+
data.tar.gz: d820be46e60ba7b08b1129f0a6b67a24a550a27d5b682a84730172bc256f4118
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd5c7dacdf48f8ada7c34c88210ac804faa1b47741f946ca16cd6f645c1f86055eb85ac6b601e9cef2ab4aa8a5cba3dc444e3005d6ed61d324c1158f2e03a70e
|
|
7
|
+
data.tar.gz: d17eb580a3f50f4b0c33561aed320c2ea3089044b905f4dc845ea8682afe1cdbf2798c6cd202f1233b1d168d06c9686a94728d41e0f47264245a33da5a99b251
|
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,329 @@
|
|
|
1
|
+
=== 5.65.0 (2023-02-01)
|
|
2
|
+
|
|
3
|
+
* Allow pg_auto_parameterize extension to use placeholder loaders (jeremyevans)
|
|
4
|
+
|
|
5
|
+
* Do not include :min_value and :max_value schema entries for decimal/numeric columns on MySQL versions not supporting check constraints (jeremyevans)
|
|
6
|
+
|
|
7
|
+
* Make Database#indexes return indexes for partitioned tables on PostgreSQL 11+ (jeremyevans)
|
|
8
|
+
|
|
9
|
+
=== 5.64.0 (2023-01-01)
|
|
10
|
+
|
|
11
|
+
* Make :db_type column schema entries on SQLAnywhere include precision/scale information (jeremyevans)
|
|
12
|
+
|
|
13
|
+
* Include :min_value and :max_value schema entries for decimal/numeric columns on most databases (rolftimmermans, jeremyevans) (#1975)
|
|
14
|
+
|
|
15
|
+
* Support :graph_use_association_block association option to make eager_graph use the association block (jeremyevans)
|
|
16
|
+
|
|
17
|
+
* Make many_through_many and many_through_one associations support eager_graph callbacks (jeremyevans)
|
|
18
|
+
|
|
19
|
+
=== 5.63.0 (2022-12-01)
|
|
20
|
+
|
|
21
|
+
* Make validates_associated plugin avoid database type errors for non-integer association keys (jeremyevans) (#1968)
|
|
22
|
+
|
|
23
|
+
* Make tactical_eager_loading plugin work better with table inheritance plugins (rolftimmermans, jeremyevans) (#1962)
|
|
24
|
+
|
|
25
|
+
* Add support for pool_class: :timed_queue on Ruby 3.2+, using a Queue for available connections (jeremyevans)
|
|
26
|
+
|
|
27
|
+
* Allow :pool_class Database option to be specified as a string to more easily choose a different pool type (jeremyevans)
|
|
28
|
+
|
|
29
|
+
* Use compare_by_identity hashes for Thread-keyed hashes in threaded connection pools (jeremyevans)
|
|
30
|
+
|
|
31
|
+
* Skip use of JRuby workaround on JRuby 9.3.9.0+ in named_timezones extension as JRuby fixed the related bug (jeremyevans)
|
|
32
|
+
|
|
33
|
+
=== 5.62.0 (2022-11-01)
|
|
34
|
+
|
|
35
|
+
* Add back the pg_auto_parameterize extension for automatically using bound variables when using postgres adapter with pg driver (jeremyevans)
|
|
36
|
+
|
|
37
|
+
* Add pg_extended_integer_support extension for customizing behavior when literalizing a Ruby integer outside PostgreSQL bigint range (jeremyevans)
|
|
38
|
+
|
|
39
|
+
* Raise Postgres::IntegerOutsideBigintRange if attempting to literalize a Ruby integer outside PostgreSQL bigint range (jeremyevans)
|
|
40
|
+
|
|
41
|
+
* Add primary_key_lookup_check_values plugin for typecasting and checking primary key values during lookup (jeremyevans)
|
|
42
|
+
|
|
43
|
+
* Setup validation of minimum and maximum values for integer columns in auto_validations (jeremyevans)
|
|
44
|
+
|
|
45
|
+
* Add validates_max_value and validates_min_value to validation_helpers (jeremyevans)
|
|
46
|
+
|
|
47
|
+
* Include :min_value and :max_value schema entries for integer columns on most databases (jeremyevans)
|
|
48
|
+
|
|
49
|
+
* Don't wrap multi-inserts in a transaction when it's not required (shannoncole, jeremyevans) (#1945)
|
|
50
|
+
|
|
51
|
+
* Update mock PostgreSQL adapter to default to PostgreSQL 15 instead of PostgreSQL 14 (jeremyevans)
|
|
52
|
+
|
|
53
|
+
* Support fractional seconds in the named_timezones extension (jeremyevans) (#1943)
|
|
54
|
+
|
|
55
|
+
* Cache reflection datasets in the postgres adapter to improve performance (jeremyevans)
|
|
56
|
+
|
|
57
|
+
* Handle BC dates and timestamps in bound variables when using the pg_extended_date_support extension (jeremyevans)
|
|
58
|
+
|
|
59
|
+
* Correctly format hstore[] types in bound variables on PostgreSQL (jeremyevans)
|
|
60
|
+
|
|
61
|
+
* Fix corner case in eager loading where window function eager limit strategy is used, but row number entry is not removed (jeremyevans)
|
|
62
|
+
|
|
63
|
+
* Support server/shard specific :after_connect and :connect_sqls Database options (jeremyevans) (#1935)
|
|
64
|
+
|
|
65
|
+
=== 5.61.0 (2022-10-01)
|
|
66
|
+
|
|
67
|
+
* Make Database#foreign_key_list on PostgreSQL return results for partitioned tables (jeremyevans)
|
|
68
|
+
|
|
69
|
+
* Add Database#check_string_typecast_bytesize for checking bytesize of strings before typecasting (jeremyevans)
|
|
70
|
+
|
|
71
|
+
* Treat negative hexidecimal strings similar to positive hexidecimal strings when typecasting to integer (jeremyevans)
|
|
72
|
+
|
|
73
|
+
* 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)
|
|
74
|
+
|
|
75
|
+
* Fix handling of timestamps before the date of calendar reform when using pg_extended_date_support extension on Ruby 3.2 (jeremyevans)
|
|
76
|
+
|
|
77
|
+
=== 5.60.1 (2022-09-02)
|
|
78
|
+
|
|
79
|
+
* Revert conversion of respond_to? to defined?, as it breaks with unused refinements on Ruby 2 (jeremyevans) (#1919)
|
|
80
|
+
|
|
81
|
+
=== 5.60.0 (2022-09-01)
|
|
82
|
+
|
|
83
|
+
* Support arbitrary expressions for date_arithmetic interval values on PostgreSQL 9.4+ (jeremyevans)
|
|
84
|
+
|
|
85
|
+
* Support native IS DISTINCT FROM on SQLite 3.39+ instead of emulating support in the is_distinct_from extension (jeremyevans)
|
|
86
|
+
|
|
87
|
+
* Support HAVING without GROUP BY on SQLite 3.39+ (jeremyevans)
|
|
88
|
+
|
|
89
|
+
* Convert most respond_to? calls to equivalent defined? for better performance (jeremyevans)
|
|
90
|
+
|
|
91
|
+
=== 5.59.0 (2022-08-01)
|
|
92
|
+
|
|
93
|
+
* Set :allow_eager association option to false for instance specific associations without eager loaders (jeremyevans)
|
|
94
|
+
|
|
95
|
+
* Add require_valid_schema plugin for checking that model classes have schema parsed as expected (jeremyevans)
|
|
96
|
+
|
|
97
|
+
* Model classes created from aliased expressions and literal strings no longer use the simple table optimization (jeremyevans)
|
|
98
|
+
|
|
99
|
+
* Model code that does not swallow connection errors will now also not swallow disconnect errors (jeremyevans) (#1892)
|
|
100
|
+
|
|
101
|
+
* Add is_json and is_not_json methods to the pg_json_ops extension, for the PostgreSQL 15+ IS [NOT] JSON operator (jeremyevans)
|
|
102
|
+
|
|
103
|
+
* Support :security_invoker view option on PostgreSQL 15+, for views where access uses permissions of user instead of owner (jeremyevans)
|
|
104
|
+
|
|
105
|
+
* Support :nulls_distinct index option on PostgreSQL 15+, for NULLS [NOT] DISTINCT (jeremyevans)
|
|
106
|
+
|
|
107
|
+
* Support sequel-postgres-pr driver in the postgres adapter (jeremyevans)
|
|
108
|
+
|
|
109
|
+
=== 5.58.0 (2022-07-01)
|
|
110
|
+
|
|
111
|
+
* Support :disable_split_materialized Database option on MySQL to work around optimizer bug in MariaDB 10.5+ affecting association tests (jeremyevans)
|
|
112
|
+
|
|
113
|
+
* Add Dataset#merge* methods to support MERGE statement on PostgreSQL 15+, MSSQL, Oracle, DB2, H2, HSQLDB, and Derby (jeremyevans)
|
|
114
|
+
|
|
115
|
+
=== 5.57.0 (2022-06-01)
|
|
116
|
+
|
|
117
|
+
* Make Database#create_function on PostgreSQL accept :parallel option (bananarne) (#1870)
|
|
118
|
+
|
|
119
|
+
* Add support for :on_update_current_timestamp column option on MySQL (jeremyevans)
|
|
120
|
+
|
|
121
|
+
* Add is_distinct_from extension with support for the IS DISTINCT FROM operator (jeremyevans)
|
|
122
|
+
|
|
123
|
+
=== 5.56.0 (2022-05-01)
|
|
124
|
+
|
|
125
|
+
* Make alter_table add_column/add_foreign_key methods support :index option to create an index on the column (jeremyevans)
|
|
126
|
+
|
|
127
|
+
* Support creation of STRICT tables on SQLite 3.37.0+ via create_table :strict option (jeremyevans)
|
|
128
|
+
|
|
129
|
+
* Add sqlite_json_ops extension for DSL support for JSON functions and operators added in SQLite 3.38.0 (jeremyevans)
|
|
130
|
+
|
|
131
|
+
* Recognize "INTEGER" type same as "integer" type in the schema dumper, helpful on SQLite 3.37.0+ (jeremyevans)
|
|
132
|
+
|
|
133
|
+
=== 5.55.0 (2022-04-01)
|
|
134
|
+
|
|
135
|
+
* Support :setup_regexp_function Database option in the sqlite adapter to allow the use of regexps when querying (jeremyevans)
|
|
136
|
+
|
|
137
|
+
* Add auto_restrict_eager_graph plugin for automatically disallow eager_graph with associations needing but lacking graph options (jeremyevans)
|
|
138
|
+
|
|
139
|
+
* Fix placeholder literalizer optimization for dataset aggregate methods on a model dataset (belousovAV) (#1847, #1848)
|
|
140
|
+
|
|
141
|
+
=== 5.54.0 (2022-03-01)
|
|
142
|
+
|
|
143
|
+
* Add enum plugin for treating columns as enums in a model (jeremyevans) (#1839)
|
|
144
|
+
|
|
145
|
+
=== 5.53.0 (2022-02-01)
|
|
146
|
+
|
|
147
|
+
* Make Dataset#_sql_comment private when using the Database sql_comments extension (jeremyevans)
|
|
148
|
+
|
|
149
|
+
* Fix prepared statements in the mysql2 adapter to reuse native prepared statements (jeremyevans) (#1832)
|
|
150
|
+
|
|
151
|
+
* Support H2 version 2+ in the jdbc/h2 adapter (jeremyevans) (#1817)
|
|
152
|
+
|
|
153
|
+
* Work around active_support breaking subclasses plugin on Ruby <3.1 (jeremyevans) (#1816)
|
|
154
|
+
|
|
155
|
+
* Fix error handling if trying to setup column_encryption plugin without keys (jeremyevans) (#1815)
|
|
156
|
+
|
|
157
|
+
=== 5.52.0 (2022-01-01)
|
|
158
|
+
|
|
159
|
+
* Use Class#subclasses if available in the subclasses plugin, instead of a custom Model.subclasses accessor (jeremyevans)
|
|
160
|
+
|
|
161
|
+
* Add Model.descendants and .freeze_descendants to subclasses plugin (jeremyevans)
|
|
162
|
+
|
|
163
|
+
* Avoid use of deprecated Refinement#include on Ruby 3.1+ (jeremyevans)
|
|
164
|
+
|
|
165
|
+
* Add date_parse_input_handler extension for custom handling of input to date parsing methods (jeremyevans)
|
|
166
|
+
|
|
167
|
+
* Make postgres adapter respect Database#default_string_column_size (jeremyevans)
|
|
168
|
+
|
|
169
|
+
* Make pg_interval extension work with ActiveSupport 7.0 (jeremyevans)
|
|
170
|
+
|
|
171
|
+
* Make :ruby_default schema entry for type: :datetime respect Sequel.datetime_class (jeremyevans)
|
|
172
|
+
|
|
173
|
+
* Make alter_table drop_constraint have an effect on MySQL 8.0.19+ (jeremyevans)
|
|
174
|
+
|
|
175
|
+
* Make mysql adapter support ruby-mysql 3 API (jeremyevans) (#1795)
|
|
176
|
+
|
|
177
|
+
* Make mysql adapter no longer use connection's server_version, since it isn't accurate when using the ruby-mysql driver (jeremyevans)
|
|
178
|
+
|
|
179
|
+
* Add sql_comments plugin for automatically including comments on queries generated by model class, instance, and dataset methods (jeremyevans)
|
|
180
|
+
|
|
181
|
+
* Make sql_comments Database extension support Database#with_comments, for automatically including comments for queries executed inside the block (jeremyevans)
|
|
182
|
+
|
|
183
|
+
* Fix sql_comments extension to not modify cached SQL for a dataset (jeremyevans)
|
|
184
|
+
|
|
185
|
+
=== 5.51.0 (2021-12-01)
|
|
186
|
+
|
|
187
|
+
* Make eager loading via tactical_eager_loading no longer modify objects who already have a cached value for the association (jeremyevans)
|
|
188
|
+
|
|
189
|
+
* Make association cloning handle cases where clone association sets different :class option than cloned association (jeremyevans)
|
|
190
|
+
|
|
191
|
+
* Make column schema entries on MySQL include an :extra entry for the Extra column in DESCRIBE output (bschmeck) (#1791)
|
|
192
|
+
|
|
193
|
+
* Update mock PostgreSQL adapter to default to PostgreSQL 14 instead of PostgreSQL 9.5 (jeremyevans)
|
|
194
|
+
|
|
195
|
+
* Support Dataset#with_recursive :search and :cycle options on PostgreSQL 14+ for result ordering and cycle detection (jeremyevans)
|
|
196
|
+
|
|
197
|
+
* Avoid method redefined verbose mode warnings in lazy_attributes plugin (jeremyevans)
|
|
198
|
+
|
|
199
|
+
=== 5.50.0 (2021-11-01)
|
|
200
|
+
|
|
201
|
+
* 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)
|
|
202
|
+
|
|
203
|
+
* Fix Model#freeze in composition, serialization, and serialization_modification_detection plugins to return self (jeremyevans) (#1788)
|
|
204
|
+
|
|
205
|
+
* Fix typecasting of lazy columns when using lazy_attributes plugin in model where dataset selects from subquery (jeremyevans)
|
|
206
|
+
|
|
207
|
+
* Add :before_preconnect Database option, for configuring extensions loaded via :preconnect_extensions (MarcPer, jeremyevans) (#1786)
|
|
208
|
+
|
|
209
|
+
* Change Dataset#columns! to use a LIMIT 0 query instead of a LIMIT 1 query (jeremyevans)
|
|
210
|
+
|
|
211
|
+
* Add sql_log_normalizer extension for normalizing logged SQL, helpful for analytics and sensitive data (jeremyevans)
|
|
212
|
+
|
|
213
|
+
* Add support for range_merge, multirange, and unnest, and PGMultiRange#op to pg_range_ops extension (jeremyevans)
|
|
214
|
+
|
|
215
|
+
* Add pg_multirange extension with support for PostgreSQL 14+ multirange types (jeremyevans)
|
|
216
|
+
|
|
217
|
+
=== 5.49.0 (2021-10-01)
|
|
218
|
+
|
|
219
|
+
* Switch block_given? usage to defined?(yield) (jeremyevans)
|
|
220
|
+
|
|
221
|
+
* Support table aliases for JOIN USING columns on PostgreSQL 14+ (jeremyevans)
|
|
222
|
+
|
|
223
|
+
* Support calling PostgreSQL procedures without arguments (jeremyevans)
|
|
224
|
+
|
|
225
|
+
* Support hstore subscripts in pg_hstore_ops on PostgreSQL 14+, for updating only part of an hstore value (jeremyevans)
|
|
226
|
+
|
|
227
|
+
* Support JSONB subscripts in pg_json_ops on PostgreSQL 14+, for updating only part of a JSONB value (jeremyevans)
|
|
228
|
+
|
|
229
|
+
* Support SQL::Expression#sequel_ast_transform for custom AST transforms on arbitrary expressions (jeremyevans)
|
|
230
|
+
|
|
231
|
+
* Add Database#create_trigger :replace option on PostgreSQL 14+ for CREATE OR REPLACE TRIGGER (jeremyevans)
|
|
232
|
+
|
|
233
|
+
* Make auto_validations plugin automatically setup no_null_byte validations (jeremyevans)
|
|
234
|
+
|
|
235
|
+
* Add Model#validates_no_null_byte to validation_helpers plugin (jeremyevans)
|
|
236
|
+
|
|
237
|
+
=== 5.48.0 (2021-09-01)
|
|
238
|
+
|
|
239
|
+
* Make the unused_associations plugin association reflection tracking work correctly when combining coverage runs (jeremyevans)
|
|
240
|
+
|
|
241
|
+
* Add Database#like_without_collate on MSSQL, to avoid using COLLATE on LIKE arguments, which can significantly improve performance (jeremyevans)
|
|
242
|
+
|
|
243
|
+
* Add Model::Errors#full_message private method for easiest i18n support for errors with multiple attributes (jeremyevans) (#1779)
|
|
244
|
+
|
|
245
|
+
=== 5.47.0 (2021-08-01)
|
|
246
|
+
|
|
247
|
+
* Make the unused_associations plugin track access to association reflections to determine whether associations are used (jeremyevans)
|
|
248
|
+
|
|
249
|
+
* Support :db option for join tables in {many,one}_through_many to use a separate query for each join table (jeremyevans)
|
|
250
|
+
|
|
251
|
+
* Support :join_table_db option for many_to_many/one_through_one associations, to use a separate query for the join table (jeremyevans)
|
|
252
|
+
|
|
253
|
+
* Support :allow_eager_graph and :allow_filtering_by association options (jeremyevans)
|
|
254
|
+
|
|
255
|
+
* Add Database#rename_tables on MySQL, for renaming multiple tables in a single call (nick96) (#1774)
|
|
256
|
+
|
|
257
|
+
* Support Dataset#returning on SQLite 3.35+ (jeremyevans)
|
|
258
|
+
|
|
259
|
+
=== 5.46.0 (2021-07-01)
|
|
260
|
+
|
|
261
|
+
* Add unused_associations plugin, for determining which associations and association methods are not used (jeremyevans)
|
|
262
|
+
|
|
263
|
+
* Make nil :setter/:adder/:remover/:clearer association options not create related methods (jeremyevans)
|
|
264
|
+
|
|
265
|
+
=== 5.45.0 (2021-06-01)
|
|
266
|
+
|
|
267
|
+
* Fix handling of NULL values in boolean columns in the ODBC adapter (jeremyevans) (#1765)
|
|
268
|
+
|
|
269
|
+
* Add auto_validations_constraint_validations_presence_message plugin for auto_validations/constraint_validations presence message integration (jeremyevans)
|
|
270
|
+
|
|
271
|
+
* Support Dataset#with :materialized option on SQLite 3.35+ for [NOT] MATERIALIZED (jeremyevans)
|
|
272
|
+
|
|
273
|
+
* Use ALTER TABLE DROP COLUMN for dropping columns on SQLite 3.35+ (jeremyevans)
|
|
274
|
+
|
|
275
|
+
=== 5.44.0 (2021-05-01)
|
|
276
|
+
|
|
277
|
+
* Add concurrent_eager_loading plugin, for eager loading multiple associations concurrently using separate threads (jeremyevans)
|
|
278
|
+
|
|
279
|
+
* Support :weeks as a interval unit in the date_arithmetic extension (jeremyevans) (#1759)
|
|
280
|
+
|
|
281
|
+
* Raise an exception if an interval hash with an unsupported key is passed in the date_arithmetic extension (jeremyevans) (#1759)
|
|
282
|
+
|
|
283
|
+
* Support dropping non-composite unique constraints on SQLite (jeremyevans) (#1755)
|
|
284
|
+
|
|
285
|
+
=== 5.43.0 (2021-04-01)
|
|
286
|
+
|
|
287
|
+
* Add column_encryption plugin, for encrypting column values (jeremyevans)
|
|
288
|
+
|
|
289
|
+
=== 5.42.0 (2021-03-01)
|
|
290
|
+
|
|
291
|
+
* Make the ado timestamp conversion proc a normal conversion proc that can be overridden similar to other conversion procs (jeremyevans)
|
|
292
|
+
|
|
293
|
+
* Add :reject_nil option to the nested_attributes method, to ignore calls where nil is passed as the associated object data (jeremyevans)
|
|
294
|
+
|
|
295
|
+
* Add async_thread_pool plugin for easier async usage with model classes and support for async destroy, with_pk, and with_pk! methods (jeremyevans)
|
|
296
|
+
|
|
297
|
+
* Add async_thread_pool Database extension for executing queries asynchronously using a thread pool (jeremyevans)
|
|
298
|
+
|
|
299
|
+
* Fix possible thread safety issue in Database#extension that could allow Module#extended to be called twice with the same Database instance (jeremyevans)
|
|
300
|
+
|
|
301
|
+
* Support cases where validations make modifications beyond setting errors in Model#freeze (jeremyevans)
|
|
302
|
+
|
|
303
|
+
* Add Model#to_json_data to the json_serializer plugin, returning a JSON data structure (jeremyevans)
|
|
304
|
+
|
|
305
|
+
=== 5.41.0 (2021-02-01)
|
|
306
|
+
|
|
307
|
+
* Have explicit :text option for a String column take priority over :size option on PostgreSQL (jeremyevans) (#1750)
|
|
308
|
+
|
|
309
|
+
* Support a :skip_invalid option in auto_validations plugin for not adding errors to a column that already has an error (jeremyevans)
|
|
310
|
+
|
|
311
|
+
* Support a :skip_invalid option in validation_helpers for not adding an error to a column that already has an error (jeremyevans)
|
|
312
|
+
|
|
313
|
+
* Support :adder, :remover, and :clearer association options that use keyword arguments in Ruby 2.7+ (jeremyevans)
|
|
314
|
+
|
|
315
|
+
* Make pg_interval use the same number of seconds per year and per month as ActiveSupport::Duration when using ActiveSupport 5.1+ (jeremyevans)
|
|
316
|
+
|
|
317
|
+
=== 5.40.0 (2021-01-01)
|
|
318
|
+
|
|
319
|
+
* Support UPDATE FROM syntax in SQLite 3.33.0+ (jeremyevans)
|
|
320
|
+
|
|
321
|
+
* Have pg_interval extension work with ActiveSupport 6.1 (jeremyevans)
|
|
322
|
+
|
|
323
|
+
* Have date_arithmetic extension work with ActiveSupport 6.1 (jeremyevans)
|
|
324
|
+
|
|
325
|
+
* Avoid method redefinition warnings in verbose warning mode (jeremyevans)
|
|
326
|
+
|
|
1
327
|
=== 5.39.0 (2020-12-01)
|
|
2
328
|
|
|
3
329
|
* 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-
|
|
2
|
+
Copyright (c) 2008-2023 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 ::
|
|
21
|
-
RDoc Documentation ::
|
|
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) ::
|
|
24
|
-
Discussion Forum (
|
|
25
|
-
|
|
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
|
|
28
|
-
sequel-talk Google Group
|
|
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(:
|
|
59
|
-
items.insert(:
|
|
60
|
-
items.insert(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
414
|
+
posts.where(Sequel[:stamp] < Date.today - 7).update(state: 'archived')
|
|
414
415
|
# NOT THIS:
|
|
415
|
-
posts.update(:
|
|
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(:
|
|
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(:
|
|
464
|
+
posts.insert(category: 'ruby', author: 'david')
|
|
439
465
|
# INSERT
|
|
440
|
-
if posts.where('stamp < ?', Date.today - 7).update(:
|
|
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(:
|
|
684
|
-
Post.where(:
|
|
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, :
|
|
723
|
+
one_to_one :first_comment, class: :Comment, order: :id
|
|
698
724
|
many_to_many :tags
|
|
699
|
-
one_through_one :first_tag, :
|
|
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, :
|
|
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
|
-
|
|
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], :
|
|
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(:
|
|
242
|
-
album2 = Album.create(:
|
|
243
|
-
album3 = Album.create(:
|
|
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(:
|
|
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(:
|
|
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, :
|
|
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(:
|
|
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, :
|
|
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(:
|
|
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(:
|
|
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, :
|
|
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(:
|
|
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).
|