activerecord-sqlserver-adapter 6.0.2 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -1
- data/VERSION +1 -1
- data/appveyor.yml +5 -7
- data/lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +4 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/preloader.rb +2 -0
- data/test/cases/coerced_tests.rb +80 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a4ddc7c26331060001ac99b3e2ea5c7d30a97204237c48c383b356280a763ac
|
4
|
+
data.tar.gz: c9e1154f442e957e1930fa7cc36addf9b8f465d579d44fcb87fb6a4ffe0426bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3e2cbdcd6ef7d2f334a4af20a66e9c1f1a4ec28548dc664e879a94e87aa487a0d68c6468182b3a026f3e05aa0c735ce16c774b8b404cb8f7e140188d8c06f0
|
7
|
+
data.tar.gz: 5f759150e7c204c5de007a320897b71bfe80913ee78d162dcfa891ab840102089f3798a7641ccaa2fe6ef6a56250deed62877f2b7900983f705a21677985c291
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v6.0.3
|
2
|
+
|
3
|
+
#### Fixed
|
4
|
+
|
5
|
+
[#1054](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1054) Conditionally apply SQL Server monkey patches to ActiveRecord so that it is safe to use this gem alongside other database adapters (e.g. PostgreSQL) in a multi-database Rails app
|
6
|
+
|
1
7
|
## v6.0.2
|
2
8
|
|
3
9
|
#### Fixed
|
data/Gemfile
CHANGED
@@ -7,9 +7,10 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
7
7
|
gemspec
|
8
8
|
|
9
9
|
gem "bcrypt"
|
10
|
-
gem "pg",
|
10
|
+
gem "pg", "~> 1.3"
|
11
11
|
gem "sqlite3", "~> 1.4"
|
12
12
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
13
|
+
gem "minitest", ">= 5.15.0", "< 5.16"
|
13
14
|
|
14
15
|
if ENV["RAILS_SOURCE"]
|
15
16
|
gemspec path: ENV["RAILS_SOURCE"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.0.
|
1
|
+
6.0.3
|
data/appveyor.yml
CHANGED
@@ -5,10 +5,10 @@ build: off
|
|
5
5
|
matrix:
|
6
6
|
fast_finish: true
|
7
7
|
allow_failures:
|
8
|
-
- ruby_version: "25"
|
9
|
-
- ruby_version: "26"
|
10
|
-
- ruby_version: "27"
|
11
8
|
- ruby_version: "27-x64"
|
9
|
+
- ruby_version: "27"
|
10
|
+
- ruby_version: "30"
|
11
|
+
- ruby_version: "30-x64"
|
12
12
|
services:
|
13
13
|
- mssql2014
|
14
14
|
|
@@ -38,9 +38,7 @@ environment:
|
|
38
38
|
CI_AZURE_PASS:
|
39
39
|
secure: cSQp8sk4urJYvq0utpsK+r7J+snJ2wpcdp8RdXJfB+w=
|
40
40
|
matrix:
|
41
|
-
- ruby_version: "25-x64"
|
42
|
-
- ruby_version: "25"
|
43
|
-
- ruby_version: "26-x64"
|
44
|
-
- ruby_version: "26"
|
45
41
|
- ruby_version: "27-x64"
|
46
42
|
- ruby_version: "27"
|
43
|
+
- ruby_version: "30"
|
44
|
+
- ruby_version: "30-x64"
|
@@ -10,6 +10,8 @@ module ActiveRecord
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def attributes_for_update(attribute_names)
|
13
|
+
return super unless self.class.connection.adapter_name == "SQLServer"
|
14
|
+
|
13
15
|
super.reject do |name|
|
14
16
|
column = self.class.columns_hash[name]
|
15
17
|
column && column.respond_to?(:is_identity?) && column.is_identity?
|
@@ -10,6 +10,8 @@ module ActiveRecord
|
|
10
10
|
module Calculations
|
11
11
|
# Same as original except we don't perform PostgreSQL hack that removes ordering.
|
12
12
|
def calculate(operation, column_name)
|
13
|
+
return super unless klass.connection.adapter_name == "SQLServer"
|
14
|
+
|
13
15
|
if has_include?(column_name)
|
14
16
|
relation = apply_join_dependency
|
15
17
|
|
@@ -29,6 +31,8 @@ module ActiveRecord
|
|
29
31
|
private
|
30
32
|
|
31
33
|
def build_count_subquery(relation, column_name, distinct)
|
34
|
+
return super unless klass.connection.adapter_name == "SQLServer"
|
35
|
+
|
32
36
|
super(relation.unscope(:order), column_name, distinct)
|
33
37
|
end
|
34
38
|
|
@@ -9,6 +9,8 @@ module ActiveRecord
|
|
9
9
|
SQLSERVER_STATEMENT_REGEXP = /N'(.+)', N'(.+)', (.+)/
|
10
10
|
|
11
11
|
def exec_explain(queries)
|
12
|
+
return super unless connection.adapter_name == "SQLServer"
|
13
|
+
|
12
14
|
unprepared_queries = queries.map do |(sql, binds)|
|
13
15
|
[unprepare_sqlserver_statement(sql, binds), binds]
|
14
16
|
end
|
@@ -12,6 +12,8 @@ module ActiveRecord
|
|
12
12
|
|
13
13
|
# Same as original except we order by values in distinct select if present.
|
14
14
|
def construct_relation_for_exists(conditions)
|
15
|
+
return super unless klass.connection.adapter_name == "SQLServer"
|
16
|
+
|
15
17
|
conditions = sanitize_forbidden_attributes(conditions)
|
16
18
|
|
17
19
|
if distinct_value && offset_value
|
@@ -10,6 +10,8 @@ module ActiveRecord
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def records_for(ids)
|
13
|
+
return super unless klass.connection.adapter_name == "SQLServer"
|
14
|
+
|
13
15
|
ids.each_slice(in_clause_length).flat_map do |slice|
|
14
16
|
scope.where(association_key_name => slice).load do |record|
|
15
17
|
# Processing only the first owner
|
data/test/cases/coerced_tests.rb
CHANGED
@@ -1088,7 +1088,8 @@ class YamlSerializationTest < ActiveRecord::TestCase
|
|
1088
1088
|
coerce_tests! :test_types_of_virtual_columns_are_not_changed_on_round_trip
|
1089
1089
|
def test_types_of_virtual_columns_are_not_changed_on_round_trip_coerced
|
1090
1090
|
author = Author.select("authors.*, 5 as posts_count").first
|
1091
|
-
|
1091
|
+
dumped_author = YAML.dump(author)
|
1092
|
+
dumped = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(dumped_author) : YAML.load(dumped_author)
|
1092
1093
|
assert_equal 5, author.posts_count
|
1093
1094
|
assert_equal 5, dumped.posts_count
|
1094
1095
|
end
|
@@ -1207,6 +1208,7 @@ module ActiveRecord
|
|
1207
1208
|
|
1208
1209
|
original_test_statement_cache_values_differ
|
1209
1210
|
ensure
|
1211
|
+
Book.where(author_id: nil, name: 'my book').delete_all
|
1210
1212
|
Book.connection.add_index(:books, [:author_id, :name], unique: true)
|
1211
1213
|
end
|
1212
1214
|
end
|
@@ -1399,6 +1401,7 @@ class EnumTest < ActiveRecord::TestCase
|
|
1399
1401
|
|
1400
1402
|
send(:'original_enums are distinct per class')
|
1401
1403
|
ensure
|
1404
|
+
Book.where(author_id: nil, name: nil).delete_all
|
1402
1405
|
Book.connection.add_index(:books, [:author_id, :name], unique: true)
|
1403
1406
|
end
|
1404
1407
|
|
@@ -1409,6 +1412,7 @@ class EnumTest < ActiveRecord::TestCase
|
|
1409
1412
|
|
1410
1413
|
send(:'original_creating new objects with enum scopes')
|
1411
1414
|
ensure
|
1415
|
+
Book.where(author_id: nil, name: nil).delete_all
|
1412
1416
|
Book.connection.add_index(:books, [:author_id, :name], unique: true)
|
1413
1417
|
end
|
1414
1418
|
|
@@ -1419,6 +1423,7 @@ class EnumTest < ActiveRecord::TestCase
|
|
1419
1423
|
|
1420
1424
|
send(:'original_enums are inheritable')
|
1421
1425
|
ensure
|
1426
|
+
Book.where(author_id: nil, name: nil).delete_all
|
1422
1427
|
Book.connection.add_index(:books, [:author_id, :name], unique: true)
|
1423
1428
|
end
|
1424
1429
|
|
@@ -1429,6 +1434,7 @@ class EnumTest < ActiveRecord::TestCase
|
|
1429
1434
|
|
1430
1435
|
send(:'original_declare multiple enums at a time')
|
1431
1436
|
ensure
|
1437
|
+
Book.where(author_id: nil, name: nil).delete_all
|
1432
1438
|
Book.connection.add_index(:books, [:author_id, :name], unique: true)
|
1433
1439
|
end
|
1434
1440
|
end
|
@@ -1522,3 +1528,76 @@ class ReloadModelsTest < ActiveRecord::TestCase
|
|
1522
1528
|
# `activesupport/lib/active_support/testing/isolation.rb` exceeds what Windows can handle.
|
1523
1529
|
coerce_tests! :test_has_one_with_reload if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
1524
1530
|
end
|
1531
|
+
|
1532
|
+
require "models/post"
|
1533
|
+
class AnnotateTest < ActiveRecord::TestCase
|
1534
|
+
# Same as original coerced test except our SQL starts with `EXEC sp_executesql`.
|
1535
|
+
# TODO: Remove coerce after Rails 7 (see https://github.com/rails/rails/pull/42027)
|
1536
|
+
coerce_tests! :test_annotate_wraps_content_in_an_inline_comment
|
1537
|
+
def test_annotate_wraps_content_in_an_inline_comment_coerced
|
1538
|
+
quoted_posts_id, quoted_posts = regexp_escape_table_name("posts.id"), regexp_escape_table_name("posts")
|
1539
|
+
|
1540
|
+
assert_sql(%r{SELECT #{quoted_posts_id} FROM #{quoted_posts} /\* foo \*/}i) do
|
1541
|
+
posts = Post.select(:id).annotate("foo")
|
1542
|
+
assert posts.first
|
1543
|
+
end
|
1544
|
+
end
|
1545
|
+
|
1546
|
+
# Same as original coerced test except our SQL starts with `EXEC sp_executesql`.
|
1547
|
+
# TODO: Remove coerce after Rails 7 (see https://github.com/rails/rails/pull/42027)
|
1548
|
+
coerce_tests! :test_annotate_is_sanitized
|
1549
|
+
def test_annotate_is_sanitized_coerced
|
1550
|
+
quoted_posts_id, quoted_posts = regexp_escape_table_name("posts.id"), regexp_escape_table_name("posts")
|
1551
|
+
|
1552
|
+
assert_sql(%r{SELECT #{quoted_posts_id} FROM #{quoted_posts} /\* \* /foo/ \* \*/}i) do
|
1553
|
+
posts = Post.select(:id).annotate("*/foo/*")
|
1554
|
+
assert posts.first
|
1555
|
+
end
|
1556
|
+
|
1557
|
+
assert_sql(%r{SELECT #{quoted_posts_id} FROM #{quoted_posts} /\* \*\* //foo// \*\* \*/}i) do
|
1558
|
+
posts = Post.select(:id).annotate("**//foo//**")
|
1559
|
+
assert posts.first
|
1560
|
+
end
|
1561
|
+
|
1562
|
+
assert_sql(%r{SELECT #{quoted_posts_id} FROM #{quoted_posts} /\* \* \* //foo// \* \* \*/}i) do
|
1563
|
+
posts = Post.select(:id).annotate("* *//foo//* *")
|
1564
|
+
assert posts.first
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
assert_sql(%r{SELECT #{quoted_posts_id} FROM #{quoted_posts} /\* \* /foo/ \* \*/ /\* \* /bar \*/}i) do
|
1568
|
+
posts = Post.select(:id).annotate("*/foo/*").annotate("*/bar")
|
1569
|
+
assert posts.first
|
1570
|
+
end
|
1571
|
+
|
1572
|
+
assert_sql(%r{SELECT #{quoted_posts_id} FROM #{quoted_posts} /\* \+ MAX_EXECUTION_TIME\(1\) \*/}i) do
|
1573
|
+
posts = Post.select(:id).annotate("+ MAX_EXECUTION_TIME(1)")
|
1574
|
+
assert posts.first
|
1575
|
+
end
|
1576
|
+
end
|
1577
|
+
end
|
1578
|
+
|
1579
|
+
class NestedThroughAssociationsTest < ActiveRecord::TestCase
|
1580
|
+
# Same as original but replace order with "order(:id)" to ensure that assert_includes_and_joins_equal doesn't raise
|
1581
|
+
# "A column has been specified more than once in the order by list"
|
1582
|
+
# Example: original test generate queries like "ORDER BY authors.id, [authors].[id]". We don't support duplicate columns in the order list
|
1583
|
+
coerce_tests! :test_has_many_through_has_many_with_has_many_through_habtm_source_reflection_preload_via_joins, :test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflection_preload_via_joins
|
1584
|
+
def test_has_many_through_has_many_with_has_many_through_habtm_source_reflection_preload_via_joins_coerced
|
1585
|
+
# preload table schemas
|
1586
|
+
Author.joins(:category_post_comments).first
|
1587
|
+
|
1588
|
+
assert_includes_and_joins_equal(
|
1589
|
+
Author.where("comments.id" => comments(:does_it_hurt).id).order(:id),
|
1590
|
+
[authors(:david), authors(:mary)], :category_post_comments
|
1591
|
+
)
|
1592
|
+
end
|
1593
|
+
|
1594
|
+
def test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflection_preload_via_joins_coerced
|
1595
|
+
# preload table schemas
|
1596
|
+
Category.joins(:post_comments).first
|
1597
|
+
|
1598
|
+
assert_includes_and_joins_equal(
|
1599
|
+
Category.where("comments.id" => comments(:more_greetings).id).order(:id),
|
1600
|
+
[categories(:general), categories(:technology)], :post_comments
|
1601
|
+
)
|
1602
|
+
end
|
1603
|
+
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: 6.0.
|
4
|
+
version: 6.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date:
|
17
|
+
date: 2023-05-23 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -217,8 +217,8 @@ licenses:
|
|
217
217
|
- MIT
|
218
218
|
metadata:
|
219
219
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
220
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v6.0.
|
221
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v6.0.
|
220
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v6.0.3/CHANGELOG.md
|
221
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v6.0.3
|
222
222
|
post_install_message:
|
223
223
|
rdoc_options: []
|
224
224
|
require_paths:
|
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
|
-
rubygems_version: 3.
|
237
|
+
rubygems_version: 3.4.7
|
238
238
|
signing_key:
|
239
239
|
specification_version: 4
|
240
240
|
summary: ActiveRecord SQL Server Adapter.
|