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
@@ -1,15 +0,0 @@
|
|
1
|
-
# Copyright 2021 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
|
-
# `albums` is defined as INTERLEAVE IN PARENT `singers`. The primary key of `singers` is `singerid`.
|
9
|
-
belongs_to :singer, foreign_key: "singerid"
|
10
|
-
|
11
|
-
# `tracks` is defined as INTERLEAVE IN PARENT `albums`. The primary key of `albums` is (`singerid`, `albumid`), but
|
12
|
-
# only `albumid` is used by ActiveRecord as the primary key. The `singerid` column is defined as a `parent_key` of
|
13
|
-
# `albums` (see also the `db/migrate/01_create_tables.rb` file).
|
14
|
-
has_many :tracks, foreign_key: "albumid"
|
15
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Copyright 2021 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
|
-
# `albums` is defined as INTERLEAVE IN PARENT `singers`. The primary key of `albums` is (`singerid`, `albumid`), but
|
9
|
-
# only `albumid` is used by ActiveRecord as the primary key. The `singerid` column is defined as a `parent_key` of
|
10
|
-
# `albums` (see also the `db/migrate/01_create_tables.rb` file).
|
11
|
-
has_many :albums, foreign_key: "singerid"
|
12
|
-
|
13
|
-
# `tracks` is defined as INTERLEAVE IN PARENT `albums`. The primary key of `tracks` is
|
14
|
-
# (`singerid`, `albumid`, `trackid`), but only `trackid` is used by ActiveRecord as the primary key. The `singerid`
|
15
|
-
# and `albumid` columns are defined as `parent_key` of `tracks` (see also the `db/migrate/01_create_tables.rb` file).
|
16
|
-
# The `singerid` column can therefore be used to associate tracks with a singer without the need to go through albums.
|
17
|
-
# Note also that the inclusion of `singerid` as a column in `tracks` is required in order to make `tracks` a child
|
18
|
-
# table of `albums` which has primary key (`singerid`, `albumid`).
|
19
|
-
has_many :tracks, foreign_key: "singerid"
|
20
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# Copyright 2021 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 Track < ActiveRecord::Base
|
8
|
-
# `tracks` is defined as INTERLEAVE IN PARENT `albums`. The primary key of `albums` is ()`singerid`, `albumid`).
|
9
|
-
belongs_to :album, foreign_key: "albumid"
|
10
|
-
|
11
|
-
# `tracks` also has a `singerid` column should be used to associate a Track with a Singer.
|
12
|
-
belongs_to :singer, foreign_key: "singerid"
|
13
|
-
|
14
|
-
# Override the default initialize method to automatically set the singer attribute when an album is given.
|
15
|
-
def initialize attributes = nil
|
16
|
-
super
|
17
|
-
self.singer ||= album&.singer
|
18
|
-
end
|
19
|
-
|
20
|
-
def album=value
|
21
|
-
super
|
22
|
-
# Ensure the singer of this track is equal to the singer of the album that is set.
|
23
|
-
self.singer = value&.singer
|
24
|
-
end
|
25
|
-
end
|