activerecord-sqlserver-adapter 7.0.5.0 → 7.0.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: 817f19cbeb123346a8b663abe75e79a93af2b318189d4e4ff0b1a74414ccfd65
4
- data.tar.gz: e9e323ec3d0174bd241ab6c841fbc7b3d204c1019c79cb7eefe47cff72b31da4
3
+ metadata.gz: 02401b4f2142fc0cdebfd2308b94647ab6dc927c77542d4125dae6b6184e7e1c
4
+ data.tar.gz: c4d0d77af6f8344846387c14b1b84977b5af321bc7b2e9cf208bdab59179363d
5
5
  SHA512:
6
- metadata.gz: ace03652a84e2943c84cf9fb2fa303fb5c26e9969f4d6375f09a8ddc5cb8a6bf84ac7609d39f9c97c3ffeaba8ef9b0b60f34c3483e576983977b87aa576cd7d4
7
- data.tar.gz: e8802d4c5c5d936f6b9dbcd53323785830756b1d605d550cc302e0ca3b3862819e12ccc4b87a5a4982f70561b1a58a16422ed776cfd7dabd842aa355895253b1
6
+ metadata.gz: e37d3daf2d7a509ef38eb45218fc3db5d4c60938ac2b8687a7f53a5e516df6fa3fa29dea71914d469336ebb8a7020921f5b479917afe78654d05048b51dd3911
7
+ data.tar.gz: 91a4c0bb6729b16736885cc7b2a89e7a80abbb11580bc02b31bb83dc4c3e2b72eb2e10815ae85af7e5a28f9990a8e7bea102345d146fa8323593605a32ec2bda
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v7.0.5.1
2
+
3
+ #### Fixed
4
+
5
+ - [#1133](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1133) Fix matching view's real column name
6
+
1
7
  ## v7.0.5.0
2
8
 
3
9
  #### Fixed
data/README.md CHANGED
@@ -13,7 +13,7 @@ Interested in older versions? We follow a rational versioning policy that tracks
13
13
 
14
14
  | Adapter Version | Rails Version | Support |
15
15
  |-----------------| ------------- | ------------------------------------------------------------------------------------------- |
16
- | `7.0.4.0` | `7.0.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
16
+ | `7.0.5.1` | `7.0.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
17
17
  | `6.1.2.1` | `6.1.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-1-stable) |
18
18
  | `6.0.3` | `6.0.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-0-stable) |
19
19
  | `5.2.1` | `5.2.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-2-stable) |
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.0.5.0
1
+ 7.0.5.1
@@ -601,17 +601,19 @@ module ActiveRecord
601
601
  identifier = SQLServer::Utils.extract_identifiers(table_name)
602
602
  information_query_table = identifier.database.present? ? "[#{identifier.database}].[INFORMATION_SCHEMA].[VIEWS]" : "[INFORMATION_SCHEMA].[VIEWS]"
603
603
  view_info = select_one "SELECT * FROM #{information_query_table} WITH (NOLOCK) WHERE TABLE_NAME = #{quote(identifier.object)}", "SCHEMA"
604
+
604
605
  if view_info
605
606
  view_info = view_info.with_indifferent_access
606
607
  if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000
607
608
  view_info[:VIEW_DEFINITION] = begin
608
- select_values("EXEC sp_helptext #{identifier.object_quoted}", "SCHEMA").join
609
+ select_values("EXEC sp_helptext #{identifier.object_quoted}", "SCHEMA").join
609
610
  rescue
610
611
  warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;"
611
612
  nil
612
- end
613
+ end
613
614
  end
614
615
  end
616
+
615
617
  view_info
616
618
  end
617
619
  end
@@ -620,7 +622,8 @@ module ActiveRecord
620
622
  view_definition = view_information(table_name)[:VIEW_DEFINITION]
621
623
  return column_name unless view_definition
622
624
 
623
- match_data = view_definition.match(/CREATE\s+VIEW.*AS\s+SELECT.*\W([\w-]*)\s+AS\s+#{column_name}/im)
625
+ # Remove "CREATE VIEW ... AS SELECT ..." and then match the column name.
626
+ match_data = view_definition.sub(/CREATE\s+VIEW.*AS\s+SELECT\s/, '').match(/([\w-]*)\s+AS\s+#{column_name}\W/im)
624
627
  match_data ? match_data[1] : column_name
625
628
  end
626
629
 
@@ -9,18 +9,20 @@ class ViewTestSQLServer < ActiveRecord::TestCase
9
9
  before do
10
10
  connection.drop_table :view_casing_table rescue nil
11
11
  connection.create_table :view_casing_table, force: true do |t|
12
- t.boolean :Default_Falsey, null: false, default: false
13
- t.boolean :Default_Truthy, null: false, default: true
14
- t.string :default_string, null: false, default: "abc"
12
+ t.boolean :Default_Falsey, null: false, default: false
13
+ t.boolean :Default_Truthy, null: false, default: true
14
+ t.string :default_string_null, null: true, default: nil
15
+ t.string :default_string, null: false, default: "abc"
15
16
  end
16
17
 
17
18
  connection.execute("DROP VIEW IF EXISTS view_casing_table_view;")
18
19
  connection.execute <<-SQL
19
20
  CREATE VIEW view_casing_table_view AS
20
21
  SELECT id AS id,
21
- default_falsey AS falsey,
22
- default_truthy AS truthy,
23
- default_string AS s
22
+ default_falsey AS falsey,
23
+ default_truthy AS truthy,
24
+ default_string_null AS s_null,
25
+ default_string AS s
24
26
  FROM view_casing_table
25
27
  SQL
26
28
  end
@@ -34,12 +36,14 @@ class ViewTestSQLServer < ActiveRecord::TestCase
34
36
  assert_equal false, obj.falsey
35
37
  assert_equal true, obj.truthy
36
38
  assert_equal "abc", obj.s
39
+ assert_nil obj.s_null
37
40
  assert_equal 0, klass.count
38
41
 
39
42
  obj.save!
40
43
  assert_equal false, obj.falsey
41
44
  assert_equal true, obj.truthy
42
45
  assert_equal "abc", obj.s
46
+ assert_nil obj.s_null
43
47
  assert_equal 1, klass.count
44
48
  end
45
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-sqlserver-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.5.0
4
+ version: 7.0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2023-11-06 00:00:00.000000000 Z
18
+ date: 2023-11-08 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord
@@ -231,8 +231,8 @@ licenses:
231
231
  - MIT
232
232
  metadata:
233
233
  bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
234
- changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.5.0/CHANGELOG.md
235
- source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.5.0
234
+ changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.5.1/CHANGELOG.md
235
+ source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.5.1
236
236
  post_install_message:
237
237
  rdoc_options: []
238
238
  require_paths: