activerecord-spanner-adapter 1.3.1 → 1.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b6dba891089af7c51b13f3b80ce8342b691d31cd0e31181dbd5799c240a2e9c
4
- data.tar.gz: 54a6079aa300d4e31bb8f47630857e624e94995dc713aae60aa848ac3da41ca0
3
+ metadata.gz: 2f432fe0aba4f4aaa5d2bcc689d8337fb944b393a8f71e11731f21bd2bc1aad5
4
+ data.tar.gz: 3dd03abd67174f3b7239d2c19a18ae0df756ad009988ae8ecddbd2369eb7164b
5
5
  SHA512:
6
- metadata.gz: d5f05cd6a79976d974d3d5aa472d514146b5367dae7a4c334913627acc0c98154c8a247c0225a42f235c976b9d3e28cd8c29c46a3c1e876eda6c181619e11617
7
- data.tar.gz: b943df790fa40955c31b5e9df89396a84d5f9b0499e8d610758238a249de1cc693b53f87f9b5d134b6595be5677222b04685206b8ca5d28472e6f9fbdac20ad9
6
+ metadata.gz: d99d549f841dcb2facf0438335b06449f70e033ad9c030fa2396fff16650e8a9ee653157ee8699cd9e473515630766e2f9b3e117acc73d6ddf35fb8ee83724a1
7
+ data.tar.gz: 4e207e65e60ab191c7479f7ae47c9fdd0ebac9a5ca54505841155428b88dc60c379dae96db6e43cd17e8c2bc2af9d9b7b5b4c5ae091281416cdf9d7616edaf9c
@@ -18,16 +18,16 @@ jobs:
18
18
  strategy:
19
19
  max-parallel: 4
20
20
  matrix:
21
- ruby: [2.6, 2.7, 3.0]
22
- ar: [6.0.5.1, 6.1.6.1, 7.0.2.4, 7.0.3.1]
21
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
22
+ ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4"]
23
23
  # Exclude combinations that are not supported.
24
24
  exclude:
25
- - ruby: 3.0
26
- ar: 6.0.5.1
27
- - ruby: 2.6
28
- ar: 7.0.2.4
29
- - ruby: 2.6
30
- ar: 7.0.3.1
25
+ - ruby: "3.0"
26
+ ar: "~> 6.0.6"
27
+ - ruby: "3.1"
28
+ ar: "~> 6.0.6"
29
+ - ruby: "2.6"
30
+ ar: "~> 7.0.4"
31
31
  env:
32
32
  AR_VERSION: ${{ matrix.ar }}
33
33
  steps:
@@ -10,14 +10,16 @@ jobs:
10
10
  strategy:
11
11
  max-parallel: 4
12
12
  matrix:
13
- ruby: ["2.6", "2.7", "3.0"]
14
- ar: ["6.0.4", "6.1.4", "7.0.2.4"]
13
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
14
+ ar: ["~> 6.0.6", "~> 6.1.7", "~> 7.0.4"]
15
15
  # Exclude combinations that are not supported.
16
16
  exclude:
17
17
  - ruby: "3.0"
18
- ar: "6.0.4"
18
+ ar: "~> 6.0.6"
19
+ - ruby: "3.1"
20
+ ar: "~> 6.0.6"
19
21
  - ruby: "2.6"
20
- ar: "7.0.2.4"
22
+ ar: "~> 7.0.4"
21
23
  env:
22
24
  AR_VERSION: ${{ matrix.ar }}
23
25
  steps:
@@ -19,8 +19,8 @@ jobs:
19
19
  max-parallel: 4
20
20
  matrix:
21
21
  # Run acceptance tests all supported combinations of Ruby and ActiveRecord.
22
- ruby: [2.5, 2.6, 2.7, 3.0]
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]
22
+ ruby: [2.6, 2.7, 3.0, 3.1]
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]
24
24
  # Exclude combinations that are not supported.
25
25
  exclude:
26
26
  - ruby: 3.0
@@ -33,14 +33,22 @@ jobs:
33
33
  ar: 6.0.3.7
34
34
  - ruby: 3.0
35
35
  ar: 6.0.4
36
- - ruby: 2.5
37
- ar: 7.0.2.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
38
46
  - ruby: 2.6
39
47
  ar: 7.0.2.4
40
- - ruby: 2.5
41
- ar: 7.0.3.1
42
48
  - ruby: 2.6
43
49
  ar: 7.0.3.1
50
+ - ruby: 2.6
51
+ ar: 7.0.4
44
52
  env:
45
53
  AR_VERSION: ${{ matrix.ar }}
46
54
  steps:
@@ -11,8 +11,8 @@ jobs:
11
11
  max-parallel: 4
12
12
  matrix:
13
13
  # Run unit tests all supported combinations of Ruby and ActiveRecord.
14
- ruby: [2.5, 2.6, 2.7, 3.0]
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]
14
+ ruby: [2.6, 2.7, 3.0, 3.1]
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]
16
16
  # Exclude combinations that are not supported.
17
17
  exclude:
18
18
  - ruby: 3.0
@@ -25,14 +25,22 @@ jobs:
25
25
  ar: 6.0.3.7
26
26
  - ruby: 3.0
27
27
  ar: 6.0.4
28
- - ruby: 2.5
29
- ar: 7.0.2.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
30
38
  - ruby: 2.6
31
39
  ar: 7.0.2.4
32
- - ruby: 2.5
33
- ar: 7.0.3.1
34
40
  - ruby: 2.6
35
41
  ar: 7.0.3.1
42
+ - ruby: 2.6
43
+ ar: 7.0.4
36
44
  env:
37
45
  AR_VERSION: ${{ matrix.ar }}
38
46
  steps:
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.3.1"
2
+ ".": "1.4.1"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.4.1 (2023-03-01)
4
+
5
+ #### Bug Fixes
6
+
7
+ * wrap default values in () as required ([#238](https://github.com/googleapis/ruby-spanner-activerecord/issues/238))
8
+ #### Documentation
9
+
10
+ * call out best practices and dialect compatibility ([#240](https://github.com/googleapis/ruby-spanner-activerecord/issues/240))
11
+
12
+ ### 1.4.0 (2023-01-18)
13
+
14
+ #### Features
15
+
16
+ * dropped support for Ruby 2.5 ([#236](https://github.com/googleapis/ruby-spanner-activerecord/issues/236))
17
+
3
18
  ### 1.3.1 (2022-12-15)
4
19
 
5
20
  #### 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.15.0"
7
+ gem "minitest", "~> 5.16.3"
8
8
  gem "pry", "~> 0.13.0"
9
9
  gem "pry-byebug", "~> 3.9.0"
10
10
 
data/README.md CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  ![rubocop](https://github.com/googleapis/ruby-spanner-activerecord/workflows/rubocop/badge.svg)
6
6
 
7
+ __This adapter only supports GoogleSQL-dialect Cloud Spanner databases. PostgreSQL-dialect
8
+ databases are not supported.__
9
+
7
10
  This project provides a Cloud Spanner adapter for ActiveRecord. It supports the following versions:
8
11
 
9
12
  - ActiveRecord 6.0.x with Ruby 2.6 and 2.7.
@@ -13,9 +16,6 @@ This project provides a Cloud Spanner adapter for ActiveRecord. It supports the
13
16
  Known limitations are listed in the [Limitations](#limitations) section.
14
17
  Please report any problems that you might encounter by [creating a new issue](https://github.com/googleapis/ruby-spanner-activerecord/issues/new).
15
18
 
16
- This adapter only supports GoogleSQL-dialect Cloud Spanner databases. PostgreSQL-dialect
17
- databases are not supported.
18
-
19
19
  ## Installation
20
20
 
21
21
  Add this line to your application's Gemfile:
@@ -36,6 +36,14 @@ And then execute:
36
36
 
37
37
  ## Usage
38
38
 
39
+ ### Migrations
40
+ __Use DDL batching when executing migrations for the best possible performance.__
41
+
42
+ Executing multiple schema changes on Cloud Spanner can take a long time. It is therefore
43
+ strongly recommended that you limit the number of schema change operations. You can do
44
+ this by using DDL batching in your migrations. See [the migrations examples](examples/snippets/migrations)
45
+ for how to do this.
46
+
39
47
  ### Database Connection
40
48
  In Rails application `config/database.yml`, make the change as the following:
41
49
 
@@ -120,6 +120,27 @@ module ActiveRecord
120
120
  end
121
121
  end
122
122
 
123
+ def test_create_table_with_column_default
124
+ testings_klass = Class.new ActiveRecord::Base
125
+ connection.ddl_batch do
126
+ connection.create_table :testings do |t|
127
+ t.string :name, null: false, default: "no name"
128
+ t.integer :age, null: false, default: 10
129
+ end
130
+ testings_klass.table_name = "testings"
131
+ end
132
+
133
+ testings_klass.reset_column_information
134
+ assert_equal false, testings_klass.columns_hash["name"].null
135
+ assert_equal false, testings_klass.columns_hash["age"].null
136
+
137
+ assert_nothing_raised {
138
+ testings_klass.connection.transaction {
139
+ testings_klass.connection.execute("insert into testings (id, name, age) values (#{generate_id}, DEFAULT, DEFAULT)")
140
+ }
141
+ }
142
+ end
143
+
123
144
  def test_create_table_with_limits
124
145
  connection.ddl_batch do
125
146
  connection.create_table :testings do |t|
@@ -30,77 +30,87 @@ module ActiveRecord
30
30
 
31
31
  def test_remove_references_column_type_with_polymorphic_removes_type
32
32
  with_change_table do |t|
33
- @connection.expect :remove_reference, nil, [:delete_me, :taggable, polymorphic: true]
33
+ @connection.expect :remove_reference, nil, [:delete_me, :taggable], polymorphic: true
34
34
  t.remove_references :taggable, polymorphic: true
35
35
  end
36
36
  end
37
37
 
38
38
  def test_references_column_type_with_polymorphic_and_options_null_is_false_adds_table_flag
39
39
  with_change_table do |t|
40
- @connection.expect :add_reference, nil, [:delete_me, :taggable, polymorphic: true, null: false]
40
+ @connection.expect :add_reference, nil, [:delete_me, :taggable], polymorphic: true, null: false
41
41
  t.references :taggable, polymorphic: true, null: false
42
42
  end
43
43
  end
44
44
 
45
45
  def test_remove_references_column_type_with_polymorphic_and_options_null_is_false_removes_table_flag
46
46
  with_change_table do |t|
47
- @connection.expect :remove_reference, nil, [:delete_me, :taggable, polymorphic: true, null: false]
47
+ @connection.expect :remove_reference, nil, [:delete_me, :taggable], polymorphic: true, null: false
48
48
  t.remove_references :taggable, polymorphic: true, null: false
49
49
  end
50
50
  end
51
51
 
52
52
  def test_references_column_type_with_polymorphic_and_type
53
53
  with_change_table do |t|
54
- @connection.expect :add_reference, nil, [:delete_me, :taggable, polymorphic: true, type: :string]
54
+ @connection.expect :add_reference, nil, [:delete_me, :taggable], polymorphic: true, type: :string
55
55
  t.references :taggable, polymorphic: true, type: :string
56
56
  end
57
57
  end
58
58
 
59
59
  def test_remove_references_column_type_with_polymorphic_and_type
60
60
  with_change_table do |t|
61
- @connection.expect :remove_reference, nil, [:delete_me, :taggable, polymorphic: true, type: :string]
61
+ @connection.expect :remove_reference, nil, [:delete_me, :taggable], polymorphic: true, type: :string
62
62
  t.remove_references :taggable, polymorphic: true, type: :string
63
63
  end
64
64
  end
65
65
 
66
66
  def test_timestamps_creates_updated_at_and_created_at
67
67
  with_change_table do |t|
68
- @connection.expect :add_timestamps, nil, [:delete_me, null: true]
68
+ @connection.expect :add_timestamps, nil, [:delete_me], null: true
69
69
  t.timestamps null: true
70
70
  end
71
71
  end
72
72
 
73
73
  def test_remove_timestamps_creates_updated_at_and_created_at
74
74
  with_change_table do |t|
75
- @connection.expect :remove_timestamps, nil, [:delete_me, { null: true }]
75
+ @connection.expect :remove_timestamps, nil, [:delete_me], null: true
76
76
  t.remove_timestamps(null: true)
77
77
  end
78
78
  end
79
79
 
80
80
  def test_primary_key_creates_primary_key_column
81
81
  with_change_table do |t|
82
- @connection.expect :add_column, nil, [:delete_me, :id, :primary_key, primary_key: true, first: true]
82
+ @connection.expect :add_column, nil, [:delete_me, :id, :primary_key], primary_key: true, first: true
83
83
  t.primary_key :id, first: true
84
84
  end
85
85
  end
86
86
 
87
87
  def test_index_exists
88
88
  with_change_table do |t|
89
- @connection.expect :index_exists?, nil, [:delete_me, :bar, {}]
90
- t.index_exists?(:bar)
89
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3")
90
+ @connection.expect :index_exists?, nil, [:delete_me, :bar, {}]
91
+ t.index_exists?(:bar, {})
92
+ else
93
+ @connection.expect :index_exists?, nil, [:delete_me, :bar]
94
+ t.index_exists?(:bar)
95
+ end
91
96
  end
92
97
  end
93
98
 
94
99
  def test_index_exists_with_options
95
100
  with_change_table do |t|
96
- @connection.expect :index_exists?, nil, [:delete_me, :bar, { unique: true }]
97
- t.index_exists?(:bar, unique: true)
101
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3")
102
+ @connection.expect :index_exists?, nil, [:delete_me, :bar, {unique: true}]
103
+ t.index_exists?(:bar, {unique: true})
104
+ else
105
+ @connection.expect :index_exists?, nil, [:delete_me, :bar], unique: true
106
+ t.index_exists?(:bar, unique: true)
107
+ end
98
108
  end
99
109
  end
100
110
 
101
111
  def test_remove_drops_multiple_columns_when_column_options_are_given
102
112
  with_change_table do |t|
103
- @connection.expect :remove_columns, nil, [:delete_me, :bar, :baz, type: :string, null: false]
113
+ @connection.expect :remove_columns, nil, [:delete_me, :bar, :baz], type: :string, null: false
104
114
  t.remove :bar, :baz, type: :string, null: false
105
115
  end
106
116
  end
@@ -20,6 +20,8 @@ module ActiveRecord
20
20
  end
21
21
 
22
22
  def test_logs_without_binds
23
+ skip "This test sometimes fails because nothing is logged (or marked as logged by the test logger)"
24
+
23
25
  published_time = Time.new(2016, 05, 11, 19, 0, 0)
24
26
  Post.where(published_time: published_time, title: 'Title - 1').first
25
27
 
@@ -30,6 +32,8 @@ module ActiveRecord
30
32
  end
31
33
 
32
34
  def test_logs_with_binds
35
+ skip "This test sometimes fails because nothing is logged (or marked as logged by the test logger)"
36
+
33
37
  ActiveRecord::ConnectionAdapters::SpannerAdapter.log_statement_binds = true
34
38
 
35
39
  published_time = Time.new(2016, 05, 11, 19, 0, 0)
@@ -129,7 +129,7 @@ module ActiveRecord
129
129
  sql << " NOT NULL"
130
130
  end
131
131
  if options.key? :default
132
- sql << " DEFAULT #{quote_default_expression options[:default], column}"
132
+ sql << " DEFAULT (#{quote_default_expression options[:default], column})"
133
133
  end
134
134
 
135
135
  if !options[:allow_commit_timestamp].nil? &&
@@ -5,5 +5,5 @@
5
5
  # https://opensource.org/licenses/MIT.
6
6
 
7
7
  module ActiveRecordSpannerAdapter
8
- VERSION = "1.3.1".freeze
8
+ VERSION = "1.4.1".freeze
9
9
  end
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.3.1
4
+ version: 1.4.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-01-02 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-spanner
@@ -536,7 +536,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
536
536
  - !ruby/object:Gem::Version
537
537
  version: '0'
538
538
  requirements: []
539
- rubygems_version: 3.3.14
539
+ rubygems_version: 3.4.2
540
540
  signing_key:
541
541
  specification_version: 4
542
542
  summary: Rails ActiveRecord connector for Google Spanner Database