activerecord-spanner-adapter 1.4.4 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1a935693a8621d55fd7f51a17ba93dcc598f97789e6b7825ca7c916fbc0c9e1
4
- data.tar.gz: 671717a9df5b2d7b6bbf388faea2c9ec6f982906a6456271a8696c2980d62684
3
+ metadata.gz: 73df0f7ee319edb7461b0fa60f8f8b611b38d798de2c0caf20a9c7d6796a7a85
4
+ data.tar.gz: 9dedd540069c5bc85d458008c20e48b9b550a75388a1f4d48b1b29b34bb689d4
5
5
  SHA512:
6
- metadata.gz: 5fa701ba551c2072ad60e6a7aadde8a4c4e20e3262d091c4854fd37d3663cfa353595017a8de229404c37dc7145ef5852c4ac16f531655c54462e419b217d86b
7
- data.tar.gz: 24733bae08d92cd3ad8c7ae4cbbdbf016dc845f3f8b1a962bdde535b8df2627c9dc8a62d4d41cad3ec58a295c22de9ccb01924f95c985d1bf6741d647a0fcf4d
6
+ metadata.gz: faac93588f6e703f183a773caf553d61b64370439093ac27a7d1a4893f6d887c887fbf1be9082baf78bb81e2c23b24f45a1e4053672e386595ff95c0980a0c4b
7
+ data.tar.gz: 4d6061c3daf7760d3015a33b52a41354f6bafa21b594a0c2b44852ae928935e1b2e23421ce417de2e65eecdc56de0890d97d0321e07fd3a3c3c104cf56856c88
@@ -18,7 +18,7 @@ jobs:
18
18
  strategy:
19
19
  max-parallel: 4
20
20
  matrix:
21
- ruby: ["2.6", "2.7", "3.0", "3.1", "3.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@v3
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@v3
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):
@@ -10,7 +10,7 @@ jobs:
10
10
  strategy:
11
11
  max-parallel: 4
12
12
  matrix:
13
- ruby: ["2.6", "2.7", "3.0", "3.1", "3.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@v3
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.6, 2.7, 3.0, 3.1, 3.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@v3
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@v3
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.6, 2.7, 3.0, 3.1, 3.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@v3
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@v3
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@v3
27
+ uses: actions/setup-node@v4
28
28
  with:
29
29
  node-version: "16.x"
30
30
  - name: Install tools
@@ -12,7 +12,7 @@ jobs:
12
12
  timeout-minutes: 10
13
13
 
14
14
  steps:
15
- - uses: actions/checkout@v3
15
+ - uses: actions/checkout@v4
16
16
  - name: setup ruby
17
17
  uses: ruby/setup-ruby@v1
18
18
  with:
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.4.4"
2
+ ".": "1.5.1"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.5.1 (2023-12-12)
4
+
5
+ #### Bug Fixes
6
+
7
+ * more permissive arg passthrough for insert_all and upsert_all ([#283](https://github.com/googleapis/ruby-spanner-activerecord/issues/283))
8
+
9
+ ### 1.5.0 (2023-11-03)
10
+
11
+ #### Features
12
+
13
+ * Drop support for Ruby 2.6 ([#270](https://github.com/googleapis/ruby-spanner-activerecord/issues/270))
14
+ * translate annotate to tags ([#267](https://github.com/googleapis/ruby-spanner-activerecord/issues/267))
15
+ #### Documentation
16
+
17
+ * update README to reference PGAdapter for PG ([#263](https://github.com/googleapis/ruby-spanner-activerecord/issues/263))
18
+ * 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))
19
+
3
20
  ### 1.4.4 (2023-09-06)
4
21
 
5
22
  #### Bug Fixes
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "activerecord", ENV.fetch("AR_VERSION", "~> 6.1.6.1")
7
- gem "minitest", "~> 5.18.0"
7
+ gem "minitest", "~> 5.19.0"
8
8
  gem "pry", "~> 0.13.0"
9
9
  gem "pry-byebug", "~> 3.9.0"
10
10
 
data/README.md CHANGED
@@ -5,12 +5,14 @@
5
5
  ![rubocop](https://github.com/googleapis/ruby-spanner-activerecord/workflows/rubocop/badge.svg)
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.6 and 2.7.
13
- - ActiveRecord 6.1.x with Ruby 2.6 and higher.
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.
@@ -33,6 +33,12 @@ module ActiveRecord
33
33
  assert_raise(NotImplementedError) { Author.insert_all(values) }
34
34
  end
35
35
 
36
+ def test_insert
37
+ value = { id: Author.next_sequence_value, name: "Alice" }
38
+
39
+ assert_raise(NotImplementedError) { Author.insert(value) }
40
+ end
41
+
36
42
  def test_insert_all!
37
43
  values = [
38
44
  { id: Author.next_sequence_value, name: "Alice" },
@@ -85,6 +91,22 @@ module ActiveRecord
85
91
  assert_equal "Carol", authors[2].name
86
92
  end
87
93
 
94
+ def test_upsert
95
+ Author.create id: 1, name: "David"
96
+ authors = Author.all.order(:name)
97
+ assert_equal 1, authors.length
98
+ assert_equal "David", authors[0].name
99
+
100
+ value = { id: 1, name: "Alice" }
101
+
102
+ Author.upsert(value)
103
+
104
+ authors = Author.all.order(:name)
105
+
106
+ assert_equal 1, authors.length
107
+ assert_equal "Alice", authors[0].name
108
+ end
109
+
88
110
  def test_upsert_all
89
111
  Author.create id: 1, name: "David"
90
112
  authors = Author.all.order(:name)
@@ -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.5"
25
+ spec.required_ruby_version = ">= 2.7"
26
26
 
27
- spec.add_dependency "google-cloud-spanner", "~> 2.10"
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,8 @@
1
+ development:
2
+ adapter: spanner
3
+ emulator_host: localhost:9010
4
+ project: test-project
5
+ instance: test-instance
6
+ database: testdb
7
+ pool: 5
8
+ timeout: 5000
@@ -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
@@ -0,0 +1,9 @@
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 Album < ActiveRecord::Base
8
+ belongs_to :singer
9
+ end
@@ -0,0 +1,9 @@
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 Singer < ActiveRecord::Base
8
+ has_many :albums
9
+ 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
@@ -67,11 +67,11 @@ module ActiveRecord
67
67
  _buffer_record values, :insert_or_update
68
68
  end
69
69
 
70
- def self.insert_all _attributes, _returning: nil, _unique_by: nil
71
- raise NotImplementedError, "Cloud Spanner does not support skip_duplicates."
70
+ def self.insert_all _attributes, **_kwargs
71
+ raise NotImplementedError, "Cloud Spanner does not support skip_duplicates. Use insert! or upsert instead."
72
72
  end
73
73
 
74
- def self.insert_all! attributes, returning: nil
74
+ def self.insert_all! attributes, **_kwargs
75
75
  return super unless spanner_adapter?
76
76
  return super if active_transaction? && !buffered_mutations?
77
77
 
@@ -90,7 +90,7 @@ module ActiveRecord
90
90
  end
91
91
  end
92
92
 
93
- def self.upsert_all attributes, returning: nil, unique_by: nil
93
+ def self.upsert_all attributes, **_kwargs
94
94
  return super unless spanner_adapter?
95
95
  if active_transaction? && !buffered_mutations?
96
96
  raise NotImplementedError, "Cloud Spanner does not support upsert using DML. " \
@@ -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
@@ -5,5 +5,5 @@
5
5
  # https://opensource.org/licenses/MIT.
6
6
 
7
7
  module ActiveRecordSpannerAdapter
8
- VERSION = "1.4.4".freeze
8
+ VERSION = "1.5.1".freeze
9
9
  end
@@ -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.4
4
+ version: 1.5.1
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-09-06 00:00:00.000000000 Z
11
+ date: 2023-12-13 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.10'
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.10'
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.5'
544
+ version: '2.7'
536
545
  required_rubygems_version: !ruby/object:Gem::Requirement
537
546
  requirements:
538
547
  - - ">="