activerecord-spanner-adapter 1.4.4 → 1.5.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 +2 -4
- data/.github/workflows/acceptance-tests-on-production.yaml +1 -1
- data/.github/workflows/ci.yaml +2 -4
- data/.github/workflows/nightly-acceptance-tests-on-emulator.yaml +2 -14
- data/.github/workflows/nightly-acceptance-tests-on-production.yaml +1 -1
- data/.github/workflows/nightly-unit-tests.yaml +2 -10
- data/.github/workflows/release-please.yml +2 -2
- data/.github/workflows/rubocop.yaml +1 -1
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/README.md +5 -3
- data/activerecord-spanner-adapter.gemspec +2 -2
- data/examples/snippets/tags/README.md +29 -0
- data/examples/snippets/tags/Rakefile +13 -0
- data/examples/snippets/tags/application.rb +32 -0
- data/examples/snippets/tags/config/database.yml +8 -0
- data/examples/snippets/tags/db/migrate/01_create_tables.rb +21 -0
- data/examples/snippets/tags/db/schema.rb +31 -0
- data/examples/snippets/tags/db/seeds.rb +24 -0
- data/examples/snippets/tags/models/album.rb +9 -0
- data/examples/snippets/tags/models/singer.rb +9 -0
- data/lib/active_record/connection_adapters/spanner/database_statements.rb +7 -2
- data/lib/activerecord_spanner_adapter/connection.rb +4 -3
- data/lib/activerecord_spanner_adapter/version.rb +1 -1
- data/lib/arel/visitors/spanner.rb +21 -0
- metadata +14 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b10ee1d169ad72da934b5d726114d5b9ac215103c54b607a0fe0c18b2ed4876
|
|
4
|
+
data.tar.gz: 3a2e65fd406507987da6a38cbcc38130da9a3200e7ad1f2b5909701916903ab8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a842880cf43a9316cb76dba5a9ef0ecf576db7102a1d03a9ecd14308232801bb296701e6b8d1506a78d7895b61eec14f7e9b887e1d44dc075ba576076c2a6c5
|
|
7
|
+
data.tar.gz: c2c9af94b3d25a19098edfe18c2bb479826ec6996e76ec0c8a3e50280988a0aee694decb8df6452d1a1bb2bee6be1e8338ace5f4bf588d96fa6781de44c13f74
|
|
@@ -18,7 +18,7 @@ jobs:
|
|
|
18
18
|
strategy:
|
|
19
19
|
max-parallel: 4
|
|
20
20
|
matrix:
|
|
21
|
-
ruby: ["2.
|
|
21
|
+
ruby: ["2.7", "3.0", "3.1", "3.2"]
|
|
22
22
|
ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4"]
|
|
23
23
|
# Exclude combinations that are not supported.
|
|
24
24
|
exclude:
|
|
@@ -28,12 +28,10 @@ jobs:
|
|
|
28
28
|
ar: "~> 6.0.6"
|
|
29
29
|
- ruby: "3.2"
|
|
30
30
|
ar: "~> 6.0.6"
|
|
31
|
-
- ruby: "2.6"
|
|
32
|
-
ar: "~> 7.0.4"
|
|
33
31
|
env:
|
|
34
32
|
AR_VERSION: ${{ matrix.ar }}
|
|
35
33
|
steps:
|
|
36
|
-
- uses: actions/checkout@
|
|
34
|
+
- uses: actions/checkout@v4
|
|
37
35
|
- name: Set up Ruby
|
|
38
36
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
|
|
39
37
|
# (see https://github.com/ruby/setup-ruby#versioning):
|
|
@@ -26,7 +26,7 @@ jobs:
|
|
|
26
26
|
matrix:
|
|
27
27
|
ruby: [3.0]
|
|
28
28
|
steps:
|
|
29
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
30
|
- name: Set up Ruby
|
|
31
31
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
|
|
32
32
|
# (see https://github.com/ruby/setup-ruby#versioning):
|
data/.github/workflows/ci.yaml
CHANGED
|
@@ -10,7 +10,7 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
max-parallel: 4
|
|
12
12
|
matrix:
|
|
13
|
-
ruby: ["2.
|
|
13
|
+
ruby: ["2.7", "3.0", "3.1", "3.2"]
|
|
14
14
|
ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4"]
|
|
15
15
|
# Exclude combinations that are not supported.
|
|
16
16
|
exclude:
|
|
@@ -20,12 +20,10 @@ jobs:
|
|
|
20
20
|
ar: "~> 6.0.6"
|
|
21
21
|
- ruby: "3.2"
|
|
22
22
|
ar: "~> 6.0.6"
|
|
23
|
-
- ruby: "2.6"
|
|
24
|
-
ar: "~> 7.0.4"
|
|
25
23
|
env:
|
|
26
24
|
AR_VERSION: ${{ matrix.ar }}
|
|
27
25
|
steps:
|
|
28
|
-
- uses: actions/checkout@
|
|
26
|
+
- uses: actions/checkout@v4
|
|
29
27
|
- name: Set up Ruby
|
|
30
28
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
|
|
31
29
|
# (see https://github.com/ruby/setup-ruby#versioning):
|
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
max-parallel: 4
|
|
20
20
|
matrix:
|
|
21
21
|
# Run acceptance tests all supported combinations of Ruby and ActiveRecord.
|
|
22
|
-
ruby: [2.
|
|
22
|
+
ruby: [2.7, 3.0, 3.1, 3.2]
|
|
23
23
|
ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.3.2, 6.1.4.7, 6.1.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1, 7.0.4, 7.0.5, 7.0.6, 7.0.7]
|
|
24
24
|
# Exclude combinations that are not supported.
|
|
25
25
|
exclude:
|
|
@@ -53,22 +53,10 @@ jobs:
|
|
|
53
53
|
ar: 6.0.3.7
|
|
54
54
|
- ruby: 3.2
|
|
55
55
|
ar: 6.0.4
|
|
56
|
-
- ruby: 2.6
|
|
57
|
-
ar: 7.0.2.4
|
|
58
|
-
- ruby: 2.6
|
|
59
|
-
ar: 7.0.3.1
|
|
60
|
-
- ruby: 2.6
|
|
61
|
-
ar: 7.0.4
|
|
62
|
-
- ruby: 2.6
|
|
63
|
-
ar: 7.0.5
|
|
64
|
-
- ruby: 2.6
|
|
65
|
-
ar: 7.0.6
|
|
66
|
-
- ruby: 2.6
|
|
67
|
-
ar: 7.0.7
|
|
68
56
|
env:
|
|
69
57
|
AR_VERSION: ${{ matrix.ar }}
|
|
70
58
|
steps:
|
|
71
|
-
- uses: actions/checkout@
|
|
59
|
+
- uses: actions/checkout@v4
|
|
72
60
|
- name: Set up Ruby
|
|
73
61
|
uses: ruby/setup-ruby@v1
|
|
74
62
|
with:
|
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
matrix:
|
|
13
13
|
ruby: [3.0]
|
|
14
14
|
steps:
|
|
15
|
-
- uses: actions/checkout@
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
16
|
- name: Set up Ruby
|
|
17
17
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
|
|
18
18
|
# (see https://github.com/ruby/setup-ruby#versioning):
|
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
max-parallel: 4
|
|
12
12
|
matrix:
|
|
13
13
|
# Run unit tests all supported combinations of Ruby and ActiveRecord.
|
|
14
|
-
ruby: [2.
|
|
14
|
+
ruby: [2.7, 3.0, 3.1, 3.2]
|
|
15
15
|
ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.3.2, 6.1.4.7, 6.1.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1, 7.0.4, 7.0.5]
|
|
16
16
|
# Exclude combinations that are not supported.
|
|
17
17
|
exclude:
|
|
@@ -45,18 +45,10 @@ jobs:
|
|
|
45
45
|
ar: 6.0.3.7
|
|
46
46
|
- ruby: 3.2
|
|
47
47
|
ar: 6.0.4
|
|
48
|
-
- ruby: 2.6
|
|
49
|
-
ar: 7.0.2.4
|
|
50
|
-
- ruby: 2.6
|
|
51
|
-
ar: 7.0.3.1
|
|
52
|
-
- ruby: 2.6
|
|
53
|
-
ar: 7.0.4
|
|
54
|
-
- ruby: 2.6
|
|
55
|
-
ar: 7.0.5
|
|
56
48
|
env:
|
|
57
49
|
AR_VERSION: ${{ matrix.ar }}
|
|
58
50
|
steps:
|
|
59
|
-
- uses: actions/checkout@
|
|
51
|
+
- uses: actions/checkout@v4
|
|
60
52
|
- name: Set up Ruby
|
|
61
53
|
uses: ruby/setup-ruby@v1
|
|
62
54
|
with:
|
|
@@ -18,13 +18,13 @@ jobs:
|
|
|
18
18
|
RELEASE_PLEASE_DISABLE: ${{ secrets.RELEASE_PLEASE_DISABLE }}
|
|
19
19
|
steps:
|
|
20
20
|
- name: Checkout repo
|
|
21
|
-
uses: actions/checkout@
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
22
|
- name: Install Ruby 3.0
|
|
23
23
|
uses: ruby/setup-ruby@v1
|
|
24
24
|
with:
|
|
25
25
|
ruby-version: "3.0"
|
|
26
26
|
- name: Install NodeJS 16.x
|
|
27
|
-
uses: actions/setup-node@
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
28
|
with:
|
|
29
29
|
node-version: "16.x"
|
|
30
30
|
- name: Install tools
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 1.5.0 (2023-11-03)
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* Drop support for Ruby 2.6 ([#270](https://github.com/googleapis/ruby-spanner-activerecord/issues/270))
|
|
8
|
+
* translate annotate to tags ([#267](https://github.com/googleapis/ruby-spanner-activerecord/issues/267))
|
|
9
|
+
#### Documentation
|
|
10
|
+
|
|
11
|
+
* update README to reference PGAdapter for PG ([#263](https://github.com/googleapis/ruby-spanner-activerecord/issues/263))
|
|
12
|
+
* update README to reference PGAdapter for PG ([#263](https://github.com/googleapis/ruby-spanner-activerecord/issues/263)) ([#268](https://github.com/googleapis/ruby-spanner-activerecord/issues/268))
|
|
13
|
+
|
|
3
14
|
### 1.4.4 (2023-09-06)
|
|
4
15
|
|
|
5
16
|
#### Bug Fixes
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
__This adapter only supports GoogleSQL-dialect Cloud Spanner databases. PostgreSQL-dialect
|
|
8
|
-
databases are not supported.
|
|
8
|
+
databases are not supported. You can use the standard PostgreSQL ActiveRecord adapter in
|
|
9
|
+
[combination with PGAdapter](https://github.com/GoogleCloudPlatform/pgadapter/blob/-/samples/ruby/activerecord)
|
|
10
|
+
for Cloud Spanner PostgreSQL-dialect databases.__
|
|
9
11
|
|
|
10
12
|
This project provides a Cloud Spanner adapter for ActiveRecord. It supports the following versions:
|
|
11
13
|
|
|
12
|
-
- ActiveRecord 6.0.x with Ruby 2.
|
|
13
|
-
- ActiveRecord 6.1.x with Ruby 2.
|
|
14
|
+
- ActiveRecord 6.0.x with Ruby 2.7.
|
|
15
|
+
- ActiveRecord 6.1.x with Ruby 2.7 and higher.
|
|
14
16
|
- ActiveRecord 7.0.x with Ruby 2.7 and higher.
|
|
15
17
|
|
|
16
18
|
Known limitations are listed in the [Limitations](#limitations) section.
|
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename f }
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
|
-
spec.required_ruby_version = ">= 2.
|
|
25
|
+
spec.required_ruby_version = ">= 2.7"
|
|
26
26
|
|
|
27
|
-
spec.add_dependency "google-cloud-spanner", "~> 2.
|
|
27
|
+
spec.add_dependency "google-cloud-spanner", "~> 2.18"
|
|
28
28
|
spec.add_runtime_dependency "activerecord", [">= 6.0.0", "< 7.1"]
|
|
29
29
|
|
|
30
30
|
spec.add_development_dependency "autotest-suffix", "~> 1.1"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Sample - Request tags and Transaction tags
|
|
2
|
+
|
|
3
|
+
Queries can be annotated with request tags and transaction tags. These can be used to give
|
|
4
|
+
you more insights in your queries and transactions.
|
|
5
|
+
See https://cloud.google.com/spanner/docs/introspection/troubleshooting-with-tags for more
|
|
6
|
+
information about request and transaction tags in Cloud Spanner.
|
|
7
|
+
|
|
8
|
+
You can use the [`annotate`](https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-annotate)
|
|
9
|
+
method in Ruby ActiveRecord to add a request and/or transaction tag to a __query__. You must
|
|
10
|
+
prefix the annotation with either `request_tag:` or `transaction_tag:` to instruct the
|
|
11
|
+
Cloud Spanner ActiveRecord provider to recognize the annotation as a tag.
|
|
12
|
+
|
|
13
|
+
__NOTE:__ Ruby ActiveRecord does not add comments for `INSERT`, `UPDATE` and `DELETE` statements
|
|
14
|
+
when you add annotations to a model. This means that these statements will not be tagged.
|
|
15
|
+
|
|
16
|
+
Example:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The sample will automatically start a Spanner Emulator in a docker container and execute the sample
|
|
23
|
+
against that emulator. The emulator will automatically be stopped when the application finishes.
|
|
24
|
+
|
|
25
|
+
Run the application with the command
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bundle exec rake run
|
|
29
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2023 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
|
|
7
|
+
require_relative "../config/environment"
|
|
8
|
+
require "sinatra/activerecord/rake"
|
|
9
|
+
|
|
10
|
+
desc "Sample showing how to tag queries on Cloud Spanner with ActiveRecord."
|
|
11
|
+
task :run do
|
|
12
|
+
Dir.chdir("..") { sh "bundle exec rake run[tags]" }
|
|
13
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright 2023 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
|
|
7
|
+
require "io/console"
|
|
8
|
+
require_relative "../config/environment"
|
|
9
|
+
require_relative "models/singer"
|
|
10
|
+
require_relative "models/album"
|
|
11
|
+
|
|
12
|
+
class Application
|
|
13
|
+
def self.run
|
|
14
|
+
puts ""
|
|
15
|
+
puts "Query all Albums and include a request tag"
|
|
16
|
+
albums = Album.annotate("request_tag: query-all-albums").all
|
|
17
|
+
puts "Queried #{albums.length} albums using a request tag"
|
|
18
|
+
|
|
19
|
+
puts ""
|
|
20
|
+
puts "Query all Albums in a transaction and include a request tag and a transaction tag"
|
|
21
|
+
Album.transaction do
|
|
22
|
+
albums = Album.annotate("request_tag: query-all-albums", "transaction_tag: sample-transaction").all
|
|
23
|
+
puts "Queried #{albums.length} albums using a request and a transaction tag"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
puts ""
|
|
27
|
+
puts "Press any key to end the application"
|
|
28
|
+
STDIN.getch
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Application.run
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright 2023 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
|
|
7
|
+
class CreateTables < ActiveRecord::Migration[6.0]
|
|
8
|
+
def change
|
|
9
|
+
connection.ddl_batch do
|
|
10
|
+
create_table :singers do |t|
|
|
11
|
+
t.string :first_name
|
|
12
|
+
t.string :last_name
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
create_table :albums do |t|
|
|
16
|
+
t.string :title
|
|
17
|
+
t.references :singer, index: false, foreign_key: true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
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 "albums", id: { limit: 8 }, force: :cascade do |t|
|
|
17
|
+
t.string "title"
|
|
18
|
+
t.integer "singer_id", limit: 8
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
create_table "singers", id: { limit: 8 }, force: :cascade do |t|
|
|
22
|
+
t.string "first_name"
|
|
23
|
+
t.string "last_name"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
add_foreign_key "albums", "singers"
|
|
27
|
+
connection.run_batch
|
|
28
|
+
rescue
|
|
29
|
+
abort_batch
|
|
30
|
+
raise
|
|
31
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2023 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
|
|
7
|
+
require_relative "../../config/environment.rb"
|
|
8
|
+
require_relative "../models/singer"
|
|
9
|
+
require_relative "../models/album"
|
|
10
|
+
|
|
11
|
+
first_names = ["Pete", "Alice", "John", "Ethel", "Trudy", "Naomi", "Wendy", "Ruben", "Thomas", "Elly"]
|
|
12
|
+
last_names = ["Wendelson", "Allison", "Peterson", "Johnson", "Henderson", "Ericsson", "Aronson", "Tennet", "Courtou"]
|
|
13
|
+
|
|
14
|
+
adjectives = ["daily", "happy", "blue", "generous", "cooked", "bad", "open"]
|
|
15
|
+
nouns = ["windows", "potatoes", "bank", "street", "tree", "glass", "bottle"]
|
|
16
|
+
|
|
17
|
+
5.times do
|
|
18
|
+
Singer.create first_name: first_names.sample, last_name: last_names.sample
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
20.times do
|
|
22
|
+
singer_id = Singer.all.sample.id
|
|
23
|
+
Album.create title: "#{adjectives.sample} #{nouns.sample}", singer_id: singer_id
|
|
24
|
+
end
|
|
@@ -34,6 +34,10 @@ module ActiveRecord
|
|
|
34
34
|
selector = Google::Cloud::Spanner::Session.single_use_transaction staleness_hint.value
|
|
35
35
|
binds.delete staleness_hint
|
|
36
36
|
end
|
|
37
|
+
request_options = binds.find { |b| b.is_a? Google::Cloud::Spanner::V1::RequestOptions }
|
|
38
|
+
if request_options
|
|
39
|
+
binds.delete request_options
|
|
40
|
+
end
|
|
37
41
|
|
|
38
42
|
log_args = [sql, name]
|
|
39
43
|
log_args.concat [binds, type_casted_binds(binds)] if log_statement_binds
|
|
@@ -43,10 +47,11 @@ module ActiveRecord
|
|
|
43
47
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
|
44
48
|
if transaction_required
|
|
45
49
|
transaction do
|
|
46
|
-
@connection.execute_query sql, params: params, types: types
|
|
50
|
+
@connection.execute_query sql, params: params, types: types, request_options: request_options
|
|
47
51
|
end
|
|
48
52
|
else
|
|
49
|
-
@connection.execute_query sql, params: params, types: types, single_use_selector: selector
|
|
53
|
+
@connection.execute_query sql, params: params, types: types, single_use_selector: selector,
|
|
54
|
+
request_options: request_options
|
|
50
55
|
end
|
|
51
56
|
end
|
|
52
57
|
end
|
|
@@ -200,7 +200,7 @@ module ActiveRecordSpannerAdapter
|
|
|
200
200
|
|
|
201
201
|
# DQL, DML Statements
|
|
202
202
|
|
|
203
|
-
def execute_query sql, params: nil, types: nil, single_use_selector: nil
|
|
203
|
+
def execute_query sql, params: nil, types: nil, single_use_selector: nil, request_options: nil
|
|
204
204
|
if params
|
|
205
205
|
converted_params, types = \
|
|
206
206
|
Google::Cloud::Spanner::Convert.to_input_params_and_types(
|
|
@@ -214,15 +214,16 @@ module ActiveRecordSpannerAdapter
|
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
selector = transaction_selector || single_use_selector
|
|
217
|
-
execute_sql_request sql, converted_params, types, selector
|
|
217
|
+
execute_sql_request sql, converted_params, types, selector, request_options
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
-
def execute_sql_request sql, converted_params, types, selector
|
|
220
|
+
def execute_sql_request sql, converted_params, types, selector, request_options = nil
|
|
221
221
|
res = session.execute_query \
|
|
222
222
|
sql,
|
|
223
223
|
params: converted_params,
|
|
224
224
|
types: types,
|
|
225
225
|
transaction: selector,
|
|
226
|
+
request_options: request_options,
|
|
226
227
|
seqno: (current_transaction&.next_sequence_number)
|
|
227
228
|
current_transaction.grpc_transaction = res.metadata.transaction \
|
|
228
229
|
if current_transaction && res&.metadata&.transaction
|
|
@@ -36,6 +36,7 @@ module Arel # :nodoc: all
|
|
|
36
36
|
|
|
37
37
|
if binds
|
|
38
38
|
binds << collector.hints[:staleness] if collector.hints[:staleness]
|
|
39
|
+
binds << collector.hints[:request_options] if collector.hints[:request_options]
|
|
39
40
|
[sql, binds]
|
|
40
41
|
else
|
|
41
42
|
sql
|
|
@@ -94,6 +95,26 @@ module Arel # :nodoc: all
|
|
|
94
95
|
collector
|
|
95
96
|
end
|
|
96
97
|
|
|
98
|
+
def visit_Arel_Nodes_Comment o, collector
|
|
99
|
+
o.values.each do |v|
|
|
100
|
+
if v.start_with?("request_tag:") || v.start_with?("transaction_tag:")
|
|
101
|
+
collector.hints[:request_options] ||= \
|
|
102
|
+
Google::Cloud::Spanner::V1::RequestOptions.new
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if v.start_with? "request_tag:"
|
|
106
|
+
collector.hints[:request_options].request_tag = v.delete_prefix("request_tag:").strip
|
|
107
|
+
next
|
|
108
|
+
end
|
|
109
|
+
if v.start_with? "transaction_tag:"
|
|
110
|
+
collector.hints[:request_options].transaction_tag = v.delete_prefix("transaction_tag:").strip
|
|
111
|
+
next
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
# Also include the annotations as comments by calling the super implementation.
|
|
115
|
+
super
|
|
116
|
+
end
|
|
117
|
+
|
|
97
118
|
def visit_Arel_Table o, collector
|
|
98
119
|
return super unless collector.table_hints[o.name]
|
|
99
120
|
if o.table_alias
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-spanner-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Google LLC
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: google-cloud-spanner
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.
|
|
19
|
+
version: '2.18'
|
|
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: '2.
|
|
26
|
+
version: '2.18'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activerecord
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -478,6 +478,15 @@ files:
|
|
|
478
478
|
- examples/snippets/stale-reads/db/seeds.rb
|
|
479
479
|
- examples/snippets/stale-reads/models/album.rb
|
|
480
480
|
- examples/snippets/stale-reads/models/singer.rb
|
|
481
|
+
- examples/snippets/tags/README.md
|
|
482
|
+
- examples/snippets/tags/Rakefile
|
|
483
|
+
- examples/snippets/tags/application.rb
|
|
484
|
+
- examples/snippets/tags/config/database.yml
|
|
485
|
+
- examples/snippets/tags/db/migrate/01_create_tables.rb
|
|
486
|
+
- examples/snippets/tags/db/schema.rb
|
|
487
|
+
- examples/snippets/tags/db/seeds.rb
|
|
488
|
+
- examples/snippets/tags/models/album.rb
|
|
489
|
+
- examples/snippets/tags/models/singer.rb
|
|
481
490
|
- examples/snippets/timestamp-data-type/README.md
|
|
482
491
|
- examples/snippets/timestamp-data-type/Rakefile
|
|
483
492
|
- examples/snippets/timestamp-data-type/application.rb
|
|
@@ -532,7 +541,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
532
541
|
requirements:
|
|
533
542
|
- - ">="
|
|
534
543
|
- !ruby/object:Gem::Version
|
|
535
|
-
version: '2.
|
|
544
|
+
version: '2.7'
|
|
536
545
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
537
546
|
requirements:
|
|
538
547
|
- - ">="
|