activerecord-sqlserver-adapter 7.0.1.0 → 7.0.2.0
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 -3
- data/CHANGELOG.md +8 -0
- data/Dockerfile.ci +2 -2
- data/VERSION +1 -1
- data/docker-compose.ci.yml +1 -1
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +6 -8
- data/test/cases/adapter_test_sqlserver.rb +1 -1
- data/test/cases/schema_test_sqlserver.rb +7 -0
- data/test/models/sqlserver/alien.rb +5 -0
- data/test/schema/sqlserver_specific_schema.rb +7 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c5135f809d1709197eef056bbac22e09adefd4ead979cc32e72a2e12c52453a
|
4
|
+
data.tar.gz: 6a0f0b78026468b273926d259a93c7edb38dc8de176f88e32d8bd64c1667c90c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299fe79b88ebbfb2edfac1145c4969c3cde3e7eec25bf5415e671b8bc5e3564cf66cca398a1ca7285cc1b4950a0a0326162860b359a41e018c4bae8c058921ba
|
7
|
+
data.tar.gz: 13566655cfaba356a7b1a1f63e95ad2a38ab0a95a6f85eaf9af4571e04ee1db03e8b2cbd4a9d58599de289c3769046e27ee23ef3898219ecc55fd24f7ec31faf
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## v7.0.2.0
|
2
|
+
|
3
|
+
[Full changelog](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/compare/v7.0.1.0...v7.0.2.0)
|
4
|
+
|
5
|
+
#### Fixed
|
6
|
+
|
7
|
+
- [#1049](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1049) Fix for inserting records into non-dbo schema table.
|
8
|
+
|
1
9
|
## v7.0.1.0
|
2
10
|
|
3
11
|
[Full changelog](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/compare/v7.0.0.0...v7.0.1.0)
|
data/Dockerfile.ci
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.0.
|
1
|
+
7.0.2.0
|
data/docker-compose.ci.yml
CHANGED
@@ -397,14 +397,12 @@ module ActiveRecord
|
|
397
397
|
end
|
398
398
|
|
399
399
|
def query_requires_identity_insert?(sql)
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
false
|
407
|
-
end
|
400
|
+
return false unless insert_sql?(sql)
|
401
|
+
|
402
|
+
raw_table_name = get_raw_table_name(sql)
|
403
|
+
id_column = identity_columns(raw_table_name).first
|
404
|
+
|
405
|
+
id_column && sql =~ /^\s*(INSERT|EXEC sp_executesql N'INSERT)[^(]+\([^)]*\b(#{id_column.name})\b,?[^)]*\)/i ? SQLServer::Utils.extract_identifiers(raw_table_name).object : false
|
408
406
|
end
|
409
407
|
|
410
408
|
def insert_sql?(sql)
|
@@ -197,7 +197,7 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
197
197
|
@identity_insert_sql_unordered_sp = "EXEC sp_executesql N'INSERT INTO [funny_jokes] ([name],[id]) VALUES (@0, @1)', N'@0 nvarchar(255), @1 int', @0 = N'Knock knock', @1 = 420"
|
198
198
|
end
|
199
199
|
|
200
|
-
it "return
|
200
|
+
it "return unquoted table_name to #query_requires_identity_insert? when INSERT sql contains id column" do
|
201
201
|
assert_equal "funny_jokes", connection.send(:query_requires_identity_insert?, @identity_insert_sql)
|
202
202
|
assert_equal "funny_jokes", connection.send(:query_requires_identity_insert?, @identity_insert_sql_unquoted)
|
203
203
|
assert_equal "funny_jokes", connection.send(:query_requires_identity_insert?, @identity_insert_sql_unordered)
|
@@ -21,6 +21,7 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
|
|
21
21
|
|
22
22
|
it "have only one identity column" do
|
23
23
|
columns = connection.columns("test.sst_schema_identity")
|
24
|
+
|
24
25
|
assert_equal 2, columns.size
|
25
26
|
assert_equal 1, columns.select { |c| c.is_identity? }.size
|
26
27
|
end
|
@@ -29,6 +30,7 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
|
|
29
30
|
test_columns = connection.columns("test.sst_schema_columns")
|
30
31
|
dbo_columns = connection.columns("dbo.sst_schema_columns")
|
31
32
|
columns = connection.columns("sst_schema_columns") # This returns table from dbo schema
|
33
|
+
|
32
34
|
assert_equal 7, test_columns.size
|
33
35
|
assert_equal 2, dbo_columns.size
|
34
36
|
assert_equal 2, columns.size
|
@@ -39,10 +41,15 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
|
|
39
41
|
|
40
42
|
it "return correct varchar and nvarchar column limit length when table is in non dbo schema" do
|
41
43
|
columns = connection.columns("test.sst_schema_columns")
|
44
|
+
|
42
45
|
assert_equal 255, columns.find { |c| c.name == "name" }.limit
|
43
46
|
assert_equal 1000, columns.find { |c| c.name == "description" }.limit
|
44
47
|
assert_equal 255, columns.find { |c| c.name == "n_name" }.limit
|
45
48
|
assert_equal 1000, columns.find { |c| c.name == "n_description" }.limit
|
46
49
|
end
|
50
|
+
|
51
|
+
it "creates new record" do
|
52
|
+
Alien.create!(name: 'Trisolarans')
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
@@ -312,4 +312,11 @@ ActiveRecord::Schema.define do
|
|
312
312
|
CONSTRAINT PK_sst_composite_with_identity PRIMARY KEY (pk_col_one, pk_col_two)
|
313
313
|
);
|
314
314
|
COMPOSITE_WITH_IDENTITY
|
315
|
+
|
316
|
+
execute "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'aliens' and TABLE_SCHEMA = 'test') DROP TABLE test.aliens"
|
317
|
+
execute <<-TABLE_IN_OTHER_SCHEMA_USED_BY_MODEL
|
318
|
+
CREATE TABLE test.aliens(
|
319
|
+
name varchar(255)
|
320
|
+
)
|
321
|
+
TABLE_IN_OTHER_SCHEMA_USED_BY_MODEL
|
315
322
|
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.2.0
|
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: 2023-
|
17
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- test/migrations/create_clients_and_change_column_collation.rb
|
182
182
|
- test/migrations/create_clients_and_change_column_null.rb
|
183
183
|
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|
184
|
+
- test/models/sqlserver/alien.rb
|
184
185
|
- test/models/sqlserver/booking.rb
|
185
186
|
- test/models/sqlserver/composite_pk.rb
|
186
187
|
- test/models/sqlserver/customers_view.rb
|
@@ -227,8 +228,8 @@ licenses:
|
|
227
228
|
- MIT
|
228
229
|
metadata:
|
229
230
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
230
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.
|
231
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.
|
231
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.0.2.0/CHANGELOG.md
|
232
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.2.0
|
232
233
|
post_install_message:
|
233
234
|
rdoc_options: []
|
234
235
|
require_paths:
|
@@ -293,6 +294,7 @@ test_files:
|
|
293
294
|
- test/migrations/create_clients_and_change_column_collation.rb
|
294
295
|
- test/migrations/create_clients_and_change_column_null.rb
|
295
296
|
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|
297
|
+
- test/models/sqlserver/alien.rb
|
296
298
|
- test/models/sqlserver/booking.rb
|
297
299
|
- test/models/sqlserver/composite_pk.rb
|
298
300
|
- test/models/sqlserver/customers_view.rb
|