activerecord-spanner-adapter 1.6.3 → 2.0.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 +3 -7
- data/.github/workflows/acceptance-tests-on-production.yaml +1 -1
- data/.github/workflows/ci.yaml +3 -7
- data/.github/workflows/nightly-acceptance-tests-on-emulator.yaml +4 -33
- data/.github/workflows/nightly-acceptance-tests-on-production.yaml +1 -1
- data/.github/workflows/nightly-unit-tests.yaml +5 -33
- data/.github/workflows/rubocop.yaml +1 -1
- data/.github/workflows/samples.yaml +30 -0
- data/.kokoro/populate-secrets.sh +5 -1
- data/.kokoro/release.cfg +22 -12
- data/.kokoro/release.sh +1 -3
- data/.kokoro/trampoline_v2.sh +19 -11
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +2 -2
- data/.trampolinerc +6 -1
- data/CHANGELOG.md +37 -0
- data/Gemfile +7 -5
- data/README.md +11 -9
- data/Rakefile +2 -2
- data/acceptance/cases/migration/command_recorder_test.rb +7 -38
- data/acceptance/cases/migration/references_index_test.rb +2 -11
- data/acceptance/cases/migration/schema_dumper_test.rb +21 -9
- data/acceptance/cases/models/binary_identifiers.rb +97 -0
- data/acceptance/cases/models/insert_all_test.rb +22 -7
- data/acceptance/cases/sessions/session_not_found_test.rb +2 -0
- data/acceptance/cases/tasks/database_tasks_test.rb +1 -0
- 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 +6 -1
- data/activerecord-spanner-adapter.gemspec +3 -3
- data/benchmarks/application.rb +3 -7
- data/examples/snippets/Rakefile +27 -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/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 +3 -3
- data/lib/active_record/connection_adapters/spanner/database_statements.rb +37 -23
- data/lib/active_record/connection_adapters/spanner/quoting.rb +19 -6
- data/lib/active_record/connection_adapters/spanner/schema_creation.rb +7 -9
- data/lib/active_record/connection_adapters/spanner/schema_definitions.rb +12 -2
- data/lib/active_record/connection_adapters/spanner/schema_statements.rb +28 -46
- data/lib/active_record/connection_adapters/spanner/type_metadata.rb +4 -6
- data/lib/active_record/connection_adapters/spanner_adapter.rb +54 -27
- 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.rb +5 -1
- data/lib/activerecord_spanner_adapter/base.rb +58 -30
- 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 +1 -1
- data/lib/activerecord_spanner_adapter/primary_key.rb +2 -2
- data/lib/activerecord_spanner_adapter/table/column.rb +12 -3
- 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 +15 -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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df28341210b0da8f86475dc621e5c4113ad00a72b23fa6bc3e224a0064c7e267
|
|
4
|
+
data.tar.gz: 00eed36443cb2cd7c99869a6e2ff3821c16fd2a16a3d937dd831c3226743ef19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a53ee5f7ab4d576a969631ce6125557a6171f91dd372f71c03c34c62b67b9363e0898d4b8d7ff3836d58efd73fd2a71dbf108668c5e837634864e017d129b8ca
|
|
7
|
+
data.tar.gz: 665f4e837ee3dee167c2d5e4160dfe03fb3008903f3be50dbae50dd07fcea8b01b7b561b683c825c460a3462d0f729c5ace143c4285d9eb05b2871776086cd94
|
|
@@ -18,16 +18,12 @@ jobs:
|
|
|
18
18
|
strategy:
|
|
19
19
|
max-parallel: 4
|
|
20
20
|
matrix:
|
|
21
|
-
ruby: ["
|
|
22
|
-
ar: ["~>
|
|
21
|
+
ruby: ["3.1", "3.2", "3.3"]
|
|
22
|
+
ar: ["~> 7.0.0", "~> 7.1.0", "~> 7.2.0", "~> 8.0.0"]
|
|
23
23
|
# Exclude combinations that are not supported.
|
|
24
24
|
exclude:
|
|
25
|
-
- ruby: "3.0"
|
|
26
|
-
ar: "~> 6.0.6"
|
|
27
25
|
- ruby: "3.1"
|
|
28
|
-
ar: "~>
|
|
29
|
-
- ruby: "3.2"
|
|
30
|
-
ar: "~> 6.0.6"
|
|
26
|
+
ar: "~> 8.0.0"
|
|
31
27
|
env:
|
|
32
28
|
AR_VERSION: ${{ matrix.ar }}
|
|
33
29
|
steps:
|
data/.github/workflows/ci.yaml
CHANGED
|
@@ -10,16 +10,12 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
max-parallel: 4
|
|
12
12
|
matrix:
|
|
13
|
-
ruby: ["
|
|
14
|
-
ar: ["~>
|
|
13
|
+
ruby: ["3.1", "3.2", "3.3"]
|
|
14
|
+
ar: ["~> 7.0.0", "~> 7.1.0", "~> 7.2.0", "~> 8.0.0"]
|
|
15
15
|
# Exclude combinations that are not supported.
|
|
16
16
|
exclude:
|
|
17
|
-
- ruby: "3.0"
|
|
18
|
-
ar: "~> 6.0.6"
|
|
19
17
|
- ruby: "3.1"
|
|
20
|
-
ar: "~>
|
|
21
|
-
- ruby: "3.2"
|
|
22
|
-
ar: "~> 6.0.6"
|
|
18
|
+
ar: "~> 8.0.0"
|
|
23
19
|
env:
|
|
24
20
|
AR_VERSION: ${{ matrix.ar }}
|
|
25
21
|
steps:
|
|
@@ -18,41 +18,12 @@ jobs:
|
|
|
18
18
|
strategy:
|
|
19
19
|
max-parallel: 4
|
|
20
20
|
matrix:
|
|
21
|
-
|
|
22
|
-
|
|
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, 7.1.0, 7.1.1, 7.1.2]
|
|
21
|
+
ruby: ["3.1", "3.2", "3.3"]
|
|
22
|
+
ar: ["~> 7.0.0", "~> 7.1.0", "~> 7.2.0", "~> 8.0.0"]
|
|
24
23
|
# Exclude combinations that are not supported.
|
|
25
24
|
exclude:
|
|
26
|
-
- ruby: 3.
|
|
27
|
-
ar:
|
|
28
|
-
- ruby: 3.0
|
|
29
|
-
ar: 6.0.1
|
|
30
|
-
- ruby: 3.0
|
|
31
|
-
ar: 6.0.2.2
|
|
32
|
-
- ruby: 3.0
|
|
33
|
-
ar: 6.0.3.7
|
|
34
|
-
- ruby: 3.0
|
|
35
|
-
ar: 6.0.4
|
|
36
|
-
- ruby: 3.1
|
|
37
|
-
ar: 6.0.0
|
|
38
|
-
- ruby: 3.1
|
|
39
|
-
ar: 6.0.1
|
|
40
|
-
- ruby: 3.1
|
|
41
|
-
ar: 6.0.2.2
|
|
42
|
-
- ruby: 3.1
|
|
43
|
-
ar: 6.0.3.7
|
|
44
|
-
- ruby: 3.1
|
|
45
|
-
ar: 6.0.4
|
|
46
|
-
- ruby: 3.2
|
|
47
|
-
ar: 6.0.0
|
|
48
|
-
- ruby: 3.2
|
|
49
|
-
ar: 6.0.1
|
|
50
|
-
- ruby: 3.2
|
|
51
|
-
ar: 6.0.2.2
|
|
52
|
-
- ruby: 3.2
|
|
53
|
-
ar: 6.0.3.7
|
|
54
|
-
- ruby: 3.2
|
|
55
|
-
ar: 6.0.4
|
|
25
|
+
- ruby: "3.1"
|
|
26
|
+
ar: "~> 8.0.0"
|
|
56
27
|
env:
|
|
57
28
|
AR_VERSION: ${{ matrix.ar }}
|
|
58
29
|
steps:
|
|
@@ -10,41 +10,13 @@ jobs:
|
|
|
10
10
|
strategy:
|
|
11
11
|
max-parallel: 4
|
|
12
12
|
matrix:
|
|
13
|
-
# Run
|
|
14
|
-
ruby: [
|
|
15
|
-
ar: [
|
|
13
|
+
# Run acceptance tests all supported combinations of Ruby and ActiveRecord.
|
|
14
|
+
ruby: ["3.1", "3.2", "3.3"]
|
|
15
|
+
ar: ["~> 7.0.0", "~> 7.1.0", "~> 7.2.0", "~> 8.0.0"]
|
|
16
16
|
# Exclude combinations that are not supported.
|
|
17
17
|
exclude:
|
|
18
|
-
- ruby: 3.
|
|
19
|
-
ar:
|
|
20
|
-
- ruby: 3.0
|
|
21
|
-
ar: 6.0.1
|
|
22
|
-
- ruby: 3.0
|
|
23
|
-
ar: 6.0.2.2
|
|
24
|
-
- ruby: 3.0
|
|
25
|
-
ar: 6.0.3.7
|
|
26
|
-
- ruby: 3.0
|
|
27
|
-
ar: 6.0.4
|
|
28
|
-
- ruby: 3.1
|
|
29
|
-
ar: 6.0.0
|
|
30
|
-
- ruby: 3.1
|
|
31
|
-
ar: 6.0.1
|
|
32
|
-
- ruby: 3.1
|
|
33
|
-
ar: 6.0.2.2
|
|
34
|
-
- ruby: 3.1
|
|
35
|
-
ar: 6.0.3.7
|
|
36
|
-
- ruby: 3.1
|
|
37
|
-
ar: 6.0.4
|
|
38
|
-
- ruby: 3.2
|
|
39
|
-
ar: 6.0.0
|
|
40
|
-
- ruby: 3.2
|
|
41
|
-
ar: 6.0.1
|
|
42
|
-
- ruby: 3.2
|
|
43
|
-
ar: 6.0.2.2
|
|
44
|
-
- ruby: 3.2
|
|
45
|
-
ar: 6.0.3.7
|
|
46
|
-
- ruby: 3.2
|
|
47
|
-
ar: 6.0.4
|
|
18
|
+
- ruby: "3.1"
|
|
19
|
+
ar: "~> 8.0.0"
|
|
48
20
|
env:
|
|
49
21
|
AR_VERSION: ${{ matrix.ar }}
|
|
50
22
|
steps:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
on:
|
|
2
|
+
pull_request:
|
|
3
|
+
name: samples
|
|
4
|
+
jobs:
|
|
5
|
+
test:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
|
|
8
|
+
strategy:
|
|
9
|
+
max-parallel: 4
|
|
10
|
+
matrix:
|
|
11
|
+
ruby: ["3.1", "3.2", "3.3"]
|
|
12
|
+
ar: ["~> 7.0.0", "~> 7.1.0", "~> 7.2.0", "~> 8.0.0"]
|
|
13
|
+
# Exclude combinations that are not supported.
|
|
14
|
+
exclude:
|
|
15
|
+
- ruby: "3.1"
|
|
16
|
+
ar: "~> 8.0.0"
|
|
17
|
+
env:
|
|
18
|
+
AR_VERSION: ${{ matrix.ar }}
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Set up Ruby
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
bundler-cache: false
|
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: bundle install
|
|
28
|
+
- name: Run samples
|
|
29
|
+
run: bundle exec rake all
|
|
30
|
+
working-directory: examples/snippets
|
data/.kokoro/populate-secrets.sh
CHANGED
|
@@ -24,6 +24,10 @@ function msg { println "$*" >&2 ;}
|
|
|
24
24
|
function println { printf '%s\n' "$(now) $*" ;}
|
|
25
25
|
|
|
26
26
|
# Populates requested secrets set in SECRET_MANAGER_KEYS
|
|
27
|
+
if [[ -z "${SECRET_MANAGER_PROJECT_ID-}" ]]; then
|
|
28
|
+
msg "SECRET_MANAGER_PROJECT_ID is not set in environment variables, using default"
|
|
29
|
+
SECRET_MANAGER_PROJECT_ID="cloud-devrel-kokoro-resources"
|
|
30
|
+
fi
|
|
27
31
|
|
|
28
32
|
# In Kokoro CI builds, we use the service account attached to the
|
|
29
33
|
# Kokoro VM. This means we need to setup auth on other CI systems.
|
|
@@ -65,7 +69,7 @@ do
|
|
|
65
69
|
msg "Retrieving secret ${key}"
|
|
66
70
|
"${GCLOUD_COMMANDS[@]}" \
|
|
67
71
|
secrets versions access latest \
|
|
68
|
-
--project
|
|
72
|
+
--project "${SECRET_MANAGER_PROJECT_ID}" \
|
|
69
73
|
--secret $key > \
|
|
70
74
|
"$SECRET_LOCATION/$key"
|
|
71
75
|
if [[ $? == 0 ]]; then
|
data/.kokoro/release.cfg
CHANGED
|
@@ -7,19 +7,13 @@ action {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
# Download resources for system tests (service account key, etc.)
|
|
11
|
-
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
|
|
12
|
-
|
|
13
|
-
# Download trampoline resources.
|
|
14
|
-
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
|
|
15
|
-
|
|
16
10
|
# Use the trampoline script to run in docker.
|
|
17
11
|
build_file: "ruby-spanner-activerecord/.kokoro/trampoline_v2.sh"
|
|
18
12
|
|
|
19
13
|
# Configure the docker image for kokoro-trampoline.
|
|
20
14
|
env_vars: {
|
|
21
15
|
key: "TRAMPOLINE_IMAGE"
|
|
22
|
-
value: "
|
|
16
|
+
value: "us-central1-docker.pkg.dev/cloud-sdk-release-custom-pool/release-images/ruby-multi"
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
env_vars: {
|
|
@@ -27,16 +21,32 @@ env_vars: {
|
|
|
27
21
|
value: ".kokoro/release.sh"
|
|
28
22
|
}
|
|
29
23
|
|
|
24
|
+
env_vars: {
|
|
25
|
+
key: "SECRET_MANAGER_PROJECT_ID"
|
|
26
|
+
value: "cloud-sdk-release-custom-pool"
|
|
27
|
+
}
|
|
28
|
+
|
|
30
29
|
env_vars: {
|
|
31
30
|
key: "SECRET_MANAGER_KEYS"
|
|
32
31
|
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,docuploader_service_account"
|
|
33
32
|
}
|
|
34
33
|
|
|
34
|
+
# Pick up Rubygems key from internal keystore
|
|
35
|
+
before_action {
|
|
36
|
+
fetch_keystore {
|
|
37
|
+
keystore_resource {
|
|
38
|
+
keystore_config_id: 73713
|
|
39
|
+
keyname: "rubygems-publish-key"
|
|
40
|
+
backend: "blade:keystore-fastconfigpush"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
# Store the packages uploaded to rubygems.org, which
|
|
36
46
|
# we can later use to generate SBOMs and attestations.
|
|
37
47
|
action {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
48
|
+
define_artifacts {
|
|
49
|
+
regex: "github/ruby-spanner-activerecord/pkg/*.gem"
|
|
50
|
+
strip_prefix: "github"
|
|
51
|
+
}
|
|
52
|
+
}
|
data/.kokoro/release.sh
CHANGED
|
@@ -8,6 +8,4 @@ export GEM_HOME=$HOME/.gem
|
|
|
8
8
|
export PATH=$GEM_HOME/bin:$PATH
|
|
9
9
|
|
|
10
10
|
gem install --no-document toys
|
|
11
|
-
toys release
|
|
12
|
-
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
|
|
13
|
-
toys release perform -v --enable-docs < /dev/null
|
|
11
|
+
toys release perform -v --reporter-org=googleapis --enable-docs --force-republish --enable-docs --enable-rad < /dev/null
|
data/.kokoro/trampoline_v2.sh
CHANGED
|
@@ -138,18 +138,26 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then
|
|
|
138
138
|
RUNNING_IN_CI="true"
|
|
139
139
|
TRAMPOLINE_CI="kokoro"
|
|
140
140
|
if [[ "${TRAMPOLINE_USE_LEGACY_SERVICE_ACCOUNT:-}" == "true" ]]; then
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
if [[ ! -f "${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json" ]]; then
|
|
142
|
+
log_red "${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json does not exist. Did you forget to mount cloud-devrel-kokoro-resources/trampoline? Aborting."
|
|
143
|
+
exit 1
|
|
144
|
+
fi
|
|
145
|
+
# This service account will be activated later.
|
|
146
|
+
TRAMPOLINE_SERVICE_ACCOUNT="${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json"
|
|
147
147
|
else
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then
|
|
149
|
+
gcloud auth list
|
|
150
|
+
fi
|
|
151
|
+
log_yellow "Configuring Container Registry access"
|
|
152
|
+
TRAMPOLINE_HOST=$(echo "${TRAMPOLINE_IMAGE}" | cut -d/ -f1)
|
|
153
|
+
if [[ ! "${TRAMPOLINE_HOST}" =~ "gcr.io" ]]; then
|
|
154
|
+
# If you need to specificy a host other than gcr.io, you have to run on an update version of gcloud.
|
|
155
|
+
echo "TRAMPOLINE_HOST: ${TRAMPOLINE_HOST}"
|
|
156
|
+
gcloud components update
|
|
157
|
+
gcloud auth configure-docker "${TRAMPOLINE_HOST}"
|
|
158
|
+
else
|
|
159
|
+
gcloud auth configure-docker --quiet
|
|
160
|
+
fi
|
|
153
161
|
fi
|
|
154
162
|
pass_down_envvars+=(
|
|
155
163
|
# KOKORO dynamic variables.
|
data/.rubocop.yml
CHANGED
|
@@ -16,7 +16,7 @@ AllCops:
|
|
|
16
16
|
|
|
17
17
|
Documentation:
|
|
18
18
|
Enabled: false
|
|
19
|
-
Layout/
|
|
19
|
+
Layout/HashAlignment:
|
|
20
20
|
Enabled: false
|
|
21
21
|
Metrics/ClassLength:
|
|
22
22
|
Enabled: false
|
|
@@ -24,7 +24,7 @@ Metrics/ModuleLength:
|
|
|
24
24
|
Enabled: false
|
|
25
25
|
Naming/RescuedExceptionsVariableName:
|
|
26
26
|
Enabled: false
|
|
27
|
-
Naming/
|
|
27
|
+
Naming/MethodParameterName:
|
|
28
28
|
Enabled: false
|
|
29
29
|
Style/EmptyMethod:
|
|
30
30
|
Enabled: false
|
data/.trampolinerc
CHANGED
|
@@ -18,7 +18,12 @@ required_envvars+=(
|
|
|
18
18
|
|
|
19
19
|
# Add env vars which are passed down into the container here.
|
|
20
20
|
pass_down_envvars+=(
|
|
21
|
-
"AUTORELEASE_PR"
|
|
21
|
+
"AUTORELEASE_PR"
|
|
22
|
+
"EXTRA_CI_ARGS"
|
|
23
|
+
"KOKORO_GIT_COMMIT"
|
|
24
|
+
"RELEASE_DRY_RUN"
|
|
25
|
+
"RELEASE_PACKAGE"
|
|
26
|
+
"RUBY_VERSIONS"
|
|
22
27
|
)
|
|
23
28
|
|
|
24
29
|
# Prevent unintentional override on the default image.
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 2.0.0 (2025-01-23)
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* drop support for Rails 6.1 ([#346](https://github.com/googleapis/ruby-spanner-activerecord/issues/346))
|
|
8
|
+
* deserialize BYTES to StringIO ([#343](https://github.com/googleapis/ruby-spanner-activerecord/issues/343))
|
|
9
|
+
|
|
10
|
+
#### Features
|
|
11
|
+
|
|
12
|
+
* drop support for Rails 6.1 ([#346](https://github.com/googleapis/ruby-spanner-activerecord/issues/346))
|
|
13
|
+
* support Rails 8.0 ([#331](https://github.com/googleapis/ruby-spanner-activerecord/issues/331))
|
|
14
|
+
#### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* deserialize BYTES to StringIO ([#343](https://github.com/googleapis/ruby-spanner-activerecord/issues/343))
|
|
17
|
+
#### Documentation
|
|
18
|
+
|
|
19
|
+
* add rails dbconsole to list of limitations ([#224](https://github.com/googleapis/ruby-spanner-activerecord/issues/224))
|
|
20
|
+
|
|
21
|
+
### 1.8.0 (2024-12-12)
|
|
22
|
+
|
|
23
|
+
#### Features
|
|
24
|
+
|
|
25
|
+
* INSERT OR [IGNORE|UPDATE] ([#332](https://github.com/googleapis/ruby-spanner-activerecord/issues/332))
|
|
26
|
+
#### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* Fixed incorrect argument handling. ([#333](https://github.com/googleapis/ruby-spanner-activerecord/issues/333))
|
|
29
|
+
|
|
30
|
+
### 1.7.0 (2024-12-11)
|
|
31
|
+
|
|
32
|
+
#### Features
|
|
33
|
+
|
|
34
|
+
* support Rails 7.2.0 ([#328](https://github.com/googleapis/ruby-spanner-activerecord/issues/328))
|
|
35
|
+
#### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* `SpannerAdapter` requires prepared statements to be enabled ([#323](https://github.com/googleapis/ruby-spanner-activerecord/issues/323))
|
|
38
|
+
* local emulator test ([#320](https://github.com/googleapis/ruby-spanner-activerecord/issues/320))
|
|
39
|
+
|
|
3
40
|
### 1.6.3 (2024-08-31)
|
|
4
41
|
|
|
5
42
|
#### Bug Fixes
|
data/Gemfile
CHANGED
|
@@ -3,16 +3,18 @@ source "https://rubygems.org"
|
|
|
3
3
|
# Specify your gem's dependencies in activerecord-spanner.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
ar_version = ENV.fetch("AR_VERSION", "~> 7.1.0")
|
|
7
|
+
gem "activerecord", ar_version
|
|
8
|
+
gem "ostruct"
|
|
7
9
|
gem "minitest", "~> 5.25.0"
|
|
8
10
|
gem "minitest-rg", "~> 5.3.0"
|
|
9
|
-
gem "pry", "~> 0.
|
|
10
|
-
gem "pry-byebug", "~> 3.
|
|
11
|
+
gem "pry", "~> 0.14.2"
|
|
12
|
+
gem "pry-byebug", "~> 3.10.1"
|
|
11
13
|
# Add sqlite3 for testing for compatibility with other adapters.
|
|
12
|
-
gem 'sqlite3'
|
|
14
|
+
gem 'sqlite3'
|
|
13
15
|
|
|
14
16
|
# Required for samples and testing.
|
|
15
|
-
install_if -> {
|
|
17
|
+
install_if -> { ar_version.dup.to_s.sub("~>", "").strip < "7.1.0" && !ENV["SKIP_COMPOSITE_PK"] } do
|
|
16
18
|
gem "composite_primary_keys"
|
|
17
19
|
end
|
|
18
20
|
|
data/README.md
CHANGED
|
@@ -89,15 +89,17 @@ Some noteworthy examples in the snippets directory:
|
|
|
89
89
|
|
|
90
90
|
## Limitations
|
|
91
91
|
|
|
92
|
-
| Limitation | Comment
|
|
93
|
-
|
|
94
|
-
| Interleaved tables require composite primary keys | Cloud Spanner requires composite primary keys for interleaved tables. See {file:examples/snippets/interleaved-tables/README.md this example} for an example on how to use interleaved tables with ActiveRecord
|
|
95
|
-
| Lack of sequential IDs | Cloud Spanner uses either using bit-reversed sequences or UUID4 to generated primary keys to avoid [hotspotting](https://cloud.google.com/spanner/docs/schema-design#uuid_primary_key) so you SHOULD NOT rely on IDs being sorted
|
|
96
|
-
| Table without Primary Key | Cloud Spanner support does not support tables without a primary key.
|
|
97
|
-
| Table names CANNOT have spaces within them whether back-ticked or not | Cloud Spanner DOES NOT support tables with spaces in them for example `Entity ID`
|
|
98
|
-
| Table names CANNOT have punctuation marks and MUST contain valid UTF-8 | Cloud Spanner DOES NOT support punctuation marks e.g. periods ".", question marks "?" in table names
|
|
99
|
-
| Index with fields length [add_index](https://apidock.com/rails/v5.2.3/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index) | Cloud Spanner does not support index with fields length
|
|
100
|
-
| Only GoogleSQL-dialect databases | Cloud Spanner supports both GoogleSQL- and PostgreSQL-dialect databases. This adapter only supports GoogleSQL-dialect databases.
|
|
92
|
+
| Limitation | Comment | Resolution |
|
|
93
|
+
|-----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
|
|
94
|
+
| Interleaved tables require composite primary keys | Cloud Spanner requires composite primary keys for interleaved tables. See {file:examples/snippets/interleaved-tables/README.md this example} for an example on how to use interleaved tables with ActiveRecord | Use composite primary keys. |
|
|
95
|
+
| Lack of sequential IDs | Cloud Spanner uses either using bit-reversed sequences or UUID4 to generated primary keys to avoid [hotspotting](https://cloud.google.com/spanner/docs/schema-design#uuid_primary_key) so you SHOULD NOT rely on IDs being sorted | Use either UUID4s or bit-reversed sequences to automatically generate primary keys. |
|
|
96
|
+
| Table without Primary Key | Cloud Spanner support does not support tables without a primary key. | Always define a primary key for your table. |
|
|
97
|
+
| Table names CANNOT have spaces within them whether back-ticked or not | Cloud Spanner DOES NOT support tables with spaces in them for example `Entity ID` | Ensure that your table names don't contain spaces. |
|
|
98
|
+
| Table names CANNOT have punctuation marks and MUST contain valid UTF-8 | Cloud Spanner DOES NOT support punctuation marks e.g. periods ".", question marks "?" in table names | Ensure that your table names don't contain punctuation marks. |
|
|
99
|
+
| Index with fields length [add_index](https://apidock.com/rails/v5.2.3/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index) | Cloud Spanner does not support index with fields length | Ensure that your database definition does not include index definitions with field lengths. |
|
|
100
|
+
| Only GoogleSQL-dialect databases | Cloud Spanner supports both GoogleSQL- and PostgreSQL-dialect databases. This adapter only supports GoogleSQL-dialect databases. You can use the [PostgreSQL ActiveRecord provider in combination with PGAdapter](https://github.com/GoogleCloudPlatform/pgadapter/tree/postgresql-dialect/samples/ruby/activerecord) for Spanner PostgreSQL databases. | |
|
|
101
|
+
| `rails dbconsole` is not supported. | The `rails dbconsole` is not supported for Spanner databases. | |
|
|
102
|
+
|
|
101
103
|
|
|
102
104
|
## Contributing
|
|
103
105
|
|
data/Rakefile
CHANGED
|
@@ -56,8 +56,8 @@ task :acceptance, [:project, :keyfile, :instance, :tests] do |t, args|
|
|
|
56
56
|
tests ||= "**"
|
|
57
57
|
|
|
58
58
|
# always overwrite when running tests
|
|
59
|
-
ENV["
|
|
60
|
-
ENV["
|
|
59
|
+
ENV["SPANNER_TEST_PROJECT"] = project
|
|
60
|
+
ENV["SPANNER_TEST_KEYFILE_JSON"] = keyfile
|
|
61
61
|
ENV["SPANNER_TEST_INSTANCE"] = instance
|
|
62
62
|
ENV["SPANNER_EMULATOR_HOST"] = emulator_host
|
|
63
63
|
|
|
@@ -13,9 +13,6 @@ module ActiveRecord
|
|
|
13
13
|
class CommandRecorderTest < SpannerAdapter::TestCase
|
|
14
14
|
include SpannerAdapter::Migration::TestHelper
|
|
15
15
|
|
|
16
|
-
VERSION_6_1_0 = Gem::Version.create "6.1.0"
|
|
17
|
-
VERSION_6_0_3 = Gem::Version.create "6.0.3"
|
|
18
|
-
|
|
19
16
|
def setup
|
|
20
17
|
skip_test_table_create!
|
|
21
18
|
super
|
|
@@ -203,20 +200,12 @@ module ActiveRecord
|
|
|
203
200
|
|
|
204
201
|
def test_invert_add_index
|
|
205
202
|
remove = @recorder.inverse_of :add_index, [:table, [:one, :two]]
|
|
206
|
-
|
|
207
|
-
assert_equal [:remove_index, [:table, { column: [:one, :two] }]], remove
|
|
208
|
-
else
|
|
209
|
-
assert_equal [:remove_index, [:table, [:one, :two]], nil], remove
|
|
210
|
-
end
|
|
203
|
+
assert_equal [:remove_index, [:table, [:one, :two]], nil], remove
|
|
211
204
|
end
|
|
212
205
|
|
|
213
206
|
def test_invert_add_index_with_name
|
|
214
207
|
remove = @recorder.inverse_of :add_index, [:table, [:one, :two], name: "new_index"]
|
|
215
|
-
|
|
216
|
-
assert_equal [:remove_index, [:table, { name: "new_index" }]], remove
|
|
217
|
-
else
|
|
218
|
-
assert_equal [:remove_index, [:table, [:one, :two], {:name=>"new_index"}], nil], remove
|
|
219
|
-
end
|
|
208
|
+
assert_equal [:remove_index, [:table, [:one, :two], {:name=>"new_index"}], nil], remove
|
|
220
209
|
end
|
|
221
210
|
|
|
222
211
|
def test_invert_remove_index
|
|
@@ -226,11 +215,7 @@ module ActiveRecord
|
|
|
226
215
|
|
|
227
216
|
def test_invert_remove_index_with_options
|
|
228
217
|
add = @recorder.inverse_of :remove_index, [:table, { column: :one }]
|
|
229
|
-
|
|
230
|
-
assert_equal [:add_index, [:table, :one, {} ]], add
|
|
231
|
-
else
|
|
232
|
-
assert_equal [:add_index, [:table, :one ]], add
|
|
233
|
-
end
|
|
218
|
+
assert_equal [:add_index, [:table, :one ]], add
|
|
234
219
|
end
|
|
235
220
|
|
|
236
221
|
def test_invert_remove_index_with_positional_column
|
|
@@ -250,11 +235,7 @@ module ActiveRecord
|
|
|
250
235
|
|
|
251
236
|
def test_invert_remove_index_with_no_special_options
|
|
252
237
|
add = @recorder.inverse_of :remove_index, [:table, { column: [:one, :two] }]
|
|
253
|
-
|
|
254
|
-
assert_equal [:add_index, [:table, [:one, :two], {}]], add
|
|
255
|
-
else
|
|
256
|
-
assert_equal [:add_index, [:table, [:one, :two]]], add
|
|
257
|
-
end
|
|
238
|
+
assert_equal [:add_index, [:table, [:one, :two]]], add
|
|
258
239
|
end
|
|
259
240
|
|
|
260
241
|
def test_invert_remove_index_with_no_column
|
|
@@ -315,11 +296,7 @@ module ActiveRecord
|
|
|
315
296
|
|
|
316
297
|
def test_invert_add_foreign_key
|
|
317
298
|
enable = @recorder.inverse_of :add_foreign_key, [:dogs, :people]
|
|
318
|
-
|
|
319
|
-
assert_equal [:remove_foreign_key, [:dogs, :people]], enable
|
|
320
|
-
else
|
|
321
|
-
assert_equal [:remove_foreign_key, [:dogs, :people], nil], enable
|
|
322
|
-
end
|
|
299
|
+
assert_equal [:remove_foreign_key, [:dogs, :people], nil], enable
|
|
323
300
|
end
|
|
324
301
|
|
|
325
302
|
def test_invert_remove_foreign_key
|
|
@@ -329,11 +306,7 @@ module ActiveRecord
|
|
|
329
306
|
|
|
330
307
|
def test_invert_add_foreign_key_with_column
|
|
331
308
|
enable = @recorder.inverse_of :add_foreign_key, [:dogs, :people, column: "owner_id"]
|
|
332
|
-
|
|
333
|
-
assert_equal [:remove_foreign_key, [:dogs, column: "owner_id"]], enable
|
|
334
|
-
else
|
|
335
|
-
assert_equal [:remove_foreign_key, [:dogs, :people, column: "owner_id"], nil], enable
|
|
336
|
-
end
|
|
309
|
+
assert_equal [:remove_foreign_key, [:dogs, :people, column: "owner_id"], nil], enable
|
|
337
310
|
end
|
|
338
311
|
|
|
339
312
|
def test_invert_remove_foreign_key_with_column
|
|
@@ -343,11 +316,7 @@ module ActiveRecord
|
|
|
343
316
|
|
|
344
317
|
def test_invert_add_foreign_key_with_column_and_name
|
|
345
318
|
enable = @recorder.inverse_of :add_foreign_key, [:dogs, :people, column: "owner_id", name: "fk"]
|
|
346
|
-
|
|
347
|
-
assert_equal [:remove_foreign_key, [:dogs, { name: "fk" }]], enable
|
|
348
|
-
else
|
|
349
|
-
assert_equal [:remove_foreign_key, [:dogs, :people, { column: "owner_id", name: "fk" }], nil], enable
|
|
350
|
-
end
|
|
319
|
+
assert_equal [:remove_foreign_key, [:dogs, :people, { column: "owner_id", name: "fk" }], nil], enable
|
|
351
320
|
end
|
|
352
321
|
|
|
353
322
|
def test_invert_remove_foreign_key_with_column_and_name
|
|
@@ -76,12 +76,7 @@ module ActiveRecord
|
|
|
76
76
|
t.references :foo, polymorphic: true, index: true
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
|
-
|
|
80
|
-
if ActiveRecord::gem_version < Gem::Version.create('6.1.0')
|
|
81
|
-
assert connection.index_exists?(table_name, [:foo_type, :foo_id], name: :index_testings_on_foo_type_and_foo_id)
|
|
82
|
-
else
|
|
83
|
-
assert connection.index_exists?(table_name, [:foo_type, :foo_id], name: :index_testings_on_foo)
|
|
84
|
-
end
|
|
79
|
+
assert connection.index_exists?(table_name, [:foo_type, :foo_id], name: :index_testings_on_foo)
|
|
85
80
|
end
|
|
86
81
|
|
|
87
82
|
def test_creates_index_for_existing_table
|
|
@@ -124,11 +119,7 @@ module ActiveRecord
|
|
|
124
119
|
end
|
|
125
120
|
end
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
assert connection.index_exists?(table_name, [:foo_type, :foo_id], name: :index_testings_on_foo_type_and_foo_id)
|
|
129
|
-
else
|
|
130
|
-
assert connection.index_exists?(table_name, [:foo_type, :foo_id], name: :index_testings_on_foo)
|
|
131
|
-
end
|
|
122
|
+
assert connection.index_exists?(table_name, [:foo_type, :foo_id], name: :index_testings_on_foo)
|
|
132
123
|
end
|
|
133
124
|
end
|
|
134
125
|
end
|