activerecord-sqlserver-adapter 7.1.0.rc2 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +10 -10
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +23 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +4 -0
- data/test/cases/coerced_tests.rb +58 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58c19846ce74967bacd12d1accd41c82b31f2fb04829ee8a19ea529f73dd97a7
|
4
|
+
data.tar.gz: 81d8ea6ee564704c1bf0178c3e28de18979892a0b18881eb3cee2f5d96052101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9369b4c86d3ea8ef36eeb47a19e5e2bc5a31024ead3aa1e1d535346a486526e0e9e196d95e8f2667a57d1532f8daa5f48b7909e657eb2c699450480e23974e85
|
7
|
+
data.tar.gz: c10c097a4ebd447e7dd25b6f6235023773a15bbf8c3650c7cc3e73cee27b4a37c82a85b493b807b71bf5fd971258fd40300e3696b3a92f4a8e585f55e0562cf0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,16 +11,16 @@ The SQL Server adapter for ActiveRecord using SQL Server 2012 or higher.
|
|
11
11
|
|
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
|
-
| Adapter Version | Rails Version | Support
|
15
|
-
|
16
|
-
| `7.1.0
|
17
|
-
| `7.0.5.1` | `7.0.x` | Active
|
18
|
-
| `6.1.3.0` | `6.1.x` | Active
|
19
|
-
| `6.0.3` | `6.0.x` | Ended
|
20
|
-
| `5.2.1` | `5.2.x` | Ended
|
21
|
-
| `5.1.6` | `5.1.x` | Ended
|
22
|
-
| `4.2.18` | `4.2.x` | Ended
|
23
|
-
| `4.1.8` | `4.1.x` | Ended
|
14
|
+
| Adapter Version | Rails Version | Support | Branch |
|
15
|
+
|-----------------|---------------|---------|--------------------------------------------------------------------------------------------------|
|
16
|
+
| `7.1.0` | `7.1.x` | Active | [main](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
|
17
|
+
| `7.0.5.1` | `7.0.x` | Active | [7-0-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/7-0-stable) |
|
18
|
+
| `6.1.3.0` | `6.1.x` | Active | [6-1-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-1-stable) |
|
19
|
+
| `6.0.3` | `6.0.x` | Ended | [6-0-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-0-stable) |
|
20
|
+
| `5.2.1` | `5.2.x` | Ended | [5-2-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-2-stable) |
|
21
|
+
| `5.1.6` | `5.1.x` | Ended | [5-1-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-1-stable) |
|
22
|
+
| `4.2.18` | `4.2.x` | Ended | [4-2-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/4-2-stable) |
|
23
|
+
| `4.1.8` | `4.1.x` | Ended | [4-1-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/4-1-stable) |
|
24
24
|
|
25
25
|
For older versions, please check their stable branches.
|
26
26
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.1.0
|
1
|
+
7.1.0
|
@@ -267,6 +267,29 @@ module ActiveRecord
|
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
|
+
def check_constraints(table_name)
|
271
|
+
sql = <<~SQL
|
272
|
+
select chk.name AS 'name',
|
273
|
+
chk.definition AS 'expression'
|
274
|
+
from sys.check_constraints chk
|
275
|
+
inner join sys.tables st on chk.parent_object_id = st.object_id
|
276
|
+
where
|
277
|
+
st.name = '#{table_name}'
|
278
|
+
SQL
|
279
|
+
|
280
|
+
chk_info = internal_exec_query(sql, "SCHEMA")
|
281
|
+
|
282
|
+
chk_info.map do |row|
|
283
|
+
options = {
|
284
|
+
name: row["name"]
|
285
|
+
}
|
286
|
+
expression = row["expression"]
|
287
|
+
expression = expression[1..-2] if expression.start_with?("(") && expression.end_with?(")")
|
288
|
+
|
289
|
+
CheckConstraintDefinition.new(table_name, expression, options)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
270
293
|
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
|
271
294
|
type_limitable = %w(string integer float char nchar varchar nvarchar).include?(type.to_s)
|
272
295
|
limit = nil unless type_limitable
|
data/test/cases/coerced_tests.rb
CHANGED
@@ -1580,6 +1580,13 @@ class SchemaDumperTest < ActiveRecord::TestCase
|
|
1580
1580
|
|
1581
1581
|
# Tests are not about a specific adapter.
|
1582
1582
|
coerce_tests! :test_do_not_dump_foreign_keys_when_bypassed_by_config
|
1583
|
+
|
1584
|
+
# SQL Server formats the check constraint expression differently.
|
1585
|
+
coerce_tests! :test_schema_dumps_check_constraints
|
1586
|
+
def test_schema_dumps_check_constraints_coerced
|
1587
|
+
constraint_definition = dump_table_schema("products").split(/\n/).grep(/t.check_constraint.*products_price_check/).first.strip
|
1588
|
+
assert_equal 't.check_constraint "[price]>[discounted_price]", name: "products_price_check"', constraint_definition
|
1589
|
+
end
|
1583
1590
|
end
|
1584
1591
|
|
1585
1592
|
class SchemaDumperDefaultsTest < ActiveRecord::TestCase
|
@@ -2585,3 +2592,54 @@ module ActiveRecord
|
|
2585
2592
|
end
|
2586
2593
|
end
|
2587
2594
|
end
|
2595
|
+
|
2596
|
+
module ActiveRecord
|
2597
|
+
class Migration
|
2598
|
+
class CheckConstraintTest < ActiveRecord::TestCase
|
2599
|
+
# SQL Server formats the check constraint expression differently.
|
2600
|
+
coerce_tests! :test_check_constraints
|
2601
|
+
def test_check_constraints_coerced
|
2602
|
+
check_constraints = @connection.check_constraints("products")
|
2603
|
+
assert_equal 1, check_constraints.size
|
2604
|
+
|
2605
|
+
constraint = check_constraints.first
|
2606
|
+
assert_equal "products", constraint.table_name
|
2607
|
+
assert_equal "products_price_check", constraint.name
|
2608
|
+
assert_equal "[price]>[discounted_price]", constraint.expression
|
2609
|
+
end
|
2610
|
+
|
2611
|
+
# SQL Server formats the check constraint expression differently.
|
2612
|
+
coerce_tests! :test_add_check_constraint
|
2613
|
+
def test_add_check_constraint_coerced
|
2614
|
+
@connection.add_check_constraint :trades, "quantity > 0"
|
2615
|
+
|
2616
|
+
check_constraints = @connection.check_constraints("trades")
|
2617
|
+
assert_equal 1, check_constraints.size
|
2618
|
+
|
2619
|
+
constraint = check_constraints.first
|
2620
|
+
assert_equal "trades", constraint.table_name
|
2621
|
+
assert_equal "chk_rails_2189e9f96c", constraint.name
|
2622
|
+
assert_equal "[quantity]>(0)", constraint.expression
|
2623
|
+
end
|
2624
|
+
|
2625
|
+
# SQL Server formats the check constraint expression differently.
|
2626
|
+
coerce_tests! :test_remove_check_constraint
|
2627
|
+
def test_remove_check_constraint_coerced
|
2628
|
+
@connection.add_check_constraint :trades, "price > 0", name: "price_check"
|
2629
|
+
@connection.add_check_constraint :trades, "quantity > 0", name: "quantity_check"
|
2630
|
+
|
2631
|
+
assert_equal 2, @connection.check_constraints("trades").size
|
2632
|
+
@connection.remove_check_constraint :trades, name: "quantity_check"
|
2633
|
+
assert_equal 1, @connection.check_constraints("trades").size
|
2634
|
+
|
2635
|
+
constraint = @connection.check_constraints("trades").first
|
2636
|
+
assert_equal "trades", constraint.table_name
|
2637
|
+
assert_equal "price_check", constraint.name
|
2638
|
+
assert_equal "[price]>(0)", constraint.expression
|
2639
|
+
|
2640
|
+
@connection.remove_check_constraint :trades, name: :price_check # name as a symbol
|
2641
|
+
assert_empty @connection.check_constraints("trades")
|
2642
|
+
end
|
2643
|
+
end
|
2644
|
+
end
|
2645
|
+
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.1.0
|
4
|
+
version: 7.1.0
|
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-
|
18
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
@@ -235,8 +235,8 @@ licenses:
|
|
235
235
|
- MIT
|
236
236
|
metadata:
|
237
237
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
238
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.1.0
|
239
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.1.0
|
238
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.1.0/CHANGELOG.md
|
239
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.1.0
|
240
240
|
post_install_message:
|
241
241
|
rdoc_options: []
|
242
242
|
require_paths:
|
@@ -248,9 +248,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
248
248
|
version: 2.7.0
|
249
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
250
|
requirements:
|
251
|
-
- - "
|
251
|
+
- - ">="
|
252
252
|
- !ruby/object:Gem::Version
|
253
|
-
version:
|
253
|
+
version: '0'
|
254
254
|
requirements: []
|
255
255
|
rubygems_version: 3.4.7
|
256
256
|
signing_key:
|