activerecord-sqlserver-adapter 6.1.1.0 → 6.1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +16 -10
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +18 -4
- data/test/cases/adapter_test_sqlserver.rb +8 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc687a6f9cd86f8c1f7b62356b266e84b47833c9abc25d6a339e387122ccbe4b
|
4
|
+
data.tar.gz: 7b1cf7d3f5caa773943a722da4f39fe69435dbd03ce451c540e855f87642e640
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa048c171f318b7b4e46662b305e04a87e923c42cd1729f5d62bcd6c3e4e8cbbdacec56b767f537becb51c64d162cf556b1b9f69637732b346c37c823833393
|
7
|
+
data.tar.gz: e4da6b9fa4c35f21afba43390d790097481dbe321c5c808d3be586eaec745d98e9af8ac10b394990266e733661f65081b12e10b958a64e457609910de4379205
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v6.1.2.0
|
2
|
+
|
3
|
+
[Full changelog](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/compare/v6.1.1.0...v6.1.2.0)
|
4
|
+
|
5
|
+
#### Fixed
|
6
|
+
|
7
|
+
- [#940](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/940) Primary key violation should result in RecordNotUnique error
|
8
|
+
|
9
|
+
#### Changed
|
10
|
+
|
11
|
+
- [#941](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/941) No longer support configuring the application name by overriding the 'configure_application_name' method.
|
12
|
+
|
1
13
|
## v6.1.1.0
|
2
14
|
|
3
15
|
[Full changelog](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/compare/v6.1.0.0...v6.1.1.0)
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Interested in older versions? We follow a rational versioning policy that tracks
|
|
13
13
|
|
14
14
|
| Adapter Version | Rails Version | Support |
|
15
15
|
| --------------- | ------------- | ------------------------------------------------------------------------------------------- |
|
16
|
-
| `6.1.
|
16
|
+
| `6.1.2.0` | `6.1.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
|
17
17
|
| `6.0.2` | `6.0.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-0-stable) |
|
18
18
|
| `5.2.1` | `5.2.x` | [active](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-2-stable) |
|
19
19
|
| `5.1.6` | `5.1.x` | [ended](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-1-stable) |
|
@@ -82,34 +82,40 @@ end
|
|
82
82
|
```
|
83
83
|
|
84
84
|
|
85
|
-
#### Configure Connection
|
85
|
+
#### Configure Connection
|
86
86
|
|
87
|
-
We currently conform to an unpublished and non-standard AbstractAdapter interface to configure connections made to the database. To do so, just override the `configure_connection` method in an initializer like so. In this case below we are setting the `TEXTSIZE` to 64 megabytes.
|
87
|
+
We currently conform to an unpublished and non-standard AbstractAdapter interface to configure connections made to the database. To do so, just override the `configure_connection` method in an initializer like so. In this case below we are setting the `TEXTSIZE` to 64 megabytes.
|
88
88
|
|
89
89
|
```ruby
|
90
90
|
module ActiveRecord
|
91
91
|
module ConnectionAdapters
|
92
92
|
class SQLServerAdapter < AbstractAdapter
|
93
|
-
|
94
93
|
def configure_connection
|
95
94
|
raw_connection_do "SET TEXTSIZE #{64.megabytes}"
|
96
95
|
end
|
97
|
-
|
98
|
-
def configure_application_name
|
99
|
-
"myapp_#{$$}_#{Thread.current.object_id}".to(29)
|
100
|
-
end
|
101
|
-
|
102
96
|
end
|
103
97
|
end
|
104
98
|
end
|
105
99
|
```
|
106
100
|
|
101
|
+
#### Configure Application Name
|
102
|
+
|
103
|
+
TinyTDS supports an application name when it logs into SQL Server. This can be used to identify the connection in SQL Server's activity monitor. By default it will use the `appname` from your database.yml file or your Rails::Application name.
|
104
|
+
|
105
|
+
Below shows how you might use the database.yml file to use the process ID in your application name.
|
106
|
+
|
107
|
+
```yaml
|
108
|
+
development:
|
109
|
+
adapter: sqlserver
|
110
|
+
appname: <%= myapp_#{Process.pid} %>
|
111
|
+
```
|
112
|
+
|
107
113
|
#### Executing Stored Procedures
|
108
114
|
|
109
115
|
Every class that sub classes ActiveRecord::Base will now have an execute_procedure class method to use. This method takes the name of the stored procedure which can be a string or symbol and any number of variables to pass to the procedure. Arguments will automatically be quoted per the connection's standards as normal. For example:
|
110
116
|
|
111
117
|
```ruby
|
112
|
-
Account.execute_procedure(:update_totals, 'admin', nil, true
|
118
|
+
Account.execute_procedure(:update_totals, 'admin', nil, true)
|
113
119
|
# Or with named parameters.
|
114
120
|
Account.execute_procedure(:update_totals, named: 'params')
|
115
121
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.1.
|
1
|
+
6.1.2.0
|
@@ -105,7 +105,23 @@ module ActiveRecord
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def config_appname(config)
|
108
|
-
|
108
|
+
if self.instance_methods.include?(:configure_application_name)
|
109
|
+
ActiveSupport::Deprecation.warn <<~MSG.squish
|
110
|
+
Configuring the application name used by TinyTDS by overriding the
|
111
|
+
`ActiveRecord::ConnectionAdapters::SQLServerAdapter#configure_application_name`
|
112
|
+
instance method is no longer supported. The application name should configured
|
113
|
+
using the `appname` setting in the `database.yml` file instead. Consult the
|
114
|
+
README for further information."
|
115
|
+
MSG
|
116
|
+
end
|
117
|
+
|
118
|
+
config[:appname] || rails_application_name
|
119
|
+
end
|
120
|
+
|
121
|
+
def rails_application_name
|
122
|
+
return nil if Rails.application.nil?
|
123
|
+
|
124
|
+
Rails.application.class.name.split("::").first
|
109
125
|
end
|
110
126
|
|
111
127
|
def config_login_timeout(config)
|
@@ -444,7 +460,7 @@ module ActiveRecord
|
|
444
460
|
case message
|
445
461
|
when /(SQL Server client is not connected)|(failed to execute statement)/i
|
446
462
|
ConnectionNotEstablished.new(message)
|
447
|
-
when /(cannot insert duplicate key .* with unique index) | (violation of unique key constraint)/i
|
463
|
+
when /(cannot insert duplicate key .* with unique index) | (violation of (unique|primary) key constraint)/i
|
448
464
|
RecordNotUnique.new(message, sql: sql, binds: binds)
|
449
465
|
when /(conflicted with the foreign key constraint) | (The DELETE statement conflicted with the REFERENCE constraint)/i
|
450
466
|
InvalidForeignKey.new(message, sql: sql, binds: binds)
|
@@ -483,8 +499,6 @@ module ActiveRecord
|
|
483
499
|
end
|
484
500
|
end
|
485
501
|
|
486
|
-
def configure_application_name; end
|
487
|
-
|
488
502
|
def initialize_dateformatter
|
489
503
|
@database_dateformat = user_options_dateformat
|
490
504
|
a, b, c = @database_dateformat.each_char.to_a
|
@@ -120,6 +120,14 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
120
120
|
"expected database #{db_config.database} to exist"
|
121
121
|
end
|
122
122
|
|
123
|
+
it "test primary key violation" do
|
124
|
+
Post.create!(id: 0, title: 'Setup', body: 'Create post with primary key of zero')
|
125
|
+
|
126
|
+
assert_raise ActiveRecord::RecordNotUnique do
|
127
|
+
Post.create!(id: 0, title: 'Test', body: 'Try to create another post with primary key of zero')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
123
131
|
describe "with different language" do
|
124
132
|
before do
|
125
133
|
@default_language = connection.user_options_language
|
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: 6.1.
|
4
|
+
version: 6.1.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: 2021-
|
17
|
+
date: 2021-09-06 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -224,8 +224,8 @@ licenses:
|
|
224
224
|
- MIT
|
225
225
|
metadata:
|
226
226
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
227
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v6.1.
|
228
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v6.1.
|
227
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v6.1.2.0/CHANGELOG.md
|
228
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v6.1.2.0
|
229
229
|
post_install_message:
|
230
230
|
rdoc_options: []
|
231
231
|
require_paths:
|