activerecord-sqlserver-adapter 7.0.5.1 → 7.0.7

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: 02401b4f2142fc0cdebfd2308b94647ab6dc927c77542d4125dae6b6184e7e1c
4
- data.tar.gz: c4d0d77af6f8344846387c14b1b84977b5af321bc7b2e9cf208bdab59179363d
3
+ metadata.gz: 83388c1406fff2ac06215c523b54148362c6eadfbb56a32555cc36e9a95b42b6
4
+ data.tar.gz: 9b7230a6317df5393e15adc93486dea74701c38b8d25cb176a6c2961cdd27b86
5
5
  SHA512:
6
- metadata.gz: e37d3daf2d7a509ef38eb45218fc3db5d4c60938ac2b8687a7f53a5e516df6fa3fa29dea71914d469336ebb8a7020921f5b479917afe78654d05048b51dd3911
7
- data.tar.gz: 91a4c0bb6729b16736885cc7b2a89e7a80abbb11580bc02b31bb83dc4c3e2b72eb2e10815ae85af7e5a28f9990a8e7bea102345d146fa8323593605a32ec2bda
6
+ metadata.gz: 58c3429ed5900c289e059d6047dfef313b8a91fca2f43bbe2c95004a16b99e5cb9255d9715ac531a34fb2db9c7b7acf77ff81bb9a9c43e3e31e90116f2bc0da8
7
+ data.tar.gz: 91c41e4809dfca4809cd8899a60d80325310999adce340a70d672aefacd06f61ddc885260908b12a5d444df3cb1008a993276ccd9640f38ff59a6df4cd6c9346
@@ -14,7 +14,6 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  ruby:
17
- - 2.7.7
18
17
  - 3.1.3
19
18
  - 3.2.1
20
19
 
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
1
  nbproject/
2
- debug.log
2
+ debug.log*
3
3
  .DS_Store
4
4
  pkg/
5
5
  doc/
@@ -16,3 +16,5 @@ coverage/*
16
16
  .flooignore
17
17
  .floo
18
18
  .byebug_history
19
+ tmp/*
20
+ test/storage/test.sqlite3*
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## v7.0.7
2
+
3
+ #### Changed
4
+
5
+ - [#1200](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1200) Remove ActiveRecord::Relation#calculate patch
6
+
7
+ ## v7.0.6
8
+
9
+ #### Added
10
+
11
+ - [#1141](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1141) Added support for check constraints.
12
+
1
13
  ## v7.0.5.1
2
14
 
3
15
  #### Fixed
data/README.md CHANGED
@@ -12,11 +12,11 @@ The SQL Server adapter for ActiveRecord using SQL Server 2012 or higher.
12
12
  Interested in older versions? We follow a rational versioning policy that tracks Rails. That means that our 7.x version of the adapter is only for the latest 7.x version of Rails. If you need the adapter for SQL Server 2008 or 2005, you are still in the right spot. Just install the latest 3.2.x to 4.1.x version of the adapter that matches your Rails version. We also have stable branches for each major/minor release of ActiveRecord.
13
13
 
14
14
  | Adapter Version | Rails Version | Support |
15
- |-----------------| ------------- | ------------------------------------------------------------------------------------------- |
16
- | `7.0.5.1` | `7.0.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
15
+ |-----------------| ------------- |---------------------------------------------------------------------------------------------|
16
+ | `7.0.7` | `7.0.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/7-0-stable) |
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
- | `5.2.1` | `5.2.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-2-stable) |
19
+ | `5.2.1` | `5.2.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-2-stable) |
20
20
  | `5.1.6` | `5.1.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-1-stable) |
21
21
  | `4.2.18` | `4.2.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/4-2-stable) |
22
22
  | `4.1.8` | `4.1.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/4-1-stable) |
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.0.5.1
1
+ 7.0.7
@@ -8,25 +8,6 @@ module ActiveRecord
8
8
  module SQLServer
9
9
  module CoreExt
10
10
  module Calculations
11
- # Same as original except we don't perform PostgreSQL hack that removes ordering.
12
- def calculate(operation, column_name)
13
- return super unless klass.connection.adapter_name == "SQLServer"
14
-
15
- if has_include?(column_name)
16
- relation = apply_join_dependency
17
-
18
- if operation.to_s.downcase == "count"
19
- unless distinct_value || distinct_select?(column_name || select_for_count)
20
- relation.distinct!
21
- relation.select_values = [klass.primary_key || table[Arel.star]]
22
- end
23
- end
24
-
25
- relation.calculate(operation, column_name)
26
- else
27
- perform_calculation(operation, column_name)
28
- end
29
- end
30
11
 
31
12
  private
32
13
 
@@ -240,6 +240,29 @@ module ActiveRecord
240
240
  end
241
241
  end
242
242
 
243
+ def check_constraints(table_name)
244
+ sql = <<~SQL
245
+ select chk.name AS 'name',
246
+ chk.definition AS 'expression'
247
+ from sys.check_constraints chk
248
+ inner join sys.tables st on chk.parent_object_id = st.object_id
249
+ where
250
+ st.name = '#{table_name}'
251
+ SQL
252
+
253
+ chk_info = exec_query(sql, "SCHEMA")
254
+
255
+ chk_info.map do |row|
256
+ options = {
257
+ name: row["name"]
258
+ }
259
+ expression = row["expression"]
260
+ expression = expression[1..-2] if expression.start_with?("(") && expression.end_with?(")")
261
+
262
+ CheckConstraintDefinition.new(table_name, expression, options)
263
+ end
264
+ end
265
+
243
266
  def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
244
267
  type_limitable = %w(string integer float char nchar varchar nvarchar).include?(type.to_s)
245
268
  limit = nil unless type_limitable
@@ -228,6 +228,10 @@ module ActiveRecord
228
228
  true
229
229
  end
230
230
 
231
+ def supports_check_constraints?
232
+ true
233
+ end
234
+
231
235
  def supports_json?
232
236
  @version_year >= 2016
233
237
  end
@@ -1449,6 +1449,13 @@ class SchemaDumperTest < ActiveRecord::TestCase
1449
1449
  output = dump_all_table_schema([/^[^n]/])
1450
1450
  assert_match %r{precision: 3,[[:space:]]+scale: 2,[[:space:]]+default: 2\.78}, output
1451
1451
  end
1452
+
1453
+ # SQL Server formats the check constraint expression differently.
1454
+ coerce_tests! :test_schema_dumps_check_constraints
1455
+ def test_schema_dumps_check_constraints_coerced
1456
+ constraint_definition = dump_table_schema("products").split(/\n/).grep(/t.check_constraint.*products_price_check/).first.strip
1457
+ assert_equal 't.check_constraint "[price]>[discounted_price]", name: "products_price_check"', constraint_definition
1458
+ end
1452
1459
  end
1453
1460
 
1454
1461
  class SchemaDumperDefaultsTest < ActiveRecord::TestCase
@@ -2150,7 +2157,7 @@ class FieldOrderedValuesTest < ActiveRecord::TestCase
2150
2157
  coerce_tests! :test_in_order_of_with_nil
2151
2158
  def test_in_order_of_with_nil_coerced
2152
2159
  Book.connection.remove_index(:books, column: [:author_id, :name])
2153
-
2160
+
2154
2161
  original_test_in_order_of_with_nil
2155
2162
  ensure
2156
2163
  Book.where(author_id: nil, name: nil).delete_all
@@ -2294,3 +2301,51 @@ class ActiveRecord::Encryption::EncryptableRecordTest < ActiveRecord::Encryption
2294
2301
  assert_not author.valid?
2295
2302
  end
2296
2303
  end
2304
+
2305
+ module ActiveRecord
2306
+ class Migration
2307
+ class CheckConstraintTest < ActiveRecord::TestCase
2308
+ # SQL Server formats the check constraint expression differently.
2309
+ coerce_tests! :test_check_constraints
2310
+ def test_check_constraints_coerced
2311
+ check_constraints = @connection.check_constraints("products")
2312
+ assert_equal 1, check_constraints.size
2313
+
2314
+ constraint = check_constraints.first
2315
+ assert_equal "products", constraint.table_name
2316
+ assert_equal "products_price_check", constraint.name
2317
+ assert_equal "[price]>[discounted_price]", constraint.expression
2318
+ end
2319
+
2320
+ # SQL Server formats the check constraint expression differently.
2321
+ coerce_tests! :test_add_check_constraint
2322
+ def test_add_check_constraint_coerced
2323
+ @connection.add_check_constraint :trades, "quantity > 0"
2324
+
2325
+ check_constraints = @connection.check_constraints("trades")
2326
+ assert_equal 1, check_constraints.size
2327
+
2328
+ constraint = check_constraints.first
2329
+ assert_equal "trades", constraint.table_name
2330
+ assert_equal "chk_rails_2189e9f96c", constraint.name
2331
+ assert_equal "[quantity]>(0)", constraint.expression
2332
+ end
2333
+
2334
+ # SQL Server formats the check constraint expression differently.
2335
+ coerce_tests! :test_remove_check_constraint
2336
+ def test_remove_check_constraint_coerced
2337
+ @connection.add_check_constraint :trades, "price > 0", name: "price_check"
2338
+ @connection.add_check_constraint :trades, "quantity > 0", name: "quantity_check"
2339
+
2340
+ assert_equal 2, @connection.check_constraints("trades").size
2341
+ @connection.remove_check_constraint :trades, name: "quantity_check"
2342
+ assert_equal 1, @connection.check_constraints("trades").size
2343
+
2344
+ constraint = @connection.check_constraints("trades").first
2345
+ assert_equal "trades", constraint.table_name
2346
+ assert_equal "price_check", constraint.name
2347
+ assert_equal "[price]>(0)", constraint.expression
2348
+ end
2349
+ end
2350
+ end
2351
+ 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.1
4
+ version: 7.0.7
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-08 00:00:00.000000000 Z
18
+ date: 2024-07-04 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.1/CHANGELOG.md
235
- source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.5.1
234
+ changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.7/CHANGELOG.md
235
+ source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.7
236
236
  post_install_message:
237
237
  rdoc_options: []
238
238
  require_paths:
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  - !ruby/object:Gem::Version
249
249
  version: '0'
250
250
  requirements: []
251
- rubygems_version: 3.4.7
251
+ rubygems_version: 3.4.22
252
252
  signing_key:
253
253
  specification_version: 4
254
254
  summary: ActiveRecord SQL Server Adapter.