activerecord-spanner-adapter 0.7.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/blunderbuss.yml +2 -0
- data/.github/sync-repo-settings.yaml +1 -1
- data/.github/workflows/acceptance-tests-on-emulator.yaml +8 -6
- data/.github/workflows/acceptance-tests-on-production.yaml +3 -3
- data/.github/workflows/ci.yaml +8 -6
- data/.github/workflows/nightly-acceptance-tests-on-emulator.yaml +9 -5
- data/.github/workflows/nightly-acceptance-tests-on-production.yaml +2 -2
- data/.github/workflows/nightly-unit-tests.yaml +9 -5
- data/.github/workflows/release-please-label.yml +4 -4
- data/.github/workflows/release-please.yml +12 -11
- data/.github/workflows/rubocop.yaml +4 -4
- data/.release-please-manifest.json +3 -0
- data/CHANGELOG.md +48 -26
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +2 -1
- data/README.md +3 -3
- data/acceptance/cases/models/insert_all_test.rb +150 -0
- data/acceptance/cases/type/all_types_test.rb +24 -25
- data/acceptance/cases/type/json_test.rb +0 -2
- data/acceptance/schema/schema.rb +2 -4
- data/acceptance/test_helper.rb +1 -1
- data/activerecord-spanner-adapter.gemspec +1 -1
- data/examples/rails/README.md +8 -8
- data/lib/active_record/connection_adapters/spanner/schema_creation.rb +10 -4
- data/lib/active_record/connection_adapters/spanner_adapter.rb +64 -31
- data/lib/active_record/type/spanner/array.rb +19 -5
- data/lib/activerecord_spanner_adapter/base.rb +72 -5
- data/lib/activerecord_spanner_adapter/connection.rb +46 -20
- data/lib/activerecord_spanner_adapter/information_schema.rb +2 -1
- data/lib/activerecord_spanner_adapter/transaction.rb +52 -21
- data/lib/activerecord_spanner_adapter/version.rb +1 -1
- data/lib/arel/visitors/spanner.rb +10 -0
- data/lib/spanner_client_ext.rb +4 -0
- data/release-please-config.json +19 -0
- metadata +17 -17
- data/examples/snippets/interleaved-tables/README.md +0 -152
- data/examples/snippets/interleaved-tables/Rakefile +0 -13
- data/examples/snippets/interleaved-tables/application.rb +0 -109
- data/examples/snippets/interleaved-tables/config/database.yml +0 -8
- data/examples/snippets/interleaved-tables/db/migrate/01_create_tables.rb +0 -44
- data/examples/snippets/interleaved-tables/db/schema.rb +0 -32
- data/examples/snippets/interleaved-tables/db/seeds.rb +0 -40
- data/examples/snippets/interleaved-tables/models/album.rb +0 -15
- data/examples/snippets/interleaved-tables/models/singer.rb +0 -20
- data/examples/snippets/interleaved-tables/models/track.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2ada6b62b88752f24052c1071bb3df30e1057e711045d26ecf1403b891d5b7
|
4
|
+
data.tar.gz: 831ec65b5bb4b25ce13970213a5f626e327d9ab6972f86f21076363218fc3ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 781bb93f7a9d505864b7b242088b51921df1386c4859e112057bd8b1d3c7bcbee1e3f941af2bcf99324537c136b667464c6328630aa6bd7a769fb9ee52ace690
|
7
|
+
data.tar.gz: 485369ec08bd2d3dac01edb57425dd003cace09581bf01fd4d7300a1d4142bc8a701a4d83f18b56c740c7b52f9d2c58d7af0eb3683bafb3e4e81afc59e2e2dc5
|
@@ -1,7 +1,7 @@
|
|
1
1
|
on:
|
2
2
|
push:
|
3
3
|
branches:
|
4
|
-
-
|
4
|
+
- main
|
5
5
|
pull_request:
|
6
6
|
name: acceptance tests on emulator
|
7
7
|
jobs:
|
@@ -19,13 +19,17 @@ jobs:
|
|
19
19
|
max-parallel: 4
|
20
20
|
matrix:
|
21
21
|
ruby: [2.6, 2.7, 3.0]
|
22
|
-
ar: [6.0.4, 6.1.4]
|
23
|
-
# Exclude
|
22
|
+
ar: [6.0.4, 6.1.4, 7.0.2.4]
|
23
|
+
# Exclude combinations that are not supported.
|
24
24
|
exclude:
|
25
25
|
- ruby: 3.0
|
26
26
|
ar: 6.0.4
|
27
|
+
- ruby: 2.6
|
28
|
+
ar: 7.0.2.4
|
29
|
+
env:
|
30
|
+
AR_VERSION: ${{ matrix.ar }}
|
27
31
|
steps:
|
28
|
-
- uses: actions/checkout@
|
32
|
+
- uses: actions/checkout@v3
|
29
33
|
- name: Set up Ruby
|
30
34
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
|
31
35
|
# (see https://github.com/ruby/setup-ruby#versioning):
|
@@ -33,8 +37,6 @@ jobs:
|
|
33
37
|
with:
|
34
38
|
bundler-cache: false
|
35
39
|
ruby-version: ${{ matrix.ruby }}
|
36
|
-
- name: Set ActiveRecord version
|
37
|
-
run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
|
38
40
|
- name: Install dependencies
|
39
41
|
run: bundle install
|
40
42
|
- name: Run acceptance tests on emulator
|
@@ -1,7 +1,7 @@
|
|
1
1
|
on:
|
2
2
|
push:
|
3
3
|
branches:
|
4
|
-
-
|
4
|
+
- main
|
5
5
|
pull_request:
|
6
6
|
name: acceptance tests on production
|
7
7
|
jobs:
|
@@ -26,7 +26,7 @@ jobs:
|
|
26
26
|
matrix:
|
27
27
|
ruby: [3.0]
|
28
28
|
steps:
|
29
|
-
- uses: actions/checkout@
|
29
|
+
- uses: actions/checkout@v3
|
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):
|
@@ -35,7 +35,7 @@ jobs:
|
|
35
35
|
bundler-cache: true
|
36
36
|
ruby-version: ${{ matrix.ruby }}
|
37
37
|
- name: Setup GCloud
|
38
|
-
uses: google-github-actions/setup-gcloud@
|
38
|
+
uses: google-github-actions/setup-gcloud@v0
|
39
39
|
with:
|
40
40
|
project_id: ${{ secrets.GCP_PROJECT_ID }}
|
41
41
|
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
data/.github/workflows/ci.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
on:
|
2
2
|
push:
|
3
3
|
branches:
|
4
|
-
-
|
4
|
+
- main
|
5
5
|
pull_request:
|
6
6
|
name: ci
|
7
7
|
jobs:
|
@@ -11,13 +11,17 @@ jobs:
|
|
11
11
|
max-parallel: 4
|
12
12
|
matrix:
|
13
13
|
ruby: [2.6, 2.7, 3.0]
|
14
|
-
ar: [6.0.4, 6.1.4]
|
15
|
-
# Exclude
|
14
|
+
ar: [6.0.4, 6.1.4, 7.0.2.4]
|
15
|
+
# Exclude combinations that are not supported.
|
16
16
|
exclude:
|
17
17
|
- ruby: 3.0
|
18
18
|
ar: 6.0.4
|
19
|
+
- ruby: 2.6
|
20
|
+
ar: 7.0.2.4
|
21
|
+
env:
|
22
|
+
AR_VERSION: ${{ matrix.ar }}
|
19
23
|
steps:
|
20
|
-
- uses: actions/checkout@
|
24
|
+
- uses: actions/checkout@v3
|
21
25
|
- name: Set up Ruby
|
22
26
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
|
23
27
|
# (see https://github.com/ruby/setup-ruby#versioning):
|
@@ -25,8 +29,6 @@ jobs:
|
|
25
29
|
with:
|
26
30
|
bundler-cache: false
|
27
31
|
ruby-version: ${{ matrix.ruby }}
|
28
|
-
- name: Set ActiveRecord version
|
29
|
-
run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
|
30
32
|
- name: Install dependencies
|
31
33
|
run: bundle install
|
32
34
|
- name: Run tests
|
@@ -19,8 +19,8 @@ jobs:
|
|
19
19
|
matrix:
|
20
20
|
# Run acceptance tests all supported combinations of Ruby and ActiveRecord.
|
21
21
|
ruby: [2.5, 2.6, 2.7, 3.0]
|
22
|
-
ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.0, 6.1.1, 6.1.2.1, 6.1.3.2, 6.1.4]
|
23
|
-
# Exclude
|
22
|
+
ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.0, 6.1.1, 6.1.2.1, 6.1.3.2, 6.1.4, 7.0.2.4]
|
23
|
+
# Exclude combinations that are not supported.
|
24
24
|
exclude:
|
25
25
|
- ruby: 3.0
|
26
26
|
ar: 6.0.0
|
@@ -32,16 +32,20 @@ jobs:
|
|
32
32
|
ar: 6.0.3.7
|
33
33
|
- ruby: 3.0
|
34
34
|
ar: 6.0.4
|
35
|
+
- ruby: 2.5
|
36
|
+
ar: 7.0.2.4
|
37
|
+
- ruby: 2.6
|
38
|
+
ar: 7.0.2.4
|
39
|
+
env:
|
40
|
+
AR_VERSION: ${{ matrix.ar }}
|
35
41
|
steps:
|
36
|
-
- uses: actions/checkout@
|
42
|
+
- uses: actions/checkout@v3
|
37
43
|
- name: Set up Ruby
|
38
44
|
uses: ruby/setup-ruby@v1
|
39
45
|
with:
|
40
46
|
# Disable caching as we are overriding the ActiveRecord below.
|
41
47
|
bundler-cache: false
|
42
48
|
ruby-version: ${{ matrix.ruby }}
|
43
|
-
- name: Set ActiveRecord version
|
44
|
-
run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
|
45
49
|
- name: Install dependencies
|
46
50
|
run: bundle install
|
47
51
|
- name: Run acceptance tests on emulator
|
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
matrix:
|
13
13
|
ruby: [3.0]
|
14
14
|
steps:
|
15
|
-
- uses: actions/checkout@
|
15
|
+
- uses: actions/checkout@v3
|
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):
|
@@ -21,7 +21,7 @@ jobs:
|
|
21
21
|
bundler-cache: true
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
23
23
|
- name: Setup GCloud
|
24
|
-
uses: google-github-actions/setup-gcloud@
|
24
|
+
uses: google-github-actions/setup-gcloud@v0
|
25
25
|
with:
|
26
26
|
project_id: ${{ secrets.GCP_PROJECT_ID }}
|
27
27
|
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
@@ -11,8 +11,8 @@ jobs:
|
|
11
11
|
matrix:
|
12
12
|
# Run unit tests all supported combinations of Ruby and ActiveRecord.
|
13
13
|
ruby: [2.5, 2.6, 2.7, 3.0]
|
14
|
-
ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.0, 6.1.1, 6.1.2.1, 6.1.3.2, 6.1.4]
|
15
|
-
# Exclude
|
14
|
+
ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.0, 6.1.1, 6.1.2.1, 6.1.3.2, 6.1.4, 7.0.2.4]
|
15
|
+
# Exclude combinations that are not supported.
|
16
16
|
exclude:
|
17
17
|
- ruby: 3.0
|
18
18
|
ar: 6.0.0
|
@@ -24,16 +24,20 @@ jobs:
|
|
24
24
|
ar: 6.0.3.7
|
25
25
|
- ruby: 3.0
|
26
26
|
ar: 6.0.4
|
27
|
+
- ruby: 2.5
|
28
|
+
ar: 7.0.2.4
|
29
|
+
- ruby: 2.6
|
30
|
+
ar: 7.0.2.4
|
31
|
+
env:
|
32
|
+
AR_VERSION: ${{ matrix.ar }}
|
27
33
|
steps:
|
28
|
-
- uses: actions/checkout@
|
34
|
+
- uses: actions/checkout@v3
|
29
35
|
- name: Set up Ruby
|
30
36
|
uses: ruby/setup-ruby@v1
|
31
37
|
with:
|
32
38
|
# Disable caching as we are overriding the ActiveRecord below.
|
33
39
|
bundler-cache: false
|
34
40
|
ruby-version: ${{ matrix.ruby }}
|
35
|
-
- name: Set ActiveRecord version
|
36
|
-
run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
|
37
41
|
- name: Install dependencies
|
38
42
|
run: bundle install
|
39
43
|
- name: Run tests
|
@@ -2,21 +2,21 @@ name: release-please-label
|
|
2
2
|
on:
|
3
3
|
pull_request_target:
|
4
4
|
branches:
|
5
|
-
-
|
5
|
+
- main
|
6
6
|
types:
|
7
7
|
- opened
|
8
8
|
jobs:
|
9
9
|
release-please-label:
|
10
|
-
if: "${{ github.event.sender.login == 'yoshi-code-bot' && startsWith(github.event.pull_request.title, 'chore: release ') }}"
|
10
|
+
if: "${{ github.event.sender.login == 'yoshi-code-bot' && startsWith(github.event.pull_request.title, 'chore(main): release ') }}"
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
steps:
|
13
13
|
- name: ReleaseLabel
|
14
|
-
uses: actions/github-script@
|
14
|
+
uses: actions/github-script@v6
|
15
15
|
with:
|
16
16
|
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
|
17
17
|
script: |
|
18
18
|
core.info('Labeling release');
|
19
|
-
await github.issues.addLabels({
|
19
|
+
await github.rest.issues.addLabels({
|
20
20
|
owner: context.repo.owner,
|
21
21
|
repo: context.repo.repo,
|
22
22
|
issue_number: context.payload.pull_request.number,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
name: Release-Please
|
2
2
|
on:
|
3
3
|
schedule:
|
4
|
-
- cron: '
|
4
|
+
- cron: '57 10 * * *'
|
5
5
|
workflow_dispatch:
|
6
6
|
inputs:
|
7
7
|
gem:
|
@@ -20,20 +20,21 @@ jobs:
|
|
20
20
|
RELEASE_PLEASE_DISABLE: ${{ secrets.RELEASE_PLEASE_DISABLE }}
|
21
21
|
steps:
|
22
22
|
- name: Checkout repo
|
23
|
-
uses: actions/checkout@
|
24
|
-
- name: Install Ruby
|
23
|
+
uses: actions/checkout@v3
|
24
|
+
- name: Install Ruby 3.0
|
25
25
|
uses: ruby/setup-ruby@v1
|
26
26
|
with:
|
27
|
-
ruby-version: "
|
28
|
-
- name: Install NodeJS
|
29
|
-
uses: actions/setup-node@
|
27
|
+
ruby-version: "3.0"
|
28
|
+
- name: Install NodeJS 16.x
|
29
|
+
uses: actions/setup-node@v3
|
30
30
|
with:
|
31
|
-
node-version: "
|
31
|
+
node-version: "16.x"
|
32
32
|
- name: Install tools
|
33
|
-
run: "gem install --no-document toys
|
33
|
+
run: "gem install --no-document toys"
|
34
34
|
- name: execute
|
35
35
|
run: |
|
36
|
-
toys release
|
36
|
+
toys release manifest -v \
|
37
|
+
--fork --skip-labeling \
|
37
38
|
--github-event-name=${{ github.event_name }} \
|
38
|
-
|
39
|
-
|
39
|
+
${{ github.event.inputs.args }} \
|
40
|
+
-- ${{ github.event.inputs.gem }}
|
@@ -4,7 +4,7 @@ on:
|
|
4
4
|
pull_request:
|
5
5
|
types: [opened, synchronize]
|
6
6
|
push:
|
7
|
-
branches: [
|
7
|
+
branches: [ main ]
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
build:
|
@@ -12,13 +12,13 @@ jobs:
|
|
12
12
|
timeout-minutes: 10
|
13
13
|
|
14
14
|
steps:
|
15
|
-
- uses: actions/checkout@
|
15
|
+
- uses: actions/checkout@v3
|
16
16
|
- name: setup ruby
|
17
17
|
uses: ruby/setup-ruby@v1
|
18
18
|
with:
|
19
|
-
ruby-version: '2.
|
19
|
+
ruby-version: '2.7'
|
20
20
|
- name: cache gems
|
21
|
-
uses: actions/cache@
|
21
|
+
uses: actions/cache@v3
|
22
22
|
with:
|
23
23
|
path: vendor/bundle
|
24
24
|
key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
|
data/CHANGELOG.md
CHANGED
@@ -1,42 +1,64 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
### 1.1.0 (2022-06-24)
|
4
4
|
|
5
|
+
#### Features
|
5
6
|
|
6
|
-
|
7
|
+
* Support insert_all and upsert_all with DML and mutations
|
7
8
|
|
8
|
-
|
9
|
+
### 1.0.1 (2022-04-21)
|
9
10
|
|
10
|
-
|
11
|
+
#### Bug Fixes
|
11
12
|
|
13
|
+
* ActiveRecord::Type::Spanner::Array does not use element type
|
12
14
|
|
13
|
-
|
15
|
+
#### Documentation
|
14
16
|
|
15
|
-
*
|
16
|
-
*
|
17
|
-
* support stale reads in read-only transactions ([#126](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/126)) ([8bf7730](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/8bf77300283c01e951725dd5e457270db20e98d2))
|
17
|
+
* add limitation of interleaved tables
|
18
|
+
* fix a couple of minor formatting issues
|
18
19
|
|
19
|
-
|
20
|
+
### 1.0.0 (2021-12-07)
|
20
21
|
|
22
|
+
* GA release
|
21
23
|
|
22
|
-
###
|
24
|
+
### 0.7.1 (2021-11-21)
|
23
25
|
|
24
|
-
|
25
|
-
* Add support for ARRAY data type ([#86](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/86)) ([0c66a62](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/0c66a620cab968779de04faf48e03eec643ebea9))
|
26
|
-
* google-cloud-spanner version upgraded to 2.2 ([#55](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/55)) ([d7581d6](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/d7581d60bd9a9e7b9989565449119f73e2caa694))
|
27
|
-
* Support interleaved tables ([#83](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/83)) ([82265f9](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/82265f94ace79964639a2c65554714752be39724))
|
28
|
-
* retry session not found ([#81](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/81)) ([88fd3b7](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/88fd3b70a03a90de2b667bb0f2e86efe5dc9328b))
|
29
|
-
* support and test multiple ActiveRecord versions ([#107](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/107)) ([db9d96c](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/db9d96c44b9560f6904209df1a9aa42bf50a5844))
|
30
|
-
* support DDL batches on connection ([#72](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/72)) ([0d18cd4](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/0d18cd49641bdb567012d6ac88b1909461d42551))
|
31
|
-
* support generated columns ([#94](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/94)) ([68664eb](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/68664eb5c617abc2954dea274430f416e616a324))
|
32
|
-
* support interleaved indexes + test other index features ([#101](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/101)) ([812e0f7](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/812e0f7f60b36ec26a974f6fb48266de5d840652))
|
33
|
-
* support optimistic locking ([#92](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/92)) ([9eb71d8](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/9eb71d8a207a8df0406241bff5780593eb0afd34))
|
34
|
-
* support PDML transactions ([#106](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/106)) ([fa0599a](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/fa0599afe986a184bb6ab26340305eeaa753dafa))
|
35
|
-
* support prepared statements and query cache ([#74](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/74)) ([fed8258](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/fed825862c95e3e052410e3576de18fc3b7849b7))
|
36
|
-
* support read only transactions ([#80](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/80)) ([2d6097b](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/2d6097bd8f4530634a41dcdbcbb3a02614f482b8))
|
37
|
-
* support setting attributes to commit timestamp ([#89](https://www.github.com/googleapis/ruby-spanner-activerecord/issues/89)) ([cdd8448](https://www.github.com/googleapis/ruby-spanner-activerecord/commit/cdd844852da92fa4e2c43fd06eeef31310d6ff8a))
|
26
|
+
#### Performance Improvements
|
38
27
|
|
28
|
+
* inline BeginTransaction with first statement in the transaction
|
39
29
|
|
40
|
-
###
|
30
|
+
### 0.7.0 (2021-10-03)
|
41
31
|
|
42
|
-
|
32
|
+
#### Features
|
33
|
+
|
34
|
+
* add support for query hints
|
35
|
+
|
36
|
+
### 0.6.0 (2021-09-09)
|
37
|
+
|
38
|
+
#### Features
|
39
|
+
|
40
|
+
* support JSON data type
|
41
|
+
* support single stale reads
|
42
|
+
* support stale reads in read-only transactions
|
43
|
+
|
44
|
+
### 0.5.0 (2021-08-31)
|
45
|
+
|
46
|
+
#### Features
|
47
|
+
|
48
|
+
* Add support for NUMERIC type
|
49
|
+
* Add support for ARRAY data type
|
50
|
+
* google-cloud-spanner version upgraded to 2.2
|
51
|
+
* retry session not found
|
52
|
+
* support and test multiple ActiveRecord versions
|
53
|
+
* support DDL batches on connection
|
54
|
+
* support generated columns
|
55
|
+
* support interleaved indexes + test other index features
|
56
|
+
* support optimistic locking
|
57
|
+
* support PDML transactions
|
58
|
+
* support prepared statements and query cache
|
59
|
+
* support read only transactions
|
60
|
+
* support setting attributes to commit timestamp
|
61
|
+
|
62
|
+
#### Performance Improvements
|
63
|
+
|
64
|
+
* add benchmarks
|
data/CONTRIBUTING.md
CHANGED
@@ -70,7 +70,7 @@ $ cd ruby-spanner-activerecord
|
|
70
70
|
$ bundle exec rubocop
|
71
71
|
```
|
72
72
|
|
73
|
-
The rubocop settings depend on [googleapis/ruby-style](https://github.com/googleapis/ruby-style/), in addition to [.rubocop.yml](https://github.com/googleapis/ruby-spanner-activerecord/blob/
|
73
|
+
The rubocop settings depend on [googleapis/ruby-style](https://github.com/googleapis/ruby-style/), in addition to [.rubocop.yml](https://github.com/googleapis/ruby-spanner-activerecord/blob/main/.rubocop.yml).
|
74
74
|
|
75
75
|
## Code of Conduct
|
76
76
|
|
data/Gemfile
CHANGED
@@ -3,7 +3,8 @@ source "https://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in activerecord-spanner.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "
|
6
|
+
gem "activerecord", ENV.fetch("AR_VERSION", "~> 6.1.4")
|
7
|
+
gem "minitest", "~> 5.15.0"
|
7
8
|
gem "pry", "~> 0.13.0"
|
8
9
|
gem "pry-byebug", "~> 3.9.0"
|
9
10
|
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
![rubocop](https://github.com/googleapis/ruby-spanner-activerecord/workflows/rubocop/badge.svg)
|
6
6
|
|
7
|
-
This project provides a Cloud Spanner adapter for ActiveRecord. It
|
7
|
+
This project provides a Cloud Spanner adapter for ActiveRecord. It supports the following versions:
|
8
8
|
|
9
9
|
- ActiveRecord 6.0.x with Ruby 2.6 and 2.7.
|
10
10
|
- ActiveRecord 6.1.x with Ruby 2.6 and higher.
|
@@ -69,13 +69,13 @@ Some noteworthy examples in the snippets directory:
|
|
69
69
|
- [mutations](examples/snippets/mutations): Shows how you can use [mutations instead of DML](https://cloud.google.com/spanner/docs/dml-versus-mutations)
|
70
70
|
for inserting, updating and deleting data in a Cloud Spanner database. Mutations can have a significant performance
|
71
71
|
advantage compared to DML statements, but do not allow read-your-writes semantics during a transaction.
|
72
|
-
- [interleaved-tables](examples/snippets/interleaved-tables): Shows how to create and work with a hierarchy of `INTERLEAVED IN` tables.
|
73
72
|
- [array-data-type](examples/snippets/array-data-type): Shows how to work with `ARRAY` data types.
|
74
73
|
|
75
74
|
## Limitations
|
76
75
|
|
77
76
|
Limitation|Comment|Resolution
|
78
77
|
---|---|---
|
78
|
+
Interleaved tables are not supported|Cloud Spanner requires to use composite primary keys for interleaved tables, but Active Record does not support composite primary keys. More details: [#160](https://github.com/googleapis/ruby-spanner-activerecord/issues/160) |Use non-interleaved tables.
|
79
79
|
Lack of DEFAULT for columns [change_column_default](https://apidock.com/rails/v5.2.3/ActiveRecord/ConnectionAdapters/SchemaStatements/change_column_default)|Cloud Spanner does not support DEFAULT values for columns. The use of default must be enforced in your controller logic| Always set a value in your model or controller logic.
|
80
80
|
Lack of sequential and auto-assigned IDs|Cloud Spanner doesn't autogenerate IDs and this integration instead creates UUID4 to avoid [hotspotting](https://cloud.google.com/spanner/docs/schema-design#uuid_primary_key) so you SHOULD NOT rely on IDs being sorted| UUID4s are automatically generated for primary keys.
|
81
81
|
Table without Primary Key| Cloud Spanner support does not support tables without a primary key.| Always define a primary key for your table.
|
@@ -93,4 +93,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
93
93
|
|
94
94
|
## Code of Conduct
|
95
95
|
|
96
|
-
Everyone interacting in the Activerecord::Spanner project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/googleapis/ruby-spanner-activerecord/blob/
|
96
|
+
Everyone interacting in the Activerecord::Spanner project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/googleapis/ruby-spanner-activerecord/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# Copyright 2022 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
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
require "test_helper"
|
10
|
+
require "models/author"
|
11
|
+
|
12
|
+
module ActiveRecord
|
13
|
+
module Model
|
14
|
+
class InsertAllTest < SpannerAdapter::TestCase
|
15
|
+
include SpannerAdapter::Associations::TestHelper
|
16
|
+
|
17
|
+
def setup
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
super
|
23
|
+
Author.destroy_all
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_insert_all
|
27
|
+
values = [
|
28
|
+
{ id: Author.next_sequence_value, name: "Alice" },
|
29
|
+
{ id: Author.next_sequence_value, name: "Bob" },
|
30
|
+
{ id: Author.next_sequence_value, name: "Carol" },
|
31
|
+
]
|
32
|
+
|
33
|
+
assert_raise(NotImplementedError) { Author.insert_all(values) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_insert_all!
|
37
|
+
values = [
|
38
|
+
{ id: Author.next_sequence_value, name: "Alice" },
|
39
|
+
{ id: Author.next_sequence_value, name: "Bob" },
|
40
|
+
{ id: Author.next_sequence_value, name: "Carol" },
|
41
|
+
]
|
42
|
+
|
43
|
+
Author.insert_all!(values)
|
44
|
+
|
45
|
+
authors = Author.all.order(:name)
|
46
|
+
|
47
|
+
assert_equal "Alice", authors[0].name
|
48
|
+
assert_equal "Bob", authors[1].name
|
49
|
+
assert_equal "Carol", authors[2].name
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_insert_all_with_transaction
|
53
|
+
values = [
|
54
|
+
{ id: Author.next_sequence_value, name: "Alice" },
|
55
|
+
{ id: Author.next_sequence_value, name: "Bob" },
|
56
|
+
{ id: Author.next_sequence_value, name: "Carol" },
|
57
|
+
]
|
58
|
+
|
59
|
+
ActiveRecord::Base.transaction do
|
60
|
+
Author.insert_all!(values)
|
61
|
+
end
|
62
|
+
|
63
|
+
authors = Author.all.order(:name)
|
64
|
+
|
65
|
+
assert_equal "Alice", authors[0].name
|
66
|
+
assert_equal "Bob", authors[1].name
|
67
|
+
assert_equal "Carol", authors[2].name
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_insert_all_with_buffered_mutation_transaction
|
71
|
+
values = [
|
72
|
+
{ id: Author.next_sequence_value, name: "Alice" },
|
73
|
+
{ id: Author.next_sequence_value, name: "Bob" },
|
74
|
+
{ id: Author.next_sequence_value, name: "Carol" },
|
75
|
+
]
|
76
|
+
|
77
|
+
ActiveRecord::Base.transaction isolation: :buffered_mutations do
|
78
|
+
Author.insert_all!(values)
|
79
|
+
end
|
80
|
+
|
81
|
+
authors = Author.all.order(:name)
|
82
|
+
|
83
|
+
assert_equal "Alice", authors[0].name
|
84
|
+
assert_equal "Bob", authors[1].name
|
85
|
+
assert_equal "Carol", authors[2].name
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_upsert_all
|
89
|
+
Author.create id: 1, name: "David"
|
90
|
+
authors = Author.all.order(:name)
|
91
|
+
assert_equal 1, authors.length
|
92
|
+
assert_equal "David", authors[0].name
|
93
|
+
|
94
|
+
values = [
|
95
|
+
{ id: 1, name: "Alice" },
|
96
|
+
{ id: 2, name: "Bob" },
|
97
|
+
{ id: 3, name: "Carol" },
|
98
|
+
]
|
99
|
+
|
100
|
+
Author.upsert_all(values)
|
101
|
+
|
102
|
+
authors = Author.all.order(:name)
|
103
|
+
|
104
|
+
assert_equal 3, authors.length
|
105
|
+
assert_equal "Alice", authors[0].name
|
106
|
+
assert_equal "Bob", authors[1].name
|
107
|
+
assert_equal "Carol", authors[2].name
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_upsert_all_with_transaction
|
111
|
+
values = [
|
112
|
+
{ id: Author.next_sequence_value, name: "Alice" },
|
113
|
+
{ id: Author.next_sequence_value, name: "Bob" },
|
114
|
+
{ id: Author.next_sequence_value, name: "Carol" },
|
115
|
+
]
|
116
|
+
|
117
|
+
err = assert_raise(NotImplementedError) do
|
118
|
+
ActiveRecord::Base.transaction do
|
119
|
+
Author.upsert_all(values)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
assert_match "Use upsert outside a transaction block", err.message
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_upsert_all_with_buffered_mutation_transaction
|
126
|
+
Author.create id: 1, name: "David"
|
127
|
+
authors = Author.all.order(:name)
|
128
|
+
assert_equal 1, authors.length
|
129
|
+
assert_equal "David", authors[0].name
|
130
|
+
|
131
|
+
values = [
|
132
|
+
{ id: 1, name: "Alice" },
|
133
|
+
{ id: 2, name: "Bob" },
|
134
|
+
{ id: 3, name: "Carol" },
|
135
|
+
]
|
136
|
+
|
137
|
+
ActiveRecord::Base.transaction isolation: :buffered_mutations do
|
138
|
+
Author.upsert_all(values)
|
139
|
+
end
|
140
|
+
|
141
|
+
authors = Author.all.order(:name)
|
142
|
+
|
143
|
+
assert_equal 3, authors.length
|
144
|
+
assert_equal "Alice", authors[0].name
|
145
|
+
assert_equal "Bob", authors[1].name
|
146
|
+
assert_equal "Carol", authors[2].name
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|