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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b2be5773d5cd15b49d3e11adcb9f464730316716e28823ed517b21f4bcff205
4
- data.tar.gz: 69588165e5c5fb13f262c3aab89a43fb33da26c0c4688fc4d26bbc1e754c1341
3
+ metadata.gz: 9c5135f809d1709197eef056bbac22e09adefd4ead979cc32e72a2e12c52453a
4
+ data.tar.gz: 6a0f0b78026468b273926d259a93c7edb38dc8de176f88e32d8bd64c1667c90c
5
5
  SHA512:
6
- metadata.gz: e3dcbc98ce8064c3e44ccab64c197ef9aeb3ce2e34c0f1829eabf5d16157a984d4f2f151b2ea69586ce1247b55363c6a210ca14c3cd8952151e52ce9ee7dff09
7
- data.tar.gz: 8ac25a4fc712a546b395e30c38936a98350b97826f8868ad2d8e4d378efe0065730619248da93991ba08dbb283303c9ccbeb7e5a5d0492fc5252b97395eb66cb
6
+ metadata.gz: 299fe79b88ebbfb2edfac1145c4969c3cde3e7eec25bf5415e671b8bc5e3564cf66cca398a1ca7285cc1b4950a0a0326162860b359a41e018c4bae8c058921ba
7
+ data.tar.gz: 13566655cfaba356a7b1a1f63e95ad2a38ab0a95a6f85eaf9af4571e04ee1db03e8b2cbd4a9d58599de289c3769046e27ee23ef3898219ecc55fd24f7ec31faf
@@ -14,9 +14,9 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  ruby:
17
- - 2.7.5
18
- - 3.0.3
19
- - 3.1.0
17
+ - 2.7.7
18
+ - 3.1.3
19
+ - 3.2.1
20
20
 
21
21
  steps:
22
22
  - name: Checkout code
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
@@ -1,6 +1,6 @@
1
- ARG TARGET_VERSION=2.6.3
1
+ ARG TARGET_VERSION=3.2.1
2
2
 
3
- FROM railssqlserver/activerecord-sqlserver-adapter:${TARGET_VERSION}
3
+ FROM ghcr.io/rails-sqlserver/activerecord-sqlserver-adapter:${TARGET_VERSION}
4
4
 
5
5
  ENV WORKDIR /activerecord-sqlserver-adapter
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.0.1.0
1
+ 7.0.2.0
@@ -1,7 +1,7 @@
1
1
  version: "2.2"
2
2
  services:
3
3
  sqlserver:
4
- image: metaskills/mssql-server-linux-rails
4
+ image: ghcr.io/rails-sqlserver/mssql-server-linux-rails
5
5
  ci:
6
6
  environment:
7
7
  - ACTIVERECORD_UNITTEST_HOST=sqlserver
@@ -397,14 +397,12 @@ module ActiveRecord
397
397
  end
398
398
 
399
399
  def query_requires_identity_insert?(sql)
400
- if insert_sql?(sql)
401
- table_name = get_table_name(sql)
402
- id_column = identity_columns(table_name).first
403
- # id_column && sql =~ /^\s*(INSERT|EXEC sp_executesql N'INSERT)[^(]+\([^)]*\b(#{id_column.name})\b,?[^)]*\)/i ? quote_table_name(table_name) : false
404
- id_column && sql =~ /^\s*(INSERT|EXEC sp_executesql N'INSERT)[^(]+\([^)]*\b(#{id_column.name})\b,?[^)]*\)/i ? table_name : false
405
- else
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 quoted table_name to #query_requires_identity_insert? when INSERT sql contains id column" do
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
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Alien < ActiveRecord::Base
4
+ self.table_name = "test.aliens"
5
+ 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.1.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-03-15 00:00:00.000000000 Z
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.1.0/CHANGELOG.md
231
- source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.0.1.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