activerecord-sqlserver-adapter 7.0.4.0 → 7.0.5.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +8 -5
- data/test/cases/view_test_sqlserver.rb +50 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02401b4f2142fc0cdebfd2308b94647ab6dc927c77542d4125dae6b6184e7e1c
|
4
|
+
data.tar.gz: c4d0d77af6f8344846387c14b1b84977b5af321bc7b2e9cf208bdab59179363d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e37d3daf2d7a509ef38eb45218fc3db5d4c60938ac2b8687a7f53a5e516df6fa3fa29dea71914d469336ebb8a7020921f5b479917afe78654d05048b51dd3911
|
7
|
+
data.tar.gz: 91a4c0bb6729b16736885cc7b2a89e7a80abbb11580bc02b31bb83dc4c3e2b72eb2e10815ae85af7e5a28f9990a8e7bea102345d146fa8323593605a32ec2bda
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
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
|
+
|
7
|
+
## v7.0.5.0
|
8
|
+
|
9
|
+
#### Fixed
|
10
|
+
|
11
|
+
- [#1113](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1113) Fix issue with default view value not being found because of case sensitivity
|
12
|
+
- [#1126](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1113) Fix view issue with default column value not found
|
13
|
+
|
1
14
|
## v7.0.4.0
|
2
15
|
|
3
16
|
#### Changed
|
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.
|
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.
|
1
|
+
7.0.5.1
|
@@ -388,7 +388,7 @@ module ActiveRecord
|
|
388
388
|
|
389
389
|
if view_exists
|
390
390
|
results = sp_executesql %{
|
391
|
-
SELECT c.COLUMN_NAME AS [name], c.COLUMN_DEFAULT AS [default]
|
391
|
+
SELECT LOWER(c.COLUMN_NAME) AS [name], c.COLUMN_DEFAULT AS [default]
|
392
392
|
FROM #{database}.INFORMATION_SCHEMA.COLUMNS c
|
393
393
|
WHERE c.TABLE_NAME = #{quote(view_tblnm)}
|
394
394
|
}.squish, "SCHEMA", []
|
@@ -426,7 +426,7 @@ module ActiveRecord
|
|
426
426
|
ci[:default_function] = begin
|
427
427
|
default = ci[:default_value]
|
428
428
|
if default.nil? && view_exists
|
429
|
-
view_column = views_real_column_name(table_name, ci[:name])
|
429
|
+
view_column = views_real_column_name(table_name, ci[:name]).downcase
|
430
430
|
default = default_functions[view_column] if view_column.present?
|
431
431
|
end
|
432
432
|
case default
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cases/helper_sqlserver"
|
4
|
+
|
5
|
+
class ViewTestSQLServer < ActiveRecord::TestCase
|
6
|
+
let(:connection) { ActiveRecord::Base.connection }
|
7
|
+
|
8
|
+
describe 'view with default values' do
|
9
|
+
before do
|
10
|
+
connection.drop_table :view_casing_table rescue nil
|
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, null: true, default: nil
|
15
|
+
t.string :default_string, null: false, default: "abc"
|
16
|
+
end
|
17
|
+
|
18
|
+
connection.execute("DROP VIEW IF EXISTS view_casing_table_view;")
|
19
|
+
connection.execute <<-SQL
|
20
|
+
CREATE VIEW view_casing_table_view AS
|
21
|
+
SELECT id AS id,
|
22
|
+
default_falsey AS falsey,
|
23
|
+
default_truthy AS truthy,
|
24
|
+
default_string_null AS s_null,
|
25
|
+
default_string AS s
|
26
|
+
FROM view_casing_table
|
27
|
+
SQL
|
28
|
+
end
|
29
|
+
|
30
|
+
it "default values are correct when column casing used in tables and views are different" do
|
31
|
+
klass = Class.new(ActiveRecord::Base) do
|
32
|
+
self.table_name = "view_casing_table_view"
|
33
|
+
end
|
34
|
+
|
35
|
+
obj = klass.new
|
36
|
+
assert_equal false, obj.falsey
|
37
|
+
assert_equal true, obj.truthy
|
38
|
+
assert_equal "abc", obj.s
|
39
|
+
assert_nil obj.s_null
|
40
|
+
assert_equal 0, klass.count
|
41
|
+
|
42
|
+
obj.save!
|
43
|
+
assert_equal false, obj.falsey
|
44
|
+
assert_equal true, obj.truthy
|
45
|
+
assert_equal "abc", obj.s
|
46
|
+
assert_nil obj.s_null
|
47
|
+
assert_equal 1, klass.count
|
48
|
+
end
|
49
|
+
end
|
50
|
+
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.
|
4
|
+
version: 7.0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
@@ -12,10 +12,10 @@ authors:
|
|
12
12
|
- Joe Rafaniello
|
13
13
|
- Tom Ward
|
14
14
|
- Aidan Haran
|
15
|
-
autorequire:
|
15
|
+
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2023-
|
18
|
+
date: 2023-11-08 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- test/cases/trigger_test_sqlserver.rb
|
178
178
|
- test/cases/utils_test_sqlserver.rb
|
179
179
|
- test/cases/uuid_test_sqlserver.rb
|
180
|
+
- test/cases/view_test_sqlserver.rb
|
180
181
|
- test/config.yml
|
181
182
|
- test/debug.rb
|
182
183
|
- test/fixtures/1px.gif
|
@@ -230,9 +231,9 @@ licenses:
|
|
230
231
|
- MIT
|
231
232
|
metadata:
|
232
233
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
233
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.
|
234
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.
|
235
|
-
post_install_message:
|
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
|
+
post_install_message:
|
236
237
|
rdoc_options: []
|
237
238
|
require_paths:
|
238
239
|
- lib
|
@@ -247,8 +248,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
248
|
- !ruby/object:Gem::Version
|
248
249
|
version: '0'
|
249
250
|
requirements: []
|
250
|
-
rubygems_version: 3.4.
|
251
|
-
signing_key:
|
251
|
+
rubygems_version: 3.4.7
|
252
|
+
signing_key:
|
252
253
|
specification_version: 4
|
253
254
|
summary: ActiveRecord SQL Server Adapter.
|
254
255
|
test_files:
|
@@ -291,6 +292,7 @@ test_files:
|
|
291
292
|
- test/cases/trigger_test_sqlserver.rb
|
292
293
|
- test/cases/utils_test_sqlserver.rb
|
293
294
|
- test/cases/uuid_test_sqlserver.rb
|
295
|
+
- test/cases/view_test_sqlserver.rb
|
294
296
|
- test/config.yml
|
295
297
|
- test/debug.rb
|
296
298
|
- test/fixtures/1px.gif
|