sequel 5.45.0 → 5.77.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 +434 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +59 -27
- data/bin/sequel +11 -3
- data/doc/advanced_associations.rdoc +16 -14
- data/doc/association_basics.rdoc +119 -24
- data/doc/cheat_sheet.rdoc +11 -3
- data/doc/mass_assignment.rdoc +1 -1
- data/doc/migration.rdoc +27 -6
- data/doc/model_hooks.rdoc +1 -1
- data/doc/object_model.rdoc +8 -8
- data/doc/opening_databases.rdoc +28 -12
- data/doc/postgresql.rdoc +16 -8
- data/doc/querying.rdoc +5 -3
- 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/release_notes/5.66.0.txt +24 -0
- data/doc/release_notes/5.67.0.txt +32 -0
- data/doc/release_notes/5.68.0.txt +61 -0
- data/doc/release_notes/5.69.0.txt +26 -0
- data/doc/release_notes/5.70.0.txt +35 -0
- data/doc/release_notes/5.71.0.txt +21 -0
- data/doc/release_notes/5.72.0.txt +33 -0
- data/doc/release_notes/5.73.0.txt +66 -0
- data/doc/release_notes/5.74.0.txt +45 -0
- data/doc/release_notes/5.75.0.txt +35 -0
- data/doc/release_notes/5.76.0.txt +86 -0
- data/doc/release_notes/5.77.0.txt +63 -0
- data/doc/schema_modification.rdoc +1 -1
- data/doc/security.rdoc +9 -9
- data/doc/sharding.rdoc +3 -1
- data/doc/sql.rdoc +27 -15
- data/doc/testing.rdoc +23 -13
- data/doc/transactions.rdoc +6 -6
- data/doc/virtual_rows.rdoc +1 -1
- data/lib/sequel/adapters/ado/access.rb +1 -1
- data/lib/sequel/adapters/ado.rb +1 -1
- data/lib/sequel/adapters/amalgalite.rb +3 -5
- data/lib/sequel/adapters/ibmdb.rb +3 -3
- data/lib/sequel/adapters/jdbc/derby.rb +8 -0
- data/lib/sequel/adapters/jdbc/h2.rb +63 -10
- data/lib/sequel/adapters/jdbc/hsqldb.rb +8 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +7 -4
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +15 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +4 -0
- data/lib/sequel/adapters/jdbc.rb +24 -22
- data/lib/sequel/adapters/mysql.rb +92 -67
- data/lib/sequel/adapters/mysql2.rb +56 -51
- data/lib/sequel/adapters/odbc/mssql.rb +1 -1
- data/lib/sequel/adapters/odbc.rb +1 -1
- data/lib/sequel/adapters/oracle.rb +4 -3
- data/lib/sequel/adapters/postgres.rb +89 -45
- data/lib/sequel/adapters/shared/access.rb +11 -1
- data/lib/sequel/adapters/shared/db2.rb +42 -0
- data/lib/sequel/adapters/shared/mssql.rb +91 -10
- data/lib/sequel/adapters/shared/mysql.rb +78 -3
- data/lib/sequel/adapters/shared/oracle.rb +86 -7
- data/lib/sequel/adapters/shared/postgres.rb +576 -171
- data/lib/sequel/adapters/shared/sqlanywhere.rb +21 -5
- data/lib/sequel/adapters/shared/sqlite.rb +92 -8
- data/lib/sequel/adapters/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/sqlite.rb +99 -18
- data/lib/sequel/adapters/tinytds.rb +1 -1
- data/lib/sequel/adapters/trilogy.rb +117 -0
- 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 +16 -11
- data/lib/sequel/connection_pool/sharded_timed_queue.rb +374 -0
- data/lib/sequel/connection_pool/single.rb +6 -8
- data/lib/sequel/connection_pool/threaded.rb +14 -8
- data/lib/sequel/connection_pool/timed_queue.rb +270 -0
- data/lib/sequel/connection_pool.rb +57 -31
- data/lib/sequel/core.rb +17 -18
- data/lib/sequel/database/connecting.rb +27 -3
- data/lib/sequel/database/dataset.rb +16 -6
- data/lib/sequel/database/misc.rb +70 -14
- data/lib/sequel/database/query.rb +73 -2
- data/lib/sequel/database/schema_generator.rb +11 -6
- data/lib/sequel/database/schema_methods.rb +23 -4
- data/lib/sequel/database/transactions.rb +6 -0
- data/lib/sequel/dataset/actions.rb +111 -15
- data/lib/sequel/dataset/deprecated_singleton_class_methods.rb +42 -0
- data/lib/sequel/dataset/features.rb +20 -1
- data/lib/sequel/dataset/misc.rb +12 -2
- data/lib/sequel/dataset/placeholder_literalizer.rb +20 -9
- data/lib/sequel/dataset/query.rb +170 -41
- data/lib/sequel/dataset/sql.rb +190 -71
- data/lib/sequel/dataset.rb +4 -0
- 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 +2 -2
- data/lib/sequel/extensions/async_thread_pool.rb +14 -13
- data/lib/sequel/extensions/auto_cast_date_and_time.rb +94 -0
- data/lib/sequel/extensions/auto_literal_strings.rb +1 -1
- data/lib/sequel/extensions/connection_expiration.rb +15 -9
- data/lib/sequel/extensions/connection_validator.rb +16 -11
- 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 +36 -8
- 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 +11 -10
- data/lib/sequel/extensions/index_caching.rb +5 -1
- data/lib/sequel/extensions/inflector.rb +1 -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 +57 -15
- data/lib/sequel/extensions/named_timezones.rb +22 -6
- data/lib/sequel/extensions/pagination.rb +1 -1
- data/lib/sequel/extensions/pg_array.rb +33 -4
- 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_auto_parameterize_in_array.rb +110 -0
- data/lib/sequel/extensions/pg_enum.rb +1 -2
- data/lib/sequel/extensions/pg_extended_date_support.rb +39 -28
- 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 +11 -11
- data/lib/sequel/extensions/pg_json.rb +13 -15
- data/lib/sequel/extensions/pg_json_ops.rb +125 -2
- data/lib/sequel/extensions/pg_multirange.rb +367 -0
- data/lib/sequel/extensions/pg_range.rb +13 -26
- data/lib/sequel/extensions/pg_range_ops.rb +37 -9
- data/lib/sequel/extensions/pg_row.rb +20 -19
- data/lib/sequel/extensions/pg_row_ops.rb +1 -1
- data/lib/sequel/extensions/pg_timestamptz.rb +27 -3
- data/lib/sequel/extensions/round_timestamps.rb +1 -1
- data/lib/sequel/extensions/s.rb +2 -1
- data/lib/sequel/extensions/schema_caching.rb +1 -1
- data/lib/sequel/extensions/schema_dumper.rb +45 -11
- data/lib/sequel/extensions/server_block.rb +10 -13
- data/lib/sequel/extensions/set_literalizer.rb +58 -0
- 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/extensions/transaction_connection_validator.rb +78 -0
- data/lib/sequel/model/associations.rb +286 -92
- data/lib/sequel/model/base.rb +53 -33
- data/lib/sequel/model/dataset_module.rb +3 -0
- data/lib/sequel/model/errors.rb +10 -1
- data/lib/sequel/model/exceptions.rb +15 -3
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/plugins/auto_restrict_eager_graph.rb +62 -0
- data/lib/sequel/plugins/auto_validations.rb +74 -16
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
- data/lib/sequel/plugins/column_encryption.rb +29 -8
- data/lib/sequel/plugins/composition.rb +3 -2
- data/lib/sequel/plugins/concurrent_eager_loading.rb +4 -4
- data/lib/sequel/plugins/constraint_validations.rb +8 -5
- data/lib/sequel/plugins/defaults_setter.rb +16 -0
- 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 +2 -2
- data/lib/sequel/plugins/lazy_attributes.rb +3 -0
- data/lib/sequel/plugins/list.rb +8 -3
- data/lib/sequel/plugins/many_through_many.rb +109 -10
- data/lib/sequel/plugins/mssql_optimistic_locking.rb +8 -38
- data/lib/sequel/plugins/nested_attributes.rb +4 -4
- data/lib/sequel/plugins/optimistic_locking.rb +9 -42
- data/lib/sequel/plugins/optimistic_locking_base.rb +55 -0
- data/lib/sequel/plugins/paged_operations.rb +181 -0
- data/lib/sequel/plugins/pg_array_associations.rb +46 -34
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +9 -3
- data/lib/sequel/plugins/pg_xmin_optimistic_locking.rb +109 -0
- data/lib/sequel/plugins/prepared_statements.rb +12 -2
- data/lib/sequel/plugins/prepared_statements_safe.rb +2 -1
- data/lib/sequel/plugins/primary_key_lookup_check_values.rb +154 -0
- data/lib/sequel/plugins/rcte_tree.rb +7 -4
- data/lib/sequel/plugins/require_valid_schema.rb +67 -0
- data/lib/sequel/plugins/serialization.rb +1 -0
- data/lib/sequel/plugins/serialization_modification_detection.rb +1 -0
- 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 +39 -1
- data/lib/sequel/plugins/static_cache_cache.rb +5 -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 +41 -11
- data/lib/sequel/plugins/validation_helpers_generic_type_messages.rb +73 -0
- 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 +109 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9951772dd3785c8ce91090bd31034a1e57ac5dcbc17af774b980a115cea15347
|
4
|
+
data.tar.gz: 3cfcaefaf6aa4758ef2cfaf78cbe6ccdc688e8b3836718bd63c42c5bdb220026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0885577c11fd7285a5278d0a1b52ae411e557cec7bce2f3a49f8128a0be63928ebfa55b2b1a86c8b28ee1c3782c1dc5ebf5d4ecf00f0194ad33da89cb6ffc12a'
|
7
|
+
data.tar.gz: ccc7b8b6c68049ee1fed2211a3d193157ee36fde9c340324eba2a8cebd8925bc97b4dc1777b61f8a2fb94d83439c41f33afb832c080f4d54bab16d09924a4fe2
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,437 @@
|
|
1
|
+
=== 5.77.0 (2024-02-01)
|
2
|
+
|
3
|
+
* Support create_table :without_rowid option on SQLite (loranger32) (#2126)
|
4
|
+
|
5
|
+
* Warn by default if trying to eager_graph/association_join an association that uses a block, when the block would be ignored (jeremyevans)
|
6
|
+
|
7
|
+
* Speed up validates_unique in validation_helpers plugin by using empty? instead of count == 0 (numbata) (#2122)
|
8
|
+
|
9
|
+
* Speed up regexp matches in sqlite adapter on Ruby 2.4+ (jeremyevans)
|
10
|
+
|
11
|
+
* Add sqlite adapter :regexp_function_cache option for specifying the cache object to use (paddor, jeremyevans) (#2116)
|
12
|
+
|
13
|
+
* Respect list plugin :top option when inserting the first row into the model's table (johanmagnusson) (#2115)
|
14
|
+
|
15
|
+
* Switch default connection pool to timed_queue on Ruby 3.4+ (jeremyevans)
|
16
|
+
|
17
|
+
* Support on_duplicate_columns={raise,warn} parameter in connection URL when using duplicate_columns_handler extension (jeremyevans)
|
18
|
+
|
19
|
+
* Add transaction_connection_validator extension for retrying transactions on new connection if ther is a disconnect error when starting transaction (jeremyevans)
|
20
|
+
|
21
|
+
=== 5.76.0 (2024-01-01)
|
22
|
+
|
23
|
+
* Improve performance and flexibility of regexp matching in sqlite adapter (paddor) (#2108)
|
24
|
+
|
25
|
+
* Support SQL::Identifier for Database#tables :schema option values on PostgreSQL (jeremyevans)
|
26
|
+
|
27
|
+
* Support generating rcte queries using UNION or UNION ALL in the rcte plugin (jonathanfrias) (#2107)
|
28
|
+
|
29
|
+
* Make Database#table_exists? on PostgreSQL handle lock or statement timeout errors as evidence the table exists (jeremyevans) (#2106)
|
30
|
+
|
31
|
+
* Work around DateTime.jd fractional second bug on JRuby in named_timezones extension (jeremyevans)
|
32
|
+
|
33
|
+
* Support fractional times and timestamps on SQLAnywhere (jeremyevans)
|
34
|
+
|
35
|
+
* Make round_timestamps extension use Dataset#sqltime_precision for rounding Sequel::SQLTime values (jeremyevans)
|
36
|
+
|
37
|
+
* Remove special handling of %N modifier in Dataset#default_timestamp_format (jeremyevans)
|
38
|
+
|
39
|
+
* Add Dataset#default_time_format private method, for adapters to override for time (not timestamp) formatting (jeremyevans)
|
40
|
+
|
41
|
+
* Remove Dataset#format_timestamp_offset private method (jeremyevans)
|
42
|
+
|
43
|
+
* Remove special handling of %z modifier in Dataset#default_timestamp_format (jeremyevans)
|
44
|
+
|
45
|
+
* Add Dataset#literal_date_or_time, for simpler use by bound argument code (jeremyevans)
|
46
|
+
|
47
|
+
* Add auto_cast_date_and_time extension, for casting date and time values using SQL standard functions (jeremyevans)
|
48
|
+
|
49
|
+
=== 5.75.0 (2023-12-01)
|
50
|
+
|
51
|
+
* Make any_not_empty? extension support passing pattern argument to any? (jeremyevans) (#2100)
|
52
|
+
|
53
|
+
* Respect :skip_transaction option in PostgreSQL Dataset#paged_each (jeremyevans) (#2097)
|
54
|
+
|
55
|
+
* Add TimestampMigrator.run_single to run a single migration file up or down (opya, jeremyevans) (#2093)
|
56
|
+
|
57
|
+
* Support INSERT RETURNING on MariaDB 10.5+, and use it when saving new model objects (jeremyevans)
|
58
|
+
|
59
|
+
* Add Database#{defer,immediate}_constraints on PostgreSQL for changing handling of deferrable constraints in a transaction (jeremyevans)
|
60
|
+
|
61
|
+
=== 5.74.0 (2023-11-01)
|
62
|
+
|
63
|
+
* Make generated columns show up in Database#schema when using SQLite 3.37+ (jeremyevans) (#2087)
|
64
|
+
|
65
|
+
* Add revert method for Sequel.migration blocks, to revert changes inside the block on up, and apply the changes on down (jeremyevans)
|
66
|
+
|
67
|
+
* Re-add is_json and is_not_json methods to the pg_json_ops extension, as the support was re-added in PostgreSQL 16 (jeremyevans)
|
68
|
+
|
69
|
+
* Avoid infinite loop when handling exceptions with a cause loop in jdbc adapter (jeremyevans)
|
70
|
+
|
71
|
+
=== 5.73.0 (2023-10-01)
|
72
|
+
|
73
|
+
* Handle disconnect errors in ibmdb and jdbc/db2 adapters (jeremyevans) (#2083)
|
74
|
+
|
75
|
+
* Support skipping transactions in Dataset#{import,paged_each} using :skip_transaction option (jeremyevans)
|
76
|
+
|
77
|
+
* Add Database#transaction :skip_transaction option to skip creating a transaction or savepoint (jeremyevans)
|
78
|
+
|
79
|
+
* Stop using a transaction for a single query if calling Dataset#import with a dataset (jeremyevans)
|
80
|
+
|
81
|
+
* Add paged_operations plugin for paged deletes and updates and other custom operations (jeremyevans) (#2080)
|
82
|
+
|
83
|
+
* Support to_tsquery: :websearch option to Dataset#full_text_search on PostgreSQL 11+ (jeremyevans) (#2075)
|
84
|
+
|
85
|
+
* Add MassAssignmentRestriction#model and #column for getting the model instance and related column for mass assignment errors (artofhuman, jeremyevans) (#2079)
|
86
|
+
|
87
|
+
* Stop using base64 library in column_encryption plugin (jeremyevans)
|
88
|
+
|
89
|
+
=== 5.72.0 (2023-09-01)
|
90
|
+
|
91
|
+
* Sort caches before marshalling when using schema_caching, index_caching, static_cache_cache, and pg_auto_constraint_validations (jeremyevans)
|
92
|
+
|
93
|
+
* Change the defaults_setter plugin do a deep-copy of database default hash/array values and delegates (jeremyevans) (#2069)
|
94
|
+
|
95
|
+
* Add pg_auto_parameterize_in_array extension, for converting IN/NOT IN to = ANY or != ALL for more types (jeremyevans)
|
96
|
+
|
97
|
+
* Fix literalization of infinite and NaN float values in PostgreSQL array bound variables (jeremyevans)
|
98
|
+
|
99
|
+
=== 5.71.0 (2023-08-01)
|
100
|
+
|
101
|
+
* Support ILIKE ANY on PostgreSQL by not forcing the use of ESCAPE for ILIKE (gilesbowkett) (#2066)
|
102
|
+
|
103
|
+
* Add pg_xmin_optimistic_locking plugin for optimistic locking for all models without database changes (jeremyevans)
|
104
|
+
|
105
|
+
* Recognize the xid PostgreSQL type as an integer type in the jdbc/postgresql adapter (jeremyevans)
|
106
|
+
|
107
|
+
* Make set_column_allow_null method reversible in migrations (enescakir) (#2060)
|
108
|
+
|
109
|
+
=== 5.70.0 (2023-07-01)
|
110
|
+
|
111
|
+
* Make static_cache plugin better handle cases where forbid_lazy_load plugin is already loaded (jeremyevans)
|
112
|
+
|
113
|
+
* Fix ShardedThreadedConnectionPool#remove_server to disconnect all connections if removing multiple servers (jeremyevans)
|
114
|
+
|
115
|
+
* Support SEQUEL_DEFAULT_CONNECTION_POOL environment variable for choosing connection pool when :pool_class Database option is not set (jeremyevans)
|
116
|
+
|
117
|
+
* Add sharded_timed_queue connection pool (jeremyevans)
|
118
|
+
|
119
|
+
* Make connection_{validator,expiration} and async_thread_pool extensions work with timed_queue connection pool (jeremyevans)
|
120
|
+
|
121
|
+
* Make connection_{validator,expiration} extensions raise error when used with single threaded pools (HoneyryderChuck, jeremyevans) (#2049)
|
122
|
+
|
123
|
+
* Workaround possible resource starvation in threaded connection pool (ioquatix) (#2048)
|
124
|
+
|
125
|
+
=== 5.69.0 (2023-06-01)
|
126
|
+
|
127
|
+
* Avoid unsupported flag warning when using the mysql adapter with ruby-mysql 3+ (jeremyevans)
|
128
|
+
|
129
|
+
* Make mysql adapter work with ruby-mysql 4+ (jeremyevans)
|
130
|
+
|
131
|
+
* Add Model::DatasetModule#model accessor (davekaro) (#2040)
|
132
|
+
|
133
|
+
* Add trilogy adapter (jeremyevans)
|
134
|
+
|
135
|
+
=== 5.68.0 (2023-05-01)
|
136
|
+
|
137
|
+
* Add validation_helpers_generic_type_messages plugin for more useful type validation failure messages (jeremyevans) (#2028)
|
138
|
+
|
139
|
+
* Make constraint_validations plugin not validate missing columns that have a default value (jeremyevans) (#2023)
|
140
|
+
|
141
|
+
* Skip normal type name parsing for enum/array/composite/range/multirange types on PostgreSQL (jeremyevans) (#2019)
|
142
|
+
|
143
|
+
* Fix corner case where pg_extended_date_support did not work correctly when using the jdbc/postgresql adapter (jeremyevans)
|
144
|
+
|
145
|
+
* Include :min_value and :max_value schema entries for date/timestamp/timestamptz columns on PostgreSQL 9.6+ (jeremyevans)
|
146
|
+
|
147
|
+
=== 5.67.0 (2023-04-01)
|
148
|
+
|
149
|
+
* Fix dumping of string column sizes in the schema dumper on MSSQL (jeremyevans) (#2013)
|
150
|
+
|
151
|
+
* Improve dumping of tables in non-default schemas in the schema_dumper extension (jeremyevans) (#2006)
|
152
|
+
|
153
|
+
* Make Database#{tables,views} support :qualify option on Microsoft SQL Server (jeremyevans)
|
154
|
+
|
155
|
+
* Avoid use of singleton classes for datasets instances on Ruby 2.4+ (jeremyevans) (#2007)
|
156
|
+
|
157
|
+
* Deprecate registering datasets extensions using an object other than a module (jeremyevans)
|
158
|
+
|
159
|
+
* Add set_literalizer extension, for treating set usage in datasets similar to array usage (jeremyevans) (#1997)
|
160
|
+
|
161
|
+
=== 5.66.0 (2023-03-01)
|
162
|
+
|
163
|
+
* Recognize SQLite error related to strict tables as a constraint violation when using the amalgalite adapter (jeremyevans)
|
164
|
+
|
165
|
+
* Make Dataset#count work correctly for datasets using Dataset#values (jeremyevans) (#1992)
|
166
|
+
|
167
|
+
* Make Dataset#count with no argument/block handle dataset with custom SQL using ORDER BY on MSSQL (jeremyevans)
|
168
|
+
|
169
|
+
* Make Dataset#empty? correctly handle datasets with custom SQL or using Dataset#values where the first value is NULL (andy-k, jeremyevans) (#1990)
|
170
|
+
|
171
|
+
=== 5.65.0 (2023-02-01)
|
172
|
+
|
173
|
+
* Allow pg_auto_parameterize extension to use placeholder loaders (jeremyevans)
|
174
|
+
|
175
|
+
* Do not include :min_value and :max_value schema entries for decimal/numeric columns on MySQL versions not supporting check constraints (jeremyevans)
|
176
|
+
|
177
|
+
* Make Database#indexes return indexes for partitioned tables on PostgreSQL 11+ (jeremyevans)
|
178
|
+
|
179
|
+
=== 5.64.0 (2023-01-01)
|
180
|
+
|
181
|
+
* Make :db_type column schema entries on SQLAnywhere include precision/scale information (jeremyevans)
|
182
|
+
|
183
|
+
* Include :min_value and :max_value schema entries for decimal/numeric columns on most databases (rolftimmermans, jeremyevans) (#1975)
|
184
|
+
|
185
|
+
* Support :graph_use_association_block association option to make eager_graph use the association block (jeremyevans)
|
186
|
+
|
187
|
+
* Make many_through_many and many_through_one associations support eager_graph callbacks (jeremyevans)
|
188
|
+
|
189
|
+
=== 5.63.0 (2022-12-01)
|
190
|
+
|
191
|
+
* Make validates_associated plugin avoid database type errors for non-integer association keys (jeremyevans) (#1968)
|
192
|
+
|
193
|
+
* Make tactical_eager_loading plugin work better with table inheritance plugins (rolftimmermans, jeremyevans) (#1962)
|
194
|
+
|
195
|
+
* Add support for pool_class: :timed_queue on Ruby 3.2+, using a Queue for available connections (jeremyevans)
|
196
|
+
|
197
|
+
* Allow :pool_class Database option to be specified as a string to more easily choose a different pool type (jeremyevans)
|
198
|
+
|
199
|
+
* Use compare_by_identity hashes for Thread-keyed hashes in threaded connection pools (jeremyevans)
|
200
|
+
|
201
|
+
* Skip use of JRuby workaround on JRuby 9.3.9.0+ in named_timezones extension as JRuby fixed the related bug (jeremyevans)
|
202
|
+
|
203
|
+
=== 5.62.0 (2022-11-01)
|
204
|
+
|
205
|
+
* Add back the pg_auto_parameterize extension for automatically using bound variables when using postgres adapter with pg driver (jeremyevans)
|
206
|
+
|
207
|
+
* Add pg_extended_integer_support extension for customizing behavior when literalizing a Ruby integer outside PostgreSQL bigint range (jeremyevans)
|
208
|
+
|
209
|
+
* Raise Postgres::IntegerOutsideBigintRange if attempting to literalize a Ruby integer outside PostgreSQL bigint range (jeremyevans)
|
210
|
+
|
211
|
+
* Add primary_key_lookup_check_values plugin for typecasting and checking primary key values during lookup (jeremyevans)
|
212
|
+
|
213
|
+
* Setup validation of minimum and maximum values for integer columns in auto_validations (jeremyevans)
|
214
|
+
|
215
|
+
* Add validates_max_value and validates_min_value to validation_helpers (jeremyevans)
|
216
|
+
|
217
|
+
* Include :min_value and :max_value schema entries for integer columns on most databases (jeremyevans)
|
218
|
+
|
219
|
+
* Don't wrap multi-inserts in a transaction when it's not required (shannoncole, jeremyevans) (#1945)
|
220
|
+
|
221
|
+
* Update mock PostgreSQL adapter to default to PostgreSQL 15 instead of PostgreSQL 14 (jeremyevans)
|
222
|
+
|
223
|
+
* Support fractional seconds in the named_timezones extension (jeremyevans) (#1943)
|
224
|
+
|
225
|
+
* Cache reflection datasets in the postgres adapter to improve performance (jeremyevans)
|
226
|
+
|
227
|
+
* Handle BC dates and timestamps in bound variables when using the pg_extended_date_support extension (jeremyevans)
|
228
|
+
|
229
|
+
* Correctly format hstore[] types in bound variables on PostgreSQL (jeremyevans)
|
230
|
+
|
231
|
+
* Fix corner case in eager loading where window function eager limit strategy is used, but row number entry is not removed (jeremyevans)
|
232
|
+
|
233
|
+
* Support server/shard specific :after_connect and :connect_sqls Database options (jeremyevans) (#1935)
|
234
|
+
|
235
|
+
=== 5.61.0 (2022-10-01)
|
236
|
+
|
237
|
+
* Make Database#foreign_key_list on PostgreSQL return results for partitioned tables (jeremyevans)
|
238
|
+
|
239
|
+
* Add Database#check_string_typecast_bytesize for checking bytesize of strings before typecasting (jeremyevans)
|
240
|
+
|
241
|
+
* Treat negative hexidecimal strings similar to positive hexidecimal strings when typecasting to integer (jeremyevans)
|
242
|
+
|
243
|
+
* 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)
|
244
|
+
|
245
|
+
* Fix handling of timestamps before the date of calendar reform when using pg_extended_date_support extension on Ruby 3.2 (jeremyevans)
|
246
|
+
|
247
|
+
=== 5.60.1 (2022-09-02)
|
248
|
+
|
249
|
+
* Revert conversion of respond_to? to defined?, as it breaks with unused refinements on Ruby 2 (jeremyevans) (#1919)
|
250
|
+
|
251
|
+
=== 5.60.0 (2022-09-01)
|
252
|
+
|
253
|
+
* Support arbitrary expressions for date_arithmetic interval values on PostgreSQL 9.4+ (jeremyevans)
|
254
|
+
|
255
|
+
* Support native IS DISTINCT FROM on SQLite 3.39+ instead of emulating support in the is_distinct_from extension (jeremyevans)
|
256
|
+
|
257
|
+
* Support HAVING without GROUP BY on SQLite 3.39+ (jeremyevans)
|
258
|
+
|
259
|
+
* Convert most respond_to? calls to equivalent defined? for better performance (jeremyevans)
|
260
|
+
|
261
|
+
=== 5.59.0 (2022-08-01)
|
262
|
+
|
263
|
+
* Set :allow_eager association option to false for instance specific associations without eager loaders (jeremyevans)
|
264
|
+
|
265
|
+
* Add require_valid_schema plugin for checking that model classes have schema parsed as expected (jeremyevans)
|
266
|
+
|
267
|
+
* Model classes created from aliased expressions and literal strings no longer use the simple table optimization (jeremyevans)
|
268
|
+
|
269
|
+
* Model code that does not swallow connection errors will now also not swallow disconnect errors (jeremyevans) (#1892)
|
270
|
+
|
271
|
+
* Add is_json and is_not_json methods to the pg_json_ops extension, for the PostgreSQL 15+ IS [NOT] JSON operator (jeremyevans)
|
272
|
+
|
273
|
+
* Support :security_invoker view option on PostgreSQL 15+, for views where access uses permissions of user instead of owner (jeremyevans)
|
274
|
+
|
275
|
+
* Support :nulls_distinct index option on PostgreSQL 15+, for NULLS [NOT] DISTINCT (jeremyevans)
|
276
|
+
|
277
|
+
* Support sequel-postgres-pr driver in the postgres adapter (jeremyevans)
|
278
|
+
|
279
|
+
=== 5.58.0 (2022-07-01)
|
280
|
+
|
281
|
+
* Support :disable_split_materialized Database option on MySQL to work around optimizer bug in MariaDB 10.5+ affecting association tests (jeremyevans)
|
282
|
+
|
283
|
+
* Add Dataset#merge* methods to support MERGE statement on PostgreSQL 15+, MSSQL, Oracle, DB2, H2, HSQLDB, and Derby (jeremyevans)
|
284
|
+
|
285
|
+
=== 5.57.0 (2022-06-01)
|
286
|
+
|
287
|
+
* Make Database#create_function on PostgreSQL accept :parallel option (bananarne) (#1870)
|
288
|
+
|
289
|
+
* Add support for :on_update_current_timestamp column option on MySQL (jeremyevans)
|
290
|
+
|
291
|
+
* Add is_distinct_from extension with support for the IS DISTINCT FROM operator (jeremyevans)
|
292
|
+
|
293
|
+
=== 5.56.0 (2022-05-01)
|
294
|
+
|
295
|
+
* Make alter_table add_column/add_foreign_key methods support :index option to create an index on the column (jeremyevans)
|
296
|
+
|
297
|
+
* Support creation of STRICT tables on SQLite 3.37.0+ via create_table :strict option (jeremyevans)
|
298
|
+
|
299
|
+
* Add sqlite_json_ops extension for DSL support for JSON functions and operators added in SQLite 3.38.0 (jeremyevans)
|
300
|
+
|
301
|
+
* Recognize "INTEGER" type same as "integer" type in the schema dumper, helpful on SQLite 3.37.0+ (jeremyevans)
|
302
|
+
|
303
|
+
=== 5.55.0 (2022-04-01)
|
304
|
+
|
305
|
+
* Support :setup_regexp_function Database option in the sqlite adapter to allow the use of regexps when querying (jeremyevans)
|
306
|
+
|
307
|
+
* Add auto_restrict_eager_graph plugin for automatically disallow eager_graph with associations needing but lacking graph options (jeremyevans)
|
308
|
+
|
309
|
+
* Fix placeholder literalizer optimization for dataset aggregate methods on a model dataset (belousovAV) (#1847, #1848)
|
310
|
+
|
311
|
+
=== 5.54.0 (2022-03-01)
|
312
|
+
|
313
|
+
* Add enum plugin for treating columns as enums in a model (jeremyevans) (#1839)
|
314
|
+
|
315
|
+
=== 5.53.0 (2022-02-01)
|
316
|
+
|
317
|
+
* Make Dataset#_sql_comment private when using the Database sql_comments extension (jeremyevans)
|
318
|
+
|
319
|
+
* Fix prepared statements in the mysql2 adapter to reuse native prepared statements (jeremyevans) (#1832)
|
320
|
+
|
321
|
+
* Support H2 version 2+ in the jdbc/h2 adapter (jeremyevans) (#1817)
|
322
|
+
|
323
|
+
* Work around active_support breaking subclasses plugin on Ruby <3.1 (jeremyevans) (#1816)
|
324
|
+
|
325
|
+
* Fix error handling if trying to setup column_encryption plugin without keys (jeremyevans) (#1815)
|
326
|
+
|
327
|
+
=== 5.52.0 (2022-01-01)
|
328
|
+
|
329
|
+
* Use Class#subclasses if available in the subclasses plugin, instead of a custom Model.subclasses accessor (jeremyevans)
|
330
|
+
|
331
|
+
* Add Model.descendants and .freeze_descendants to subclasses plugin (jeremyevans)
|
332
|
+
|
333
|
+
* Avoid use of deprecated Refinement#include on Ruby 3.1+ (jeremyevans)
|
334
|
+
|
335
|
+
* Add date_parse_input_handler extension for custom handling of input to date parsing methods (jeremyevans)
|
336
|
+
|
337
|
+
* Make postgres adapter respect Database#default_string_column_size (jeremyevans)
|
338
|
+
|
339
|
+
* Make pg_interval extension work with ActiveSupport 7.0 (jeremyevans)
|
340
|
+
|
341
|
+
* Make :ruby_default schema entry for type: :datetime respect Sequel.datetime_class (jeremyevans)
|
342
|
+
|
343
|
+
* Make alter_table drop_constraint have an effect on MySQL 8.0.19+ (jeremyevans)
|
344
|
+
|
345
|
+
* Make mysql adapter support ruby-mysql 3 API (jeremyevans) (#1795)
|
346
|
+
|
347
|
+
* Make mysql adapter no longer use connection's server_version, since it isn't accurate when using the ruby-mysql driver (jeremyevans)
|
348
|
+
|
349
|
+
* Add sql_comments plugin for automatically including comments on queries generated by model class, instance, and dataset methods (jeremyevans)
|
350
|
+
|
351
|
+
* Make sql_comments Database extension support Database#with_comments, for automatically including comments for queries executed inside the block (jeremyevans)
|
352
|
+
|
353
|
+
* Fix sql_comments extension to not modify cached SQL for a dataset (jeremyevans)
|
354
|
+
|
355
|
+
=== 5.51.0 (2021-12-01)
|
356
|
+
|
357
|
+
* Make eager loading via tactical_eager_loading no longer modify objects who already have a cached value for the association (jeremyevans)
|
358
|
+
|
359
|
+
* Make association cloning handle cases where clone association sets different :class option than cloned association (jeremyevans)
|
360
|
+
|
361
|
+
* Make column schema entries on MySQL include an :extra entry for the Extra column in DESCRIBE output (bschmeck) (#1791)
|
362
|
+
|
363
|
+
* Update mock PostgreSQL adapter to default to PostgreSQL 14 instead of PostgreSQL 9.5 (jeremyevans)
|
364
|
+
|
365
|
+
* Support Dataset#with_recursive :search and :cycle options on PostgreSQL 14+ for result ordering and cycle detection (jeremyevans)
|
366
|
+
|
367
|
+
* Avoid method redefined verbose mode warnings in lazy_attributes plugin (jeremyevans)
|
368
|
+
|
369
|
+
=== 5.50.0 (2021-11-01)
|
370
|
+
|
371
|
+
* 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)
|
372
|
+
|
373
|
+
* Fix Model#freeze in composition, serialization, and serialization_modification_detection plugins to return self (jeremyevans) (#1788)
|
374
|
+
|
375
|
+
* Fix typecasting of lazy columns when using lazy_attributes plugin in model where dataset selects from subquery (jeremyevans)
|
376
|
+
|
377
|
+
* Add :before_preconnect Database option, for configuring extensions loaded via :preconnect_extensions (MarcPer, jeremyevans) (#1786)
|
378
|
+
|
379
|
+
* Change Dataset#columns! to use a LIMIT 0 query instead of a LIMIT 1 query (jeremyevans)
|
380
|
+
|
381
|
+
* Add sql_log_normalizer extension for normalizing logged SQL, helpful for analytics and sensitive data (jeremyevans)
|
382
|
+
|
383
|
+
* Add support for range_merge, multirange, and unnest, and PGMultiRange#op to pg_range_ops extension (jeremyevans)
|
384
|
+
|
385
|
+
* Add pg_multirange extension with support for PostgreSQL 14+ multirange types (jeremyevans)
|
386
|
+
|
387
|
+
=== 5.49.0 (2021-10-01)
|
388
|
+
|
389
|
+
* Switch block_given? usage to defined?(yield) (jeremyevans)
|
390
|
+
|
391
|
+
* Support table aliases for JOIN USING columns on PostgreSQL 14+ (jeremyevans)
|
392
|
+
|
393
|
+
* Support calling PostgreSQL procedures without arguments (jeremyevans)
|
394
|
+
|
395
|
+
* Support hstore subscripts in pg_hstore_ops on PostgreSQL 14+, for updating only part of an hstore value (jeremyevans)
|
396
|
+
|
397
|
+
* Support JSONB subscripts in pg_json_ops on PostgreSQL 14+, for updating only part of a JSONB value (jeremyevans)
|
398
|
+
|
399
|
+
* Support SQL::Expression#sequel_ast_transform for custom AST transforms on arbitrary expressions (jeremyevans)
|
400
|
+
|
401
|
+
* Add Database#create_trigger :replace option on PostgreSQL 14+ for CREATE OR REPLACE TRIGGER (jeremyevans)
|
402
|
+
|
403
|
+
* Make auto_validations plugin automatically setup no_null_byte validations (jeremyevans)
|
404
|
+
|
405
|
+
* Add Model#validates_no_null_byte to validation_helpers plugin (jeremyevans)
|
406
|
+
|
407
|
+
=== 5.48.0 (2021-09-01)
|
408
|
+
|
409
|
+
* Make the unused_associations plugin association reflection tracking work correctly when combining coverage runs (jeremyevans)
|
410
|
+
|
411
|
+
* Add Database#like_without_collate on MSSQL, to avoid using COLLATE on LIKE arguments, which can significantly improve performance (jeremyevans)
|
412
|
+
|
413
|
+
* Add Model::Errors#full_message private method for easiest i18n support for errors with multiple attributes (jeremyevans) (#1779)
|
414
|
+
|
415
|
+
=== 5.47.0 (2021-08-01)
|
416
|
+
|
417
|
+
* Make the unused_associations plugin track access to association reflections to determine whether associations are used (jeremyevans)
|
418
|
+
|
419
|
+
* Support :db option for join tables in {many,one}_through_many to use a separate query for each join table (jeremyevans)
|
420
|
+
|
421
|
+
* Support :join_table_db option for many_to_many/one_through_one associations, to use a separate query for the join table (jeremyevans)
|
422
|
+
|
423
|
+
* Support :allow_eager_graph and :allow_filtering_by association options (jeremyevans)
|
424
|
+
|
425
|
+
* Add Database#rename_tables on MySQL, for renaming multiple tables in a single call (nick96) (#1774)
|
426
|
+
|
427
|
+
* Support Dataset#returning on SQLite 3.35+ (jeremyevans)
|
428
|
+
|
429
|
+
=== 5.46.0 (2021-07-01)
|
430
|
+
|
431
|
+
* Add unused_associations plugin, for determining which associations and association methods are not used (jeremyevans)
|
432
|
+
|
433
|
+
* Make nil :setter/:adder/:remover/:clearer association options not create related methods (jeremyevans)
|
434
|
+
|
1
435
|
=== 5.45.0 (2021-06-01)
|
2
436
|
|
3
437
|
* Fix handling of NULL values in boolean columns in the ODBC adapter (jeremyevans) (#1765)
|
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
@@ -13,19 +13,20 @@ toolkit for Ruby.
|
|
13
13
|
database sharding.
|
14
14
|
* Sequel currently has adapters for ADO, Amalgalite,
|
15
15
|
IBM_DB, JDBC, MySQL, Mysql2, ODBC, Oracle,
|
16
|
-
PostgreSQL, SQLAnywhere, SQLite3, and
|
16
|
+
PostgreSQL, SQLAnywhere, SQLite3, TinyTDS, and Trilogy.
|
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
|
@@ -799,7 +825,7 @@ You can dynamically customize eager loads for both +eager+ and +eager_graph+ whi
|
|
799
825
|
|
800
826
|
=== Joining with Associations
|
801
827
|
|
802
|
-
You can use the +association_join+ method to add a join to the model's dataset based on the
|
828
|
+
You can use the +association_join+ method to add a join to the model's dataset based on the association:
|
803
829
|
|
804
830
|
Post.association_join(:author)
|
805
831
|
# SELECT * FROM posts
|
@@ -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.2.0.0 (due to the bigdecimal dependency).
|
899
931
|
|
900
932
|
== Maintainer
|
901
933
|
|