activerecord-sqlserver-adapter 7.2.2 → 7.2.3

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: dba9ea79e6287b945d1c8fba8894559510999b58272b968f69953630d94eb484
4
- data.tar.gz: 9abcab548b00c1c906e26ebbb5f1d18982529c605452d447fba3b0a081f5046d
3
+ metadata.gz: 05376f4fb4ac7599dc2f61c926eed10a587bb21f34c68dc47de9025d2a031d6d
4
+ data.tar.gz: cadbc6f8881d3f8cc70bfa2892abb3a7de2f6805c932c960bc0212c8376fc904
5
5
  SHA512:
6
- metadata.gz: cba19ac223013b55bc0d67fade1dc8b8d0a80dc05175bebcc5ba209e28a3980d271f8d9240a92ec8d2cebba2ae33049581d21c0a30c5f9e188ca9150909d5bb3
7
- data.tar.gz: e4feae1a11d2f000c1f75b81e6e5600a5abb0c08ea3220b26bf8d681aa881e34ebafb212ad0ae8a85280ae3d72401f27855e2af0e79f42521e6cdb5b56334907
6
+ metadata.gz: 4ed7c2b41c36c70c0efc188421238224c80093d83430756028d3108402302cb75fe03ca8d07990322fd4c4f58d9e0da51b1180cd310963c34ebd11a15bab65ab
7
+ data.tar.gz: 5a4e6f2a659c0fb23e0feadd04d8489f3ac9679767a94f4cf4e4da46de52f0cd70da617cada139ded171efbef2e342833b3967b8bdf2feb4eb48062eb8323d85
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v7.2.3
2
+
3
+ #### Fixed
4
+
5
+ - [#1262](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1262) Fix distinct alias when multiple databases used.
6
+
1
7
  ## v7.2.2
2
8
 
3
9
  #### Fixed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.2.2
1
+ 7.2.3
@@ -347,12 +347,16 @@ module ActiveRecord
347
347
 
348
348
  def columns_for_distinct(columns, orders)
349
349
  order_columns = orders.reject(&:blank?).map { |s|
350
- s = s.to_sql unless s.is_a?(String)
350
+ s = visitor.compile(s) unless s.is_a?(String)
351
351
  s.gsub(/\s+(?:ASC|DESC)\b/i, "")
352
352
  .gsub(/\s+NULLS\s+(?:FIRST|LAST)\b/i, "")
353
- }.reject(&:blank?).map.with_index { |column, i| "#{column} AS alias_#{i}" }
353
+ }
354
+ .reject(&:blank?)
355
+ .reject { |s| columns.include?(s) }
354
356
 
355
- (order_columns << super).join(", ")
357
+ order_columns_aliased = order_columns.map.with_index { |column, i| "#{column} AS alias_#{i}" }
358
+
359
+ (order_columns_aliased << super).join(", ")
356
360
  end
357
361
 
358
362
  def update_table_definition(table_name, base)
@@ -594,4 +594,13 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
594
594
  assert_equal Task.where("starting < ?", DateTime.current).count, 1
595
595
  end
596
596
  end
597
+
598
+ describe "distinct select query" do
599
+ it "generated SQL does not contain unnecessary alias projection" do
600
+ sqls = capture_sql do
601
+ Post.includes(:comments).joins(:comments).first
602
+ end
603
+ assert_no_match(/AS alias_0/, sqls.first)
604
+ end
605
+ end
597
606
  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.2.2
4
+ version: 7.2.3
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: 2024-11-10 00:00:00.000000000 Z
18
+ date: 2024-12-08 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord
@@ -239,8 +239,8 @@ licenses:
239
239
  - MIT
240
240
  metadata:
241
241
  bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
242
- changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.2/CHANGELOG.md
243
- source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.2
242
+ changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.3/CHANGELOG.md
243
+ source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.3
244
244
  post_install_message:
245
245
  rdoc_options: []
246
246
  require_paths: