activerecord 6.0.0.beta2 → 6.0.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +471 -9
- data/README.rdoc +3 -1
- data/lib/active_record.rb +0 -1
- data/lib/active_record/association_relation.rb +15 -6
- data/lib/active_record/associations.rb +4 -3
- data/lib/active_record/associations/association.rb +10 -2
- data/lib/active_record/associations/builder/association.rb +14 -18
- data/lib/active_record/associations/builder/belongs_to.rb +5 -2
- data/lib/active_record/associations/builder/collection_association.rb +5 -15
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +1 -1
- data/lib/active_record/associations/builder/has_many.rb +2 -0
- data/lib/active_record/associations/builder/has_one.rb +35 -1
- data/lib/active_record/associations/builder/singular_association.rb +2 -0
- data/lib/active_record/associations/collection_association.rb +6 -2
- data/lib/active_record/associations/collection_proxy.rb +2 -2
- data/lib/active_record/associations/has_many_through_association.rb +4 -11
- data/lib/active_record/associations/join_dependency.rb +14 -9
- data/lib/active_record/associations/join_dependency/join_association.rb +12 -3
- data/lib/active_record/associations/preloader.rb +13 -8
- data/lib/active_record/associations/preloader/association.rb +34 -30
- data/lib/active_record/associations/preloader/through_association.rb +48 -28
- data/lib/active_record/attribute_methods.rb +3 -53
- data/lib/active_record/attribute_methods/before_type_cast.rb +4 -1
- data/lib/active_record/attribute_methods/dirty.rb +47 -14
- data/lib/active_record/attribute_methods/primary_key.rb +7 -15
- data/lib/active_record/attribute_methods/query.rb +2 -3
- data/lib/active_record/attribute_methods/read.rb +3 -9
- data/lib/active_record/attribute_methods/write.rb +6 -12
- data/lib/active_record/attributes.rb +13 -0
- data/lib/active_record/autosave_association.rb +21 -7
- data/lib/active_record/base.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +109 -11
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +8 -4
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +88 -61
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +6 -4
- data/lib/active_record/connection_adapters/abstract/quoting.rb +63 -6
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +4 -7
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +79 -22
- data/lib/active_record/connection_adapters/abstract/transaction.rb +12 -4
- data/lib/active_record/connection_adapters/abstract_adapter.rb +114 -34
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +78 -73
- data/lib/active_record/connection_adapters/column.rb +17 -13
- data/lib/active_record/connection_adapters/connection_specification.rb +2 -2
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +2 -2
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +48 -8
- data/lib/active_record/connection_adapters/mysql/quoting.rb +44 -7
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +7 -5
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +10 -7
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +6 -10
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +18 -5
- data/lib/active_record/connection_adapters/postgresql/column.rb +17 -30
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +8 -2
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +39 -2
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +34 -38
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +23 -27
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +68 -27
- data/lib/active_record/connection_adapters/schema_cache.rb +32 -14
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +11 -8
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +120 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +38 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +2 -2
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +66 -114
- data/lib/active_record/connection_handling.rb +31 -13
- data/lib/active_record/core.rb +23 -24
- data/lib/active_record/database_configurations.rb +73 -44
- data/lib/active_record/database_configurations/hash_config.rb +11 -11
- data/lib/active_record/database_configurations/url_config.rb +12 -12
- data/lib/active_record/dynamic_matchers.rb +1 -1
- data/lib/active_record/enum.rb +15 -0
- data/lib/active_record/errors.rb +1 -1
- data/lib/active_record/fixtures.rb +11 -6
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/insert_all.rb +179 -0
- data/lib/active_record/integration.rb +13 -1
- data/lib/active_record/internal_metadata.rb +5 -1
- data/lib/active_record/locking/optimistic.rb +3 -4
- data/lib/active_record/log_subscriber.rb +1 -1
- data/lib/active_record/middleware/database_selector.rb +3 -3
- data/lib/active_record/middleware/database_selector/resolver.rb +4 -6
- data/lib/active_record/migration.rb +62 -44
- data/lib/active_record/migration/command_recorder.rb +28 -14
- data/lib/active_record/migration/compatibility.rb +10 -0
- data/lib/active_record/model_schema.rb +3 -0
- data/lib/active_record/persistence.rb +206 -13
- data/lib/active_record/querying.rb +17 -12
- data/lib/active_record/railtie.rb +0 -1
- data/lib/active_record/railties/databases.rake +127 -25
- data/lib/active_record/reflection.rb +3 -3
- data/lib/active_record/relation.rb +99 -20
- data/lib/active_record/relation/calculations.rb +38 -40
- data/lib/active_record/relation/delegation.rb +22 -30
- data/lib/active_record/relation/finder_methods.rb +17 -12
- data/lib/active_record/relation/merger.rb +11 -16
- data/lib/active_record/relation/query_methods.rb +228 -76
- data/lib/active_record/relation/where_clause.rb +9 -5
- data/lib/active_record/sanitization.rb +33 -4
- data/lib/active_record/schema.rb +1 -1
- data/lib/active_record/schema_dumper.rb +10 -1
- data/lib/active_record/schema_migration.rb +1 -1
- data/lib/active_record/scoping/default.rb +6 -7
- data/lib/active_record/scoping/named.rb +3 -2
- data/lib/active_record/statement_cache.rb +2 -2
- data/lib/active_record/store.rb +48 -0
- data/lib/active_record/table_metadata.rb +9 -13
- data/lib/active_record/tasks/database_tasks.rb +109 -6
- data/lib/active_record/tasks/mysql_database_tasks.rb +3 -1
- data/lib/active_record/test_databases.rb +1 -16
- data/lib/active_record/test_fixtures.rb +1 -0
- data/lib/active_record/timestamp.rb +26 -16
- data/lib/active_record/touch_later.rb +4 -2
- data/lib/active_record/transactions.rb +56 -46
- data/lib/active_record/type_caster/connection.rb +16 -10
- data/lib/active_record/validations.rb +1 -0
- data/lib/active_record/validations/uniqueness.rb +3 -5
- data/lib/arel.rb +12 -5
- data/lib/arel/insert_manager.rb +3 -3
- data/lib/arel/nodes.rb +2 -1
- data/lib/arel/nodes/comment.rb +29 -0
- data/lib/arel/nodes/select_core.rb +16 -12
- data/lib/arel/nodes/unary.rb +1 -0
- data/lib/arel/nodes/values_list.rb +2 -17
- data/lib/arel/select_manager.rb +10 -10
- data/lib/arel/visitors/depth_first.rb +7 -2
- data/lib/arel/visitors/dot.rb +7 -2
- data/lib/arel/visitors/ibm_db.rb +13 -0
- data/lib/arel/visitors/informix.rb +6 -0
- data/lib/arel/visitors/mssql.rb +15 -1
- data/lib/arel/visitors/oracle12.rb +4 -5
- data/lib/arel/visitors/postgresql.rb +4 -10
- data/lib/arel/visitors/to_sql.rb +107 -131
- data/lib/arel/visitors/visitor.rb +9 -5
- data/lib/rails/generators/active_record/migration/migration_generator.rb +1 -1
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +1 -1
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +1 -1
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +10 -1
- metadata +16 -12
- data/lib/active_record/collection_cache_key.rb +0 -53
- data/lib/arel/nodes/values.rb +0 -16
@@ -7,8 +7,8 @@ module Arel # :nodoc: all
|
|
7
7
|
@dispatch = get_dispatch_cache
|
8
8
|
end
|
9
9
|
|
10
|
-
def accept(object,
|
11
|
-
visit object,
|
10
|
+
def accept(object, collector = nil)
|
11
|
+
visit object, collector
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -16,7 +16,7 @@ module Arel # :nodoc: all
|
|
16
16
|
attr_reader :dispatch
|
17
17
|
|
18
18
|
def self.dispatch_cache
|
19
|
-
Hash.new do |hash, klass|
|
19
|
+
@dispatch_cache ||= Hash.new do |hash, klass|
|
20
20
|
hash[klass] = "visit_#{(klass.name || '').gsub('::', '_')}"
|
21
21
|
end
|
22
22
|
end
|
@@ -25,9 +25,13 @@ module Arel # :nodoc: all
|
|
25
25
|
self.class.dispatch_cache
|
26
26
|
end
|
27
27
|
|
28
|
-
def visit(object,
|
28
|
+
def visit(object, collector = nil)
|
29
29
|
dispatch_method = dispatch[object.class]
|
30
|
-
|
30
|
+
if collector
|
31
|
+
send dispatch_method, object, collector
|
32
|
+
else
|
33
|
+
send dispatch_method, object
|
34
|
+
end
|
31
35
|
rescue NoMethodError => e
|
32
36
|
raise e if respond_to?(dispatch_method, true)
|
33
37
|
superklass = object.class.ancestors.find { |klass|
|
@@ -8,7 +8,7 @@ module ActiveRecord
|
|
8
8
|
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
9
9
|
|
10
10
|
class_option :primary_key_type, type: :string, desc: "The type for primary key"
|
11
|
-
class_option :database, type: :string, aliases: %i(db), desc: "The database for your migration. By default, the current environment's primary database is used."
|
11
|
+
class_option :database, type: :string, aliases: %i(--db), desc: "The database for your migration. By default, the current environment's primary database is used."
|
12
12
|
|
13
13
|
def create_migration_file
|
14
14
|
set_local_assigns!
|
@@ -6,7 +6,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
|
|
6
6
|
t.string :password_digest<%= attribute.inject_options %>
|
7
7
|
<% elsif attribute.token? -%>
|
8
8
|
t.string :<%= attribute.name %><%= attribute.inject_options %>
|
9
|
-
<%
|
9
|
+
<% elsif !attribute.virtual? -%>
|
10
10
|
t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
|
11
11
|
<% end -%>
|
12
12
|
<% end -%>
|
@@ -7,7 +7,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
|
|
7
7
|
<%- elsif attribute.token? -%>
|
8
8
|
add_column :<%= table_name %>, :<%= attribute.name %>, :string<%= attribute.inject_options %>
|
9
9
|
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
|
10
|
-
<%-
|
10
|
+
<%- elsif !attribute.virtual? -%>
|
11
11
|
add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
|
12
12
|
<%- if attribute.has_index? -%>
|
13
13
|
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
@@ -21,7 +21,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
|
|
21
21
|
<%- attributes.each do |attribute| -%>
|
22
22
|
<%- if attribute.reference? -%>
|
23
23
|
t.references :<%= attribute.name %><%= attribute.inject_options %>
|
24
|
-
<%-
|
24
|
+
<%- elsif !attribute.virtual? -%>
|
25
25
|
<%= '# ' unless attribute.has_index? -%>t.index <%= attribute.index_name %><%= attribute.inject_index_options %>
|
26
26
|
<%- end -%>
|
27
27
|
<%- end -%>
|
@@ -37,7 +37,9 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
|
|
37
37
|
<%- if attribute.has_index? -%>
|
38
38
|
remove_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
39
39
|
<%- end -%>
|
40
|
+
<%- if !attribute.virtual? %>
|
40
41
|
remove_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
|
42
|
+
<%- end -%>
|
41
43
|
<%- end -%>
|
42
44
|
<%- end -%>
|
43
45
|
<%- end -%>
|
@@ -14,7 +14,7 @@ module ActiveRecord
|
|
14
14
|
class_option :parent, type: :string, desc: "The parent class for the generated model"
|
15
15
|
class_option :indexes, type: :boolean, default: true, desc: "Add indexes for references and belongs_to columns"
|
16
16
|
class_option :primary_key_type, type: :string, desc: "The type for primary key"
|
17
|
-
class_option :database, type: :string, aliases: %i(db), desc: "The database for your model's migration. By default, the current environment's primary database is used."
|
17
|
+
class_option :database, type: :string, aliases: %i(--db), desc: "The database for your model's migration. By default, the current environment's primary database is used."
|
18
18
|
|
19
19
|
# creates the migration file for the model.
|
20
20
|
def create_migration_file
|
@@ -1,7 +1,16 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
class <%= class_name %> < <%= parent_class_name.classify %>
|
3
3
|
<% attributes.select(&:reference?).each do |attribute| -%>
|
4
|
-
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic?
|
4
|
+
belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %>
|
5
|
+
<% end -%>
|
6
|
+
<% attributes.select(&:rich_text?).each do |attribute| -%>
|
7
|
+
has_rich_text :<%= attribute.name %>
|
8
|
+
<% end -%>
|
9
|
+
<% attributes.select(&:attachment?).each do |attribute| -%>
|
10
|
+
has_one_attached :<%= attribute.name %>
|
11
|
+
<% end -%>
|
12
|
+
<% attributes.select(&:attachments?).each do |attribute| -%>
|
13
|
+
has_many_attached :<%= attribute.name %>
|
5
14
|
<% end -%>
|
6
15
|
<% attributes.select(&:token?).each do |attribute| -%>
|
7
16
|
has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.2.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.
|
19
|
+
version: 6.0.2.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.0.
|
26
|
+
version: 6.0.2.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 6.0.
|
33
|
+
version: 6.0.2.rc1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 6.0.
|
40
|
+
version: 6.0.2.rc1
|
41
41
|
description: Databases on Rails. Build a persistent domain model by mapping database
|
42
42
|
tables to Ruby classes. Strong conventions for associations, validations, aggregations,
|
43
43
|
migrations, and testing come baked-in.
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- lib/active_record/callbacks.rb
|
102
102
|
- lib/active_record/coders/json.rb
|
103
103
|
- lib/active_record/coders/yaml_column.rb
|
104
|
-
- lib/active_record/collection_cache_key.rb
|
105
104
|
- lib/active_record/connection_adapters/abstract/connection_pool.rb
|
106
105
|
- lib/active_record/connection_adapters/abstract/database_limits.rb
|
107
106
|
- lib/active_record/connection_adapters/abstract/database_statements.rb
|
@@ -165,6 +164,7 @@ files:
|
|
165
164
|
- lib/active_record/connection_adapters/postgresql_adapter.rb
|
166
165
|
- lib/active_record/connection_adapters/schema_cache.rb
|
167
166
|
- lib/active_record/connection_adapters/sql_type_metadata.rb
|
167
|
+
- lib/active_record/connection_adapters/sqlite3/database_statements.rb
|
168
168
|
- lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb
|
169
169
|
- lib/active_record/connection_adapters/sqlite3/quoting.rb
|
170
170
|
- lib/active_record/connection_adapters/sqlite3/schema_creation.rb
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/active_record/fixtures.rb
|
196
196
|
- lib/active_record/gem_version.rb
|
197
197
|
- lib/active_record/inheritance.rb
|
198
|
+
- lib/active_record/insert_all.rb
|
198
199
|
- lib/active_record/integration.rb
|
199
200
|
- lib/active_record/internal_metadata.rb
|
200
201
|
- lib/active_record/legacy_yaml_adapter.rb
|
@@ -316,6 +317,7 @@ files:
|
|
316
317
|
- lib/arel/nodes/bind_param.rb
|
317
318
|
- lib/arel/nodes/case.rb
|
318
319
|
- lib/arel/nodes/casted.rb
|
320
|
+
- lib/arel/nodes/comment.rb
|
319
321
|
- lib/arel/nodes/count.rb
|
320
322
|
- lib/arel/nodes/delete_statement.rb
|
321
323
|
- lib/arel/nodes/descending.rb
|
@@ -349,7 +351,6 @@ files:
|
|
349
351
|
- lib/arel/nodes/unary_operation.rb
|
350
352
|
- lib/arel/nodes/unqualified_column.rb
|
351
353
|
- lib/arel/nodes/update_statement.rb
|
352
|
-
- lib/arel/nodes/values.rb
|
353
354
|
- lib/arel/nodes/values_list.rb
|
354
355
|
- lib/arel/nodes/window.rb
|
355
356
|
- lib/arel/nodes/with.rb
|
@@ -384,12 +385,15 @@ files:
|
|
384
385
|
- lib/rails/generators/active_record/model/model_generator.rb
|
385
386
|
- lib/rails/generators/active_record/model/templates/model.rb.tt
|
386
387
|
- lib/rails/generators/active_record/model/templates/module.rb.tt
|
387
|
-
homepage:
|
388
|
+
homepage: https://rubyonrails.org
|
388
389
|
licenses:
|
389
390
|
- MIT
|
390
391
|
metadata:
|
391
|
-
|
392
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
392
|
+
bug_tracker_uri: https://github.com/rails/rails/issues
|
393
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.2.rc1/activerecord/CHANGELOG.md
|
394
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.2.rc1/
|
395
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
|
396
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.2.rc1/activerecord
|
393
397
|
post_install_message:
|
394
398
|
rdoc_options:
|
395
399
|
- "--main"
|
@@ -407,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
411
|
- !ruby/object:Gem::Version
|
408
412
|
version: 1.3.1
|
409
413
|
requirements: []
|
410
|
-
rubygems_version: 3.0.
|
414
|
+
rubygems_version: 3.0.3
|
411
415
|
signing_key:
|
412
416
|
specification_version: 4
|
413
417
|
summary: Object-relational mapper framework (part of Rails).
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module CollectionCacheKey
|
5
|
-
def collection_cache_key(collection = all, timestamp_column = :updated_at) # :nodoc:
|
6
|
-
query_signature = ActiveSupport::Digest.hexdigest(collection.to_sql)
|
7
|
-
key = "#{collection.model_name.cache_key}/query-#{query_signature}"
|
8
|
-
|
9
|
-
if collection.loaded? || collection.distinct_value
|
10
|
-
size = collection.records.size
|
11
|
-
if size > 0
|
12
|
-
timestamp = collection.max_by(×tamp_column)._read_attribute(timestamp_column)
|
13
|
-
end
|
14
|
-
else
|
15
|
-
if collection.eager_loading?
|
16
|
-
collection = collection.send(:apply_join_dependency)
|
17
|
-
end
|
18
|
-
column_type = type_for_attribute(timestamp_column)
|
19
|
-
column = connection.visitor.compile(collection.arel_attribute(timestamp_column))
|
20
|
-
select_values = "COUNT(*) AS #{connection.quote_column_name("size")}, MAX(%s) AS timestamp"
|
21
|
-
|
22
|
-
if collection.has_limit_or_offset?
|
23
|
-
query = collection.select("#{column} AS collection_cache_key_timestamp")
|
24
|
-
subquery_alias = "subquery_for_cache_key"
|
25
|
-
subquery_column = "#{subquery_alias}.collection_cache_key_timestamp"
|
26
|
-
subquery = query.arel.as(subquery_alias)
|
27
|
-
arel = Arel::SelectManager.new(subquery).project(select_values % subquery_column)
|
28
|
-
else
|
29
|
-
query = collection.unscope(:order)
|
30
|
-
query.select_values = [select_values % column]
|
31
|
-
arel = query.arel
|
32
|
-
end
|
33
|
-
|
34
|
-
result = connection.select_one(arel, nil)
|
35
|
-
|
36
|
-
if result.blank?
|
37
|
-
size = 0
|
38
|
-
timestamp = nil
|
39
|
-
else
|
40
|
-
size = result["size"]
|
41
|
-
timestamp = column_type.deserialize(result["timestamp"])
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
if timestamp
|
47
|
-
"#{key}-#{size}-#{timestamp.utc.to_s(cache_timestamp_format)}"
|
48
|
-
else
|
49
|
-
"#{key}-#{size}"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/arel/nodes/values.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Arel # :nodoc: all
|
4
|
-
module Nodes
|
5
|
-
class Values < Arel::Nodes::Binary
|
6
|
-
alias :expressions :left
|
7
|
-
alias :expressions= :left=
|
8
|
-
alias :columns :right
|
9
|
-
alias :columns= :right=
|
10
|
-
|
11
|
-
def initialize(exprs, columns = [])
|
12
|
-
super
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|