activerecord-spanner-adapter 1.8.0 → 2.1.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/.github/workflows/acceptance-tests-on-emulator.yaml +4 -6
- data/.github/workflows/ci.yaml +4 -6
- data/.github/workflows/nightly-acceptance-tests-on-emulator.yaml +4 -6
- data/.github/workflows/nightly-unit-tests.yaml +4 -6
- data/.github/workflows/rubocop.yaml +1 -1
- data/.github/workflows/samples.yaml +30 -0
- data/.kokoro/release.cfg +2 -2
- data/.kokoro/release.sh +1 -4
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +28 -0
- data/Gemfile +6 -5
- data/README.md +26 -22
- data/acceptance/cases/migration/command_recorder_test.rb +7 -38
- data/acceptance/cases/migration/references_index_test.rb +2 -11
- data/acceptance/cases/models/binary_identifiers.rb +97 -0
- data/acceptance/cases/models/default_value_test.rb +2 -2
- data/acceptance/cases/tasks/database_tasks_test.rb +71 -74
- data/acceptance/cases/transactions/read_write_transactions_test.rb +10 -4
- data/acceptance/models/binary_project.rb +20 -0
- data/acceptance/models/string_io.rb +28 -0
- data/acceptance/models/user.rb +20 -0
- data/acceptance/test_helper.rb +22 -8
- data/activerecord-spanner-adapter.gemspec +3 -3
- data/benchmarks/application.rb +3 -7
- data/examples/snippets/Rakefile +28 -5
- data/examples/snippets/array-data-type/application.rb +1 -5
- data/examples/snippets/array-data-type/config/database.yml +1 -0
- data/examples/snippets/auto-generated-primary-key/README.md +140 -0
- data/examples/snippets/auto-generated-primary-key/Rakefile +13 -0
- data/examples/snippets/auto-generated-primary-key/application.rb +86 -0
- data/examples/snippets/auto-generated-primary-key/config/database.yml +10 -0
- data/examples/snippets/auto-generated-primary-key/db/migrate/01_create_tables.rb +29 -0
- data/examples/snippets/auto-generated-primary-key/db/seeds.rb +31 -0
- data/examples/snippets/auto-generated-primary-key/models/album.rb +11 -0
- data/examples/snippets/auto-generated-primary-key/models/singer.rb +11 -0
- data/examples/snippets/bit-reversed-sequence/application.rb +0 -4
- data/examples/snippets/bit-reversed-sequence/config/database.yml +1 -0
- data/examples/snippets/bit-reversed-sequence/db/seeds.rb +2 -2
- data/examples/snippets/bulk-insert/application.rb +1 -5
- data/examples/snippets/bulk-insert/config/database.yml +1 -0
- data/examples/snippets/commit-timestamp/application.rb +0 -4
- data/examples/snippets/commit-timestamp/config/database.yml +1 -0
- data/examples/snippets/config/environment.rb +5 -0
- data/examples/snippets/create-records/application.rb +1 -5
- data/examples/snippets/create-records/config/database.yml +1 -0
- data/examples/snippets/date-data-type/application.rb +1 -5
- data/examples/snippets/date-data-type/config/database.yml +1 -0
- data/examples/snippets/date-data-type/db/seeds.rb +1 -1
- data/examples/snippets/generated-column/application.rb +0 -4
- data/examples/snippets/generated-column/config/database.yml +1 -0
- data/examples/snippets/generated-column/db/seeds.rb +1 -1
- data/examples/snippets/hints/application.rb +0 -4
- data/examples/snippets/hints/config/database.yml +1 -0
- data/examples/snippets/hints/db/seeds.rb +1 -1
- data/examples/snippets/interleaved-tables/application.rb +1 -5
- data/examples/snippets/interleaved-tables/config/database.yml +1 -0
- data/examples/snippets/interleaved-tables/db/seeds.rb +1 -1
- data/examples/snippets/interleaved-tables/models/album.rb +6 -2
- data/examples/snippets/interleaved-tables/models/track.rb +5 -1
- data/examples/snippets/interleaved-tables-before-7.1/application.rb +1 -5
- data/examples/snippets/interleaved-tables-before-7.1/config/database.yml +1 -0
- data/examples/snippets/interleaved-tables-before-7.1/db/seeds.rb +1 -1
- data/examples/snippets/migrations/application.rb +0 -4
- data/examples/snippets/migrations/config/database.yml +1 -0
- data/examples/snippets/mutations/application.rb +1 -5
- data/examples/snippets/mutations/config/database.yml +1 -0
- data/examples/snippets/mutations/db/seeds.rb +1 -1
- data/examples/snippets/optimistic-locking/application.rb +0 -4
- data/examples/snippets/optimistic-locking/config/database.yml +1 -0
- data/examples/snippets/optimistic-locking/db/seeds.rb +1 -1
- data/examples/snippets/partitioned-dml/application.rb +0 -4
- data/examples/snippets/partitioned-dml/config/database.yml +1 -0
- data/examples/snippets/partitioned-dml/db/seeds.rb +1 -1
- data/examples/snippets/query-logs/application.rb +15 -13
- data/examples/snippets/query-logs/config/database.yml +1 -0
- data/examples/snippets/query-logs/db/seeds.rb +1 -1
- data/examples/snippets/quickstart/application.rb +0 -4
- data/examples/snippets/quickstart/config/database.yml +1 -0
- data/examples/snippets/quickstart/db/seeds.rb +1 -1
- data/examples/snippets/read-only-transactions/application.rb +0 -4
- data/examples/snippets/read-only-transactions/config/database.yml +1 -0
- data/examples/snippets/read-only-transactions/db/seeds.rb +1 -1
- data/examples/snippets/read-write-transactions/application.rb +2 -6
- data/examples/snippets/read-write-transactions/config/database.yml +1 -0
- data/examples/snippets/read-write-transactions/db/seeds.rb +1 -1
- data/examples/snippets/stale-reads/application.rb +0 -4
- data/examples/snippets/stale-reads/config/database.yml +1 -0
- data/examples/snippets/stale-reads/db/seeds.rb +1 -1
- data/examples/snippets/tags/application.rb +0 -4
- data/examples/snippets/tags/config/database.yml +1 -0
- data/examples/snippets/tags/db/seeds.rb +1 -1
- data/examples/snippets/timestamp-data-type/application.rb +0 -4
- data/examples/snippets/timestamp-data-type/config/database.yml +1 -0
- data/lib/active_record/connection_adapters/spanner/column.rb +7 -3
- data/lib/active_record/connection_adapters/spanner/database_statements.rb +34 -22
- data/lib/active_record/connection_adapters/spanner/quoting.rb +2 -1
- data/lib/active_record/connection_adapters/spanner/schema_creation.rb +20 -11
- data/lib/active_record/connection_adapters/spanner/schema_definitions.rb +12 -2
- data/lib/active_record/connection_adapters/spanner/schema_statements.rb +22 -51
- data/lib/active_record/connection_adapters/spanner/type_metadata.rb +10 -8
- data/lib/active_record/connection_adapters/spanner_adapter.rb +42 -7
- data/lib/active_record/tasks/spanner_database_tasks.rb +4 -4
- data/lib/active_record/type/spanner/array.rb +4 -0
- data/lib/active_record/type/spanner/bytes.rb +10 -0
- data/lib/activerecord_spanner_adapter/base.rb +59 -32
- data/lib/activerecord_spanner_adapter/connection.rb +9 -5
- data/lib/activerecord_spanner_adapter/foreign_key.rb +9 -2
- data/lib/activerecord_spanner_adapter/index/column.rb +6 -1
- data/lib/activerecord_spanner_adapter/index.rb +10 -2
- data/lib/activerecord_spanner_adapter/information_schema.rb +5 -3
- data/lib/activerecord_spanner_adapter/primary_key.rb +2 -2
- data/lib/activerecord_spanner_adapter/table/column.rb +16 -4
- data/lib/activerecord_spanner_adapter/table.rb +8 -2
- data/lib/activerecord_spanner_adapter/transaction.rb +1 -1
- data/lib/activerecord_spanner_adapter/version.rb +1 -1
- data/lib/arel/visitors/spanner.rb +16 -11
- data/lib/spanner_client_ext.rb +4 -3
- metadata +23 -34
- data/examples/snippets/array-data-type/db/schema.rb +0 -31
- data/examples/snippets/bit-reversed-sequence/db/schema.rb +0 -31
- data/examples/snippets/bulk-insert/db/schema.rb +0 -31
- data/examples/snippets/commit-timestamp/db/schema.rb +0 -34
- data/examples/snippets/create-records/db/schema.rb +0 -31
- data/examples/snippets/date-data-type/db/schema.rb +0 -26
- data/examples/snippets/generated-column/db/schema.rb +0 -26
- data/examples/snippets/hints/db/schema.rb +0 -33
- data/examples/snippets/interleaved-tables/db/schema.rb +0 -39
- data/examples/snippets/interleaved-tables-before-7.1/db/schema.rb +0 -37
- data/examples/snippets/migrations/db/schema.rb +0 -38
- data/examples/snippets/mutations/db/schema.rb +0 -32
- data/examples/snippets/optimistic-locking/db/schema.rb +0 -34
- data/examples/snippets/partitioned-dml/db/schema.rb +0 -31
- data/examples/snippets/query-logs/db/schema.rb +0 -31
- data/examples/snippets/quickstart/db/schema.rb +0 -31
- data/examples/snippets/read-only-transactions/db/schema.rb +0 -31
- data/examples/snippets/read-write-transactions/db/schema.rb +0 -32
- data/examples/snippets/stale-reads/db/schema.rb +0 -31
- data/examples/snippets/tags/db/schema.rb +0 -31
- data/examples/snippets/timestamp-data-type/db/schema.rb +0 -26
@@ -10,7 +10,9 @@ require "activerecord_spanner_adapter/information_schema"
|
|
10
10
|
|
11
11
|
module ActiveRecordSpannerAdapter
|
12
12
|
class Connection
|
13
|
-
attr_reader :instance_id
|
13
|
+
attr_reader :instance_id
|
14
|
+
attr_reader :database_id
|
15
|
+
attr_reader :spanner
|
14
16
|
attr_accessor :current_transaction
|
15
17
|
|
16
18
|
def initialize config
|
@@ -45,7 +47,7 @@ module ActiveRecordSpannerAdapter
|
|
45
47
|
|
46
48
|
def self.information_schema config
|
47
49
|
@information_schemas ||= {}
|
48
|
-
@information_schemas[database_path(config)] ||=
|
50
|
+
@information_schemas[database_path(config)] ||=
|
49
51
|
ActiveRecordSpannerAdapter::InformationSchema.new new(config)
|
50
52
|
end
|
51
53
|
|
@@ -202,7 +204,7 @@ module ActiveRecordSpannerAdapter
|
|
202
204
|
|
203
205
|
def execute_query sql, params: nil, types: nil, single_use_selector: nil, request_options: nil
|
204
206
|
if params
|
205
|
-
converted_params, types =
|
207
|
+
converted_params, types =
|
206
208
|
Google::Cloud::Spanner::Convert.to_input_params_and_types(
|
207
209
|
params, types
|
208
210
|
)
|
@@ -217,6 +219,7 @@ module ActiveRecordSpannerAdapter
|
|
217
219
|
execute_sql_request sql, converted_params, types, selector, request_options
|
218
220
|
end
|
219
221
|
|
222
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
220
223
|
def execute_sql_request sql, converted_params, types, selector, request_options = nil
|
221
224
|
res = session.execute_query \
|
222
225
|
sql,
|
@@ -224,7 +227,7 @@ module ActiveRecordSpannerAdapter
|
|
224
227
|
types: types,
|
225
228
|
transaction: selector,
|
226
229
|
request_options: request_options,
|
227
|
-
seqno:
|
230
|
+
seqno: current_transaction&.next_sequence_number
|
228
231
|
current_transaction.grpc_transaction = res.metadata.transaction \
|
229
232
|
if current_transaction && res&.metadata&.transaction
|
230
233
|
res
|
@@ -252,6 +255,7 @@ module ActiveRecordSpannerAdapter
|
|
252
255
|
# It was not the first statement, so propagate the error.
|
253
256
|
raise
|
254
257
|
end
|
258
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
255
259
|
|
256
260
|
# Creates a transaction using a BeginTransaction RPC. This is used if the first statement of a
|
257
261
|
# transaction fails, as that also means that no transaction id was returned.
|
@@ -283,7 +287,7 @@ module ActiveRecordSpannerAdapter
|
|
283
287
|
end
|
284
288
|
|
285
289
|
def transaction_selector
|
286
|
-
|
290
|
+
current_transaction&.transaction_selector if current_transaction&.active?
|
287
291
|
end
|
288
292
|
|
289
293
|
def truncate table_name
|
@@ -6,8 +6,15 @@
|
|
6
6
|
|
7
7
|
module ActiveRecordSpannerAdapter
|
8
8
|
class ForeignKey
|
9
|
-
attr_accessor :table_schema
|
10
|
-
|
9
|
+
attr_accessor :table_schema
|
10
|
+
attr_accessor :table_name
|
11
|
+
attr_accessor :name
|
12
|
+
attr_accessor :columns
|
13
|
+
attr_accessor :ref_schema
|
14
|
+
attr_accessor :ref_table
|
15
|
+
attr_accessor :ref_columns
|
16
|
+
attr_accessor :on_delete
|
17
|
+
attr_accessor :on_update
|
11
18
|
|
12
19
|
def initialize \
|
13
20
|
table_name,
|
@@ -7,7 +7,12 @@
|
|
7
7
|
module ActiveRecordSpannerAdapter
|
8
8
|
class Index
|
9
9
|
class Column
|
10
|
-
attr_accessor :table_name
|
10
|
+
attr_accessor :table_name
|
11
|
+
attr_accessor :schema_name
|
12
|
+
attr_accessor :index_name
|
13
|
+
attr_accessor :name
|
14
|
+
attr_accessor :order
|
15
|
+
attr_accessor :ordinal_position
|
11
16
|
|
12
17
|
def initialize \
|
13
18
|
table_name,
|
@@ -8,8 +8,16 @@ require "activerecord_spanner_adapter/index/column"
|
|
8
8
|
|
9
9
|
module ActiveRecordSpannerAdapter
|
10
10
|
class Index
|
11
|
-
attr_accessor :schema
|
12
|
-
|
11
|
+
attr_accessor :schema
|
12
|
+
attr_accessor :table
|
13
|
+
attr_accessor :name
|
14
|
+
attr_accessor :columns
|
15
|
+
attr_accessor :type
|
16
|
+
attr_accessor :unique
|
17
|
+
attr_accessor :null_filtered
|
18
|
+
attr_accessor :interleave_in
|
19
|
+
attr_accessor :storing
|
20
|
+
attr_accessor :state
|
13
21
|
|
14
22
|
def initialize \
|
15
23
|
table,
|
@@ -32,7 +32,7 @@ module ActiveRecordSpannerAdapter
|
|
32
32
|
|
33
33
|
rows = execute_query(
|
34
34
|
sql,
|
35
|
-
schema_name:
|
35
|
+
schema_name: schema_name || "", table_name: table_name
|
36
36
|
)
|
37
37
|
|
38
38
|
rows.map do |row|
|
@@ -66,7 +66,8 @@ module ActiveRecordSpannerAdapter
|
|
66
66
|
def table_columns table_name, column_name: nil, schema_name: ""
|
67
67
|
primary_keys = table_primary_keys(table_name).map(&:name)
|
68
68
|
sql = +"SELECT COLUMN_NAME, SPANNER_TYPE, IS_NULLABLE, GENERATION_EXPRESSION,"
|
69
|
-
sql << " CAST(COLUMN_DEFAULT AS STRING) AS COLUMN_DEFAULT, ORDINAL_POSITION"
|
69
|
+
sql << " CAST(COLUMN_DEFAULT AS STRING) AS COLUMN_DEFAULT, ORDINAL_POSITION,"
|
70
|
+
sql << " IS_IDENTITY"
|
70
71
|
sql << " FROM INFORMATION_SCHEMA.COLUMNS"
|
71
72
|
sql << " WHERE TABLE_NAME=%<table_name>s"
|
72
73
|
sql << " AND TABLE_SCHEMA=%<schema_name>s"
|
@@ -114,7 +115,8 @@ module ActiveRecordSpannerAdapter
|
|
114
115
|
default: default,
|
115
116
|
default_function: default_function,
|
116
117
|
generated: row["GENERATION_EXPRESSION"].present?,
|
117
|
-
primary_key: primary_key
|
118
|
+
primary_key: primary_key,
|
119
|
+
is_identity: row["IS_IDENTITY"] == "YES"
|
118
120
|
end
|
119
121
|
|
120
122
|
def table_column table_name, column_name, schema_name: ""
|
@@ -18,8 +18,8 @@ module ActiveRecord
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def fetch_primary_and_parent_key
|
21
|
-
|
22
|
-
if ActiveRecord::Base
|
21
|
+
connection.spanner_schema_cache.primary_and_parent_keys table_name \
|
22
|
+
if self != ActiveRecord::Base && table_exists?
|
23
23
|
end
|
24
24
|
|
25
25
|
def primary_and_parent_key= value
|
@@ -7,9 +7,19 @@
|
|
7
7
|
module ActiveRecordSpannerAdapter
|
8
8
|
class Table
|
9
9
|
class Column
|
10
|
-
attr_accessor :schema_name
|
11
|
-
|
12
|
-
|
10
|
+
attr_accessor :schema_name
|
11
|
+
attr_accessor :table_name
|
12
|
+
attr_accessor :name
|
13
|
+
attr_accessor :type
|
14
|
+
attr_accessor :limit
|
15
|
+
attr_accessor :ordinal_position
|
16
|
+
attr_accessor :allow_commit_timestamp
|
17
|
+
attr_accessor :default
|
18
|
+
attr_accessor :default_function
|
19
|
+
attr_accessor :generated
|
20
|
+
attr_accessor :primary_key
|
21
|
+
attr_accessor :nullable
|
22
|
+
attr_accessor :is_identity
|
13
23
|
|
14
24
|
def initialize \
|
15
25
|
table_name,
|
@@ -23,7 +33,8 @@ module ActiveRecordSpannerAdapter
|
|
23
33
|
default: nil,
|
24
34
|
default_function: nil,
|
25
35
|
generated: nil,
|
26
|
-
primary_key: false
|
36
|
+
primary_key: false,
|
37
|
+
is_identity: false
|
27
38
|
@schema_name = schema_name.to_s
|
28
39
|
@table_name = table_name.to_s
|
29
40
|
@name = name.to_s
|
@@ -36,6 +47,7 @@ module ActiveRecordSpannerAdapter
|
|
36
47
|
@default_function = default_function
|
37
48
|
@generated = generated == true
|
38
49
|
@primary_key = primary_key
|
50
|
+
@is_identity = is_identity
|
39
51
|
end
|
40
52
|
|
41
53
|
def spanner_type
|
@@ -30,8 +30,14 @@ require "activerecord_spanner_adapter/table/column"
|
|
30
30
|
|
31
31
|
module ActiveRecordSpannerAdapter
|
32
32
|
class Table
|
33
|
-
attr_accessor :name
|
34
|
-
|
33
|
+
attr_accessor :name
|
34
|
+
attr_accessor :on_delete
|
35
|
+
attr_accessor :parent_table
|
36
|
+
attr_accessor :schema_name
|
37
|
+
attr_accessor :catalog
|
38
|
+
attr_accessor :indexes
|
39
|
+
attr_accessor :columns
|
40
|
+
attr_accessor :foreign_keys
|
35
41
|
|
36
42
|
# parent_table == interleave_in
|
37
43
|
def initialize \
|
@@ -123,7 +123,7 @@ module ActiveRecordSpannerAdapter
|
|
123
123
|
|
124
124
|
def shoot_and_forget_rollback
|
125
125
|
@connection.session.rollback @grpc_transaction.transaction_id if @committable
|
126
|
-
rescue StandardError
|
126
|
+
rescue StandardError
|
127
127
|
# Ignored
|
128
128
|
end
|
129
129
|
|
@@ -35,9 +35,7 @@ module Arel # :nodoc: all
|
|
35
35
|
sql = collector.hints[:statement_hint].value + sql if collector.hints[:statement_hint]
|
36
36
|
|
37
37
|
if binds
|
38
|
-
|
39
|
-
binds << collector.hints[:request_options] if collector.hints[:request_options]
|
40
|
-
[sql, binds]
|
38
|
+
compile_with_binds collector, sql, binds
|
41
39
|
else
|
42
40
|
sql
|
43
41
|
end
|
@@ -45,6 +43,12 @@ module Arel # :nodoc: all
|
|
45
43
|
|
46
44
|
private
|
47
45
|
|
46
|
+
def compile_with_binds collector, sql, binds
|
47
|
+
binds << collector.hints[:staleness] if collector.hints[:staleness]
|
48
|
+
binds << collector.hints[:request_options] if collector.hints[:request_options]
|
49
|
+
[sql, binds]
|
50
|
+
end
|
51
|
+
|
48
52
|
BIND_BLOCK = proc { |i| "@p#{i}" }
|
49
53
|
private_constant :BIND_BLOCK
|
50
54
|
|
@@ -62,43 +66,44 @@ module Arel # :nodoc: all
|
|
62
66
|
end
|
63
67
|
|
64
68
|
def visit_statement_hint v, collector
|
65
|
-
collector.hints[:statement_hint] =
|
69
|
+
collector.hints[:statement_hint] =
|
66
70
|
StatementHint.new v.delete_prefix("statement_hint:")
|
67
71
|
end
|
68
72
|
|
69
|
-
# rubocop:disable Naming/MethodName
|
73
|
+
# rubocop:disable Naming/MethodName, Metrics/AbcSize
|
70
74
|
def visit_Arel_Nodes_OptimizerHints o, collector
|
71
75
|
o.expr.each do |v|
|
72
76
|
visit_table_hint v, collector if v.start_with? "table_hint:"
|
73
77
|
visit_statement_hint v, collector if v.start_with? "statement_hint:"
|
74
78
|
if v.start_with? "max_staleness:"
|
75
|
-
collector.hints[:staleness] =
|
79
|
+
collector.hints[:staleness] =
|
76
80
|
StalenessHint.new max_staleness: v.delete_prefix("max_staleness:").to_f
|
77
81
|
next
|
78
82
|
end
|
79
83
|
if v.start_with? "exact_staleness:"
|
80
|
-
collector.hints[:staleness] =
|
84
|
+
collector.hints[:staleness] =
|
81
85
|
StalenessHint.new exact_staleness: v.delete_prefix("exact_staleness:").to_f
|
82
86
|
next
|
83
87
|
end
|
84
88
|
if v.start_with? "min_read_timestamp:"
|
85
89
|
time = Time.xmlschema v.delete_prefix("min_read_timestamp:")
|
86
|
-
collector.hints[:staleness] =
|
90
|
+
collector.hints[:staleness] =
|
87
91
|
StalenessHint.new min_read_timestamp: time
|
88
92
|
next
|
89
93
|
end
|
90
94
|
next unless v.start_with? "read_timestamp:"
|
91
95
|
time = Time.xmlschema v.delete_prefix("read_timestamp:")
|
92
|
-
collector.hints[:staleness] =
|
96
|
+
collector.hints[:staleness] =
|
93
97
|
StalenessHint.new read_timestamp: time
|
94
98
|
end
|
95
99
|
collector
|
96
100
|
end
|
101
|
+
# rubocop:enable Metrics/AbcSize
|
97
102
|
|
98
103
|
def visit_Arel_Nodes_Comment o, collector
|
99
|
-
o.values.each do |v|
|
104
|
+
o.values.each do |v| # rubocop:disable Style/HashEachMethods
|
100
105
|
if v.start_with?("request_tag:") || v.start_with?("transaction_tag:")
|
101
|
-
collector.hints[:request_options] ||=
|
106
|
+
collector.hints[:request_options] ||=
|
102
107
|
Google::Cloud::Spanner::V1::RequestOptions.new
|
103
108
|
end
|
104
109
|
|
data/lib/spanner_client_ext.rb
CHANGED
@@ -66,8 +66,8 @@ module Google
|
|
66
66
|
ensure_service!
|
67
67
|
|
68
68
|
snp_grpc = service.create_snapshot \
|
69
|
-
path, timestamp:
|
70
|
-
staleness:
|
69
|
+
path, timestamp: timestamp || read_timestamp,
|
70
|
+
staleness: staleness || exact_staleness
|
71
71
|
num_args = Snapshot.method(:from_grpc).arity
|
72
72
|
if num_args == 3
|
73
73
|
Snapshot.from_grpc snp_grpc, self, nil
|
@@ -105,7 +105,8 @@ module Google
|
|
105
105
|
end
|
106
106
|
|
107
107
|
class Transaction
|
108
|
-
attr_accessor :seqno
|
108
|
+
attr_accessor :seqno
|
109
|
+
attr_accessor :commit
|
109
110
|
end
|
110
111
|
end
|
111
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-spanner-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-17 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: google-cloud-spanner
|
@@ -44,20 +43,20 @@ dependencies:
|
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '7.0'
|
48
47
|
- - "<"
|
49
48
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
49
|
+
version: '9'
|
51
50
|
type: :runtime
|
52
51
|
prerelease: false
|
53
52
|
version_requirements: !ruby/object:Gem::Requirement
|
54
53
|
requirements:
|
55
54
|
- - ">="
|
56
55
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
56
|
+
version: '7.0'
|
58
57
|
- - "<"
|
59
58
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
59
|
+
version: '9'
|
61
60
|
- !ruby/object:Gem::Dependency
|
62
61
|
name: autotest-suffix
|
63
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,14 +91,14 @@ dependencies:
|
|
92
91
|
requirements:
|
93
92
|
- - "~>"
|
94
93
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
94
|
+
version: 1.30.1
|
96
95
|
type: :development
|
97
96
|
prerelease: false
|
98
97
|
version_requirements: !ruby/object:Gem::Requirement
|
99
98
|
requirements:
|
100
99
|
- - "~>"
|
101
100
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
101
|
+
version: 1.30.1
|
103
102
|
- !ruby/object:Gem::Dependency
|
104
103
|
name: minitest
|
105
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,6 +244,7 @@ files:
|
|
245
244
|
- ".github/workflows/nightly-acceptance-tests-on-production.yaml"
|
246
245
|
- ".github/workflows/nightly-unit-tests.yaml"
|
247
246
|
- ".github/workflows/rubocop.yaml"
|
247
|
+
- ".github/workflows/samples.yaml"
|
248
248
|
- ".gitignore"
|
249
249
|
- ".kokoro/populate-secrets.sh"
|
250
250
|
- ".kokoro/release.cfg"
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- acceptance/cases/migration/references_statements_test.rb
|
284
284
|
- acceptance/cases/migration/rename_column_test.rb
|
285
285
|
- acceptance/cases/migration/schema_dumper_test.rb
|
286
|
+
- acceptance/cases/models/binary_identifiers.rb
|
286
287
|
- acceptance/cases/models/calculation_query_test.rb
|
287
288
|
- acceptance/cases/models/default_value_test.rb
|
288
289
|
- acceptance/cases/models/generated_column_test.rb
|
@@ -313,6 +314,7 @@ files:
|
|
313
314
|
- acceptance/models/album.rb
|
314
315
|
- acceptance/models/all_types.rb
|
315
316
|
- acceptance/models/author.rb
|
317
|
+
- acceptance/models/binary_project.rb
|
316
318
|
- acceptance/models/club.rb
|
317
319
|
- acceptance/models/comment.rb
|
318
320
|
- acceptance/models/customer.rb
|
@@ -324,9 +326,11 @@ files:
|
|
324
326
|
- acceptance/models/organization.rb
|
325
327
|
- acceptance/models/post.rb
|
326
328
|
- acceptance/models/singer.rb
|
329
|
+
- acceptance/models/string_io.rb
|
327
330
|
- acceptance/models/table_with_sequence.rb
|
328
331
|
- acceptance/models/track.rb
|
329
332
|
- acceptance/models/transaction.rb
|
333
|
+
- acceptance/models/user.rb
|
330
334
|
- acceptance/schema/schema.rb
|
331
335
|
- acceptance/test_helper.rb
|
332
336
|
- acceptance/test_helpers/with_separate_database.rb
|
@@ -351,16 +355,22 @@ files:
|
|
351
355
|
- examples/snippets/array-data-type/application.rb
|
352
356
|
- examples/snippets/array-data-type/config/database.yml
|
353
357
|
- examples/snippets/array-data-type/db/migrate/01_create_tables.rb
|
354
|
-
- examples/snippets/array-data-type/db/schema.rb
|
355
358
|
- examples/snippets/array-data-type/db/seeds.rb
|
356
359
|
- examples/snippets/array-data-type/models/entity_with_array_types.rb
|
360
|
+
- examples/snippets/auto-generated-primary-key/README.md
|
361
|
+
- examples/snippets/auto-generated-primary-key/Rakefile
|
362
|
+
- examples/snippets/auto-generated-primary-key/application.rb
|
363
|
+
- examples/snippets/auto-generated-primary-key/config/database.yml
|
364
|
+
- examples/snippets/auto-generated-primary-key/db/migrate/01_create_tables.rb
|
365
|
+
- examples/snippets/auto-generated-primary-key/db/seeds.rb
|
366
|
+
- examples/snippets/auto-generated-primary-key/models/album.rb
|
367
|
+
- examples/snippets/auto-generated-primary-key/models/singer.rb
|
357
368
|
- examples/snippets/bin/create_emulator_instance.rb
|
358
369
|
- examples/snippets/bit-reversed-sequence/README.md
|
359
370
|
- examples/snippets/bit-reversed-sequence/Rakefile
|
360
371
|
- examples/snippets/bit-reversed-sequence/application.rb
|
361
372
|
- examples/snippets/bit-reversed-sequence/config/database.yml
|
362
373
|
- examples/snippets/bit-reversed-sequence/db/migrate/01_create_tables.rb
|
363
|
-
- examples/snippets/bit-reversed-sequence/db/schema.rb
|
364
374
|
- examples/snippets/bit-reversed-sequence/db/seeds.rb
|
365
375
|
- examples/snippets/bit-reversed-sequence/models/album.rb
|
366
376
|
- examples/snippets/bit-reversed-sequence/models/singer.rb
|
@@ -369,7 +379,6 @@ files:
|
|
369
379
|
- examples/snippets/bulk-insert/application.rb
|
370
380
|
- examples/snippets/bulk-insert/config/database.yml
|
371
381
|
- examples/snippets/bulk-insert/db/migrate/01_create_tables.rb
|
372
|
-
- examples/snippets/bulk-insert/db/schema.rb
|
373
382
|
- examples/snippets/bulk-insert/db/seeds.rb
|
374
383
|
- examples/snippets/bulk-insert/models/album.rb
|
375
384
|
- examples/snippets/bulk-insert/models/singer.rb
|
@@ -378,7 +387,6 @@ files:
|
|
378
387
|
- examples/snippets/commit-timestamp/application.rb
|
379
388
|
- examples/snippets/commit-timestamp/config/database.yml
|
380
389
|
- examples/snippets/commit-timestamp/db/migrate/01_create_tables.rb
|
381
|
-
- examples/snippets/commit-timestamp/db/schema.rb
|
382
390
|
- examples/snippets/commit-timestamp/db/seeds.rb
|
383
391
|
- examples/snippets/commit-timestamp/models/album.rb
|
384
392
|
- examples/snippets/commit-timestamp/models/singer.rb
|
@@ -388,7 +396,6 @@ files:
|
|
388
396
|
- examples/snippets/create-records/application.rb
|
389
397
|
- examples/snippets/create-records/config/database.yml
|
390
398
|
- examples/snippets/create-records/db/migrate/01_create_tables.rb
|
391
|
-
- examples/snippets/create-records/db/schema.rb
|
392
399
|
- examples/snippets/create-records/db/seeds.rb
|
393
400
|
- examples/snippets/create-records/models/album.rb
|
394
401
|
- examples/snippets/create-records/models/singer.rb
|
@@ -397,7 +404,6 @@ files:
|
|
397
404
|
- examples/snippets/date-data-type/application.rb
|
398
405
|
- examples/snippets/date-data-type/config/database.yml
|
399
406
|
- examples/snippets/date-data-type/db/migrate/01_create_tables.rb
|
400
|
-
- examples/snippets/date-data-type/db/schema.rb
|
401
407
|
- examples/snippets/date-data-type/db/seeds.rb
|
402
408
|
- examples/snippets/date-data-type/models/singer.rb
|
403
409
|
- examples/snippets/generated-column/README.md
|
@@ -405,7 +411,6 @@ files:
|
|
405
411
|
- examples/snippets/generated-column/application.rb
|
406
412
|
- examples/snippets/generated-column/config/database.yml
|
407
413
|
- examples/snippets/generated-column/db/migrate/01_create_tables.rb
|
408
|
-
- examples/snippets/generated-column/db/schema.rb
|
409
414
|
- examples/snippets/generated-column/db/seeds.rb
|
410
415
|
- examples/snippets/generated-column/models/singer.rb
|
411
416
|
- examples/snippets/hints/README.md
|
@@ -413,7 +418,6 @@ files:
|
|
413
418
|
- examples/snippets/hints/application.rb
|
414
419
|
- examples/snippets/hints/config/database.yml
|
415
420
|
- examples/snippets/hints/db/migrate/01_create_tables.rb
|
416
|
-
- examples/snippets/hints/db/schema.rb
|
417
421
|
- examples/snippets/hints/db/seeds.rb
|
418
422
|
- examples/snippets/hints/models/album.rb
|
419
423
|
- examples/snippets/hints/models/singer.rb
|
@@ -422,7 +426,6 @@ files:
|
|
422
426
|
- examples/snippets/interleaved-tables-before-7.1/application.rb
|
423
427
|
- examples/snippets/interleaved-tables-before-7.1/config/database.yml
|
424
428
|
- examples/snippets/interleaved-tables-before-7.1/db/migrate/01_create_tables.rb
|
425
|
-
- examples/snippets/interleaved-tables-before-7.1/db/schema.rb
|
426
429
|
- examples/snippets/interleaved-tables-before-7.1/db/seeds.rb
|
427
430
|
- examples/snippets/interleaved-tables-before-7.1/models/album.rb
|
428
431
|
- examples/snippets/interleaved-tables-before-7.1/models/singer.rb
|
@@ -432,7 +435,6 @@ files:
|
|
432
435
|
- examples/snippets/interleaved-tables/application.rb
|
433
436
|
- examples/snippets/interleaved-tables/config/database.yml
|
434
437
|
- examples/snippets/interleaved-tables/db/migrate/01_create_tables.rb
|
435
|
-
- examples/snippets/interleaved-tables/db/schema.rb
|
436
438
|
- examples/snippets/interleaved-tables/db/seeds.rb
|
437
439
|
- examples/snippets/interleaved-tables/models/album.rb
|
438
440
|
- examples/snippets/interleaved-tables/models/singer.rb
|
@@ -442,7 +444,6 @@ files:
|
|
442
444
|
- examples/snippets/migrations/application.rb
|
443
445
|
- examples/snippets/migrations/config/database.yml
|
444
446
|
- examples/snippets/migrations/db/migrate/01_create_tables.rb
|
445
|
-
- examples/snippets/migrations/db/schema.rb
|
446
447
|
- examples/snippets/migrations/db/seeds.rb
|
447
448
|
- examples/snippets/migrations/models/album.rb
|
448
449
|
- examples/snippets/migrations/models/singer.rb
|
@@ -452,7 +453,6 @@ files:
|
|
452
453
|
- examples/snippets/mutations/application.rb
|
453
454
|
- examples/snippets/mutations/config/database.yml
|
454
455
|
- examples/snippets/mutations/db/migrate/01_create_tables.rb
|
455
|
-
- examples/snippets/mutations/db/schema.rb
|
456
456
|
- examples/snippets/mutations/db/seeds.rb
|
457
457
|
- examples/snippets/mutations/models/album.rb
|
458
458
|
- examples/snippets/mutations/models/singer.rb
|
@@ -461,7 +461,6 @@ files:
|
|
461
461
|
- examples/snippets/optimistic-locking/application.rb
|
462
462
|
- examples/snippets/optimistic-locking/config/database.yml
|
463
463
|
- examples/snippets/optimistic-locking/db/migrate/01_create_tables.rb
|
464
|
-
- examples/snippets/optimistic-locking/db/schema.rb
|
465
464
|
- examples/snippets/optimistic-locking/db/seeds.rb
|
466
465
|
- examples/snippets/optimistic-locking/models/album.rb
|
467
466
|
- examples/snippets/optimistic-locking/models/singer.rb
|
@@ -470,7 +469,6 @@ files:
|
|
470
469
|
- examples/snippets/partitioned-dml/application.rb
|
471
470
|
- examples/snippets/partitioned-dml/config/database.yml
|
472
471
|
- examples/snippets/partitioned-dml/db/migrate/01_create_tables.rb
|
473
|
-
- examples/snippets/partitioned-dml/db/schema.rb
|
474
472
|
- examples/snippets/partitioned-dml/db/seeds.rb
|
475
473
|
- examples/snippets/partitioned-dml/models/album.rb
|
476
474
|
- examples/snippets/partitioned-dml/models/singer.rb
|
@@ -479,7 +477,6 @@ files:
|
|
479
477
|
- examples/snippets/query-logs/application.rb
|
480
478
|
- examples/snippets/query-logs/config/database.yml
|
481
479
|
- examples/snippets/query-logs/db/migrate/01_create_tables.rb
|
482
|
-
- examples/snippets/query-logs/db/schema.rb
|
483
480
|
- examples/snippets/query-logs/db/seeds.rb
|
484
481
|
- examples/snippets/query-logs/models/album.rb
|
485
482
|
- examples/snippets/query-logs/models/singer.rb
|
@@ -488,7 +485,6 @@ files:
|
|
488
485
|
- examples/snippets/quickstart/application.rb
|
489
486
|
- examples/snippets/quickstart/config/database.yml
|
490
487
|
- examples/snippets/quickstart/db/migrate/01_create_tables.rb
|
491
|
-
- examples/snippets/quickstart/db/schema.rb
|
492
488
|
- examples/snippets/quickstart/db/seeds.rb
|
493
489
|
- examples/snippets/quickstart/models/album.rb
|
494
490
|
- examples/snippets/quickstart/models/singer.rb
|
@@ -497,7 +493,6 @@ files:
|
|
497
493
|
- examples/snippets/read-only-transactions/application.rb
|
498
494
|
- examples/snippets/read-only-transactions/config/database.yml
|
499
495
|
- examples/snippets/read-only-transactions/db/migrate/01_create_tables.rb
|
500
|
-
- examples/snippets/read-only-transactions/db/schema.rb
|
501
496
|
- examples/snippets/read-only-transactions/db/seeds.rb
|
502
497
|
- examples/snippets/read-only-transactions/models/album.rb
|
503
498
|
- examples/snippets/read-only-transactions/models/singer.rb
|
@@ -506,7 +501,6 @@ files:
|
|
506
501
|
- examples/snippets/read-write-transactions/application.rb
|
507
502
|
- examples/snippets/read-write-transactions/config/database.yml
|
508
503
|
- examples/snippets/read-write-transactions/db/migrate/01_create_tables.rb
|
509
|
-
- examples/snippets/read-write-transactions/db/schema.rb
|
510
504
|
- examples/snippets/read-write-transactions/db/seeds.rb
|
511
505
|
- examples/snippets/read-write-transactions/models/album.rb
|
512
506
|
- examples/snippets/read-write-transactions/models/singer.rb
|
@@ -515,7 +509,6 @@ files:
|
|
515
509
|
- examples/snippets/stale-reads/application.rb
|
516
510
|
- examples/snippets/stale-reads/config/database.yml
|
517
511
|
- examples/snippets/stale-reads/db/migrate/01_create_tables.rb
|
518
|
-
- examples/snippets/stale-reads/db/schema.rb
|
519
512
|
- examples/snippets/stale-reads/db/seeds.rb
|
520
513
|
- examples/snippets/stale-reads/models/album.rb
|
521
514
|
- examples/snippets/stale-reads/models/singer.rb
|
@@ -524,7 +517,6 @@ files:
|
|
524
517
|
- examples/snippets/tags/application.rb
|
525
518
|
- examples/snippets/tags/config/database.yml
|
526
519
|
- examples/snippets/tags/db/migrate/01_create_tables.rb
|
527
|
-
- examples/snippets/tags/db/schema.rb
|
528
520
|
- examples/snippets/tags/db/seeds.rb
|
529
521
|
- examples/snippets/tags/models/album.rb
|
530
522
|
- examples/snippets/tags/models/singer.rb
|
@@ -533,7 +525,6 @@ files:
|
|
533
525
|
- examples/snippets/timestamp-data-type/application.rb
|
534
526
|
- examples/snippets/timestamp-data-type/config/database.yml
|
535
527
|
- examples/snippets/timestamp-data-type/db/migrate/01_create_tables.rb
|
536
|
-
- examples/snippets/timestamp-data-type/db/schema.rb
|
537
528
|
- examples/snippets/timestamp-data-type/db/seeds.rb
|
538
529
|
- examples/snippets/timestamp-data-type/models/meeting.rb
|
539
530
|
- examples/solidus/README.md
|
@@ -574,7 +565,6 @@ homepage: https://github.com/googleapis/ruby-spanner-activerecord
|
|
574
565
|
licenses:
|
575
566
|
- MIT
|
576
567
|
metadata: {}
|
577
|
-
post_install_message:
|
578
568
|
rdoc_options: []
|
579
569
|
require_paths:
|
580
570
|
- lib
|
@@ -582,15 +572,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
582
572
|
requirements:
|
583
573
|
- - ">="
|
584
574
|
- !ruby/object:Gem::Version
|
585
|
-
version: '
|
575
|
+
version: '3.1'
|
586
576
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
587
577
|
requirements:
|
588
578
|
- - ">="
|
589
579
|
- !ruby/object:Gem::Version
|
590
580
|
version: '0'
|
591
581
|
requirements: []
|
592
|
-
rubygems_version: 3.5
|
593
|
-
signing_key:
|
582
|
+
rubygems_version: 3.6.5
|
594
583
|
specification_version: 4
|
595
584
|
summary: Rails ActiveRecord connector for Google Spanner Database
|
596
585
|
test_files: []
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead
|
2
|
-
# of editing this file, please use the migrations feature of Active Record to
|
3
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
-
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
|
-
# be faster and is potentially less error prone than running all of your
|
8
|
-
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
-
# migrations use external dependencies or application code.
|
10
|
-
#
|
11
|
-
# It's strongly recommended that you check this file into your version control system.
|
12
|
-
|
13
|
-
ActiveRecord::Schema.define(version: 1) do
|
14
|
-
connection.start_batch_ddl
|
15
|
-
|
16
|
-
create_table "entity_with_array_types", id: { limit: 8 }, force: :cascade do |t|
|
17
|
-
t.string "col_array_string"
|
18
|
-
t.integer "col_array_int64", limit: 8
|
19
|
-
t.float "col_array_float64"
|
20
|
-
t.decimal "col_array_numeric"
|
21
|
-
t.boolean "col_array_bool"
|
22
|
-
t.binary "col_array_bytes"
|
23
|
-
t.date "col_array_date"
|
24
|
-
t.time "col_array_timestamp"
|
25
|
-
end
|
26
|
-
|
27
|
-
connection.run_batch
|
28
|
-
rescue
|
29
|
-
abort_batch
|
30
|
-
raise
|
31
|
-
end
|