activerecord-sqlserver-adapter 7.1.0.rc1 → 7.1.0.rc2

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: 42ca12c2b62c162e798e40d6ca3ec7861e736835d8d91f132eef16240dcfeb02
4
- data.tar.gz: ddf249b287e32a11a03ea4b2a9bfe85dbbded619d83165559f108892d90da658
3
+ metadata.gz: ddd1e2bb81c9a6675d4a8f561c585869b0fafb6ecfe3c513e7e69d8bc3646d9f
4
+ data.tar.gz: 0d669eaaa14be843acc19cc887c47a3f8eecfb3552e8477a062df688d9ef1172
5
5
  SHA512:
6
- metadata.gz: dde118ab5b86cd3b154739ce66933e8d4f3380503e6626796941c93cd08775571ad1f6b1630d7a5882b8dc97e0cd5475a7043fd8ac792af723e7c85720ff2271
7
- data.tar.gz: 80efec8b5e389f05c57a1a2bab01cae17addbda59ec772a602f9aa1e4212508301a954b32d795d0ec6898c161226d36664a169f834c3f34e3ce1fd1c34a56d0e
6
+ metadata.gz: 879aeb90caaef5bb0218651407ec5a978d4a62d51682e92d55fbda2d3eed2fd37e8348e72aa8c4c92cab856c8eebc2fa4bf1c2166ad13d99c983f1310d3b66ab
7
+ data.tar.gz: 15030862f3ae2044dd780a62f4a8868dc383cd6e9775fcedff214b1429bdbf2881be503e670cf2cbcfcbe92c0583c2a89d53f30ddd988a5425649ff29ef2c971
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v7.1.0.rc2
2
+
3
+ #### Added
4
+
5
+ - [#1136](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1136) Prevent marking broken connections as verified
6
+ - [#1138](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1138) Cache quoted names
7
+
1
8
  ## v7.1.0.rc1
2
9
 
3
10
  #### Added
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 | Branch |
15
15
  |-----------------|---------------|----------------|-------------------------------------------------------------------------------------------------|
16
- | `7.1.0.rc1` | `7.1.x` | In development | [main](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
16
+ | `7.1.0.rc2` | `7.1.x` | In development | [main](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
17
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
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
19
  | `6.0.3` | `6.0.x` | Ended | [6-0-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-0-stable) |
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.1.0.rc1
1
+ 7.1.0.rc2
@@ -23,6 +23,7 @@ module ActiveRecord
23
23
  else
24
24
  internal_raw_execute(sql, conn, perform_do: true)
25
25
  end
26
+ verified!
26
27
  end
27
28
  end
28
29
 
@@ -50,6 +51,7 @@ module ActiveRecord
50
51
  else
51
52
  result = internal_exec_sql_query(sql, conn)
52
53
  end
54
+ verified!
53
55
  end
54
56
  end
55
57
 
@@ -175,6 +177,7 @@ module ActiveRecord
175
177
  log(sql, "Execute Procedure") do
176
178
  with_raw_connection do |conn|
177
179
  result = internal_raw_execute(sql, conn)
180
+ verified!
178
181
  options = { as: :hash, cache_rows: true, timezone: ActiveRecord.default_timezone || :utc }
179
182
 
180
183
  result.each(options) do |row|
@@ -4,18 +4,18 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module SQLServer
6
6
  module Quoting
7
- QUOTED_TRUE = "1".freeze
8
- QUOTED_FALSE = "0".freeze
9
- QUOTED_STRING_PREFIX = "N".freeze
7
+ QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
8
+ QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:
10
9
 
11
10
  def fetch_type_metadata(sql_type, sqlserver_options = {})
12
11
  cast_type = lookup_cast_type(sql_type)
12
+
13
13
  simple_type = SqlTypeMetadata.new(
14
- sql_type: sql_type,
15
- type: cast_type.type,
16
- limit: cast_type.limit,
14
+ sql_type: sql_type,
15
+ type: cast_type.type,
16
+ limit: cast_type.limit,
17
17
  precision: cast_type.precision,
18
- scale: cast_type.scale
18
+ scale: cast_type.scale
19
19
  )
20
20
 
21
21
  SQLServer::TypeMetadata.new(simple_type, **sqlserver_options)
@@ -34,7 +34,11 @@ module ActiveRecord
34
34
  end
35
35
 
36
36
  def quote_column_name(name)
37
- SQLServer::Utils.extract_identifiers(name).quoted
37
+ QUOTED_COLUMN_NAMES[name] ||= SQLServer::Utils.extract_identifiers(name).quoted
38
+ end
39
+
40
+ def quote_table_name(name)
41
+ QUOTED_TABLE_NAMES[name] ||= SQLServer::Utils.extract_identifiers(name).quoted
38
42
  end
39
43
 
40
44
  def quote_default_expression(value, column)
@@ -47,7 +51,7 @@ module ActiveRecord
47
51
  end
48
52
 
49
53
  def quoted_true
50
- QUOTED_TRUE
54
+ '1'
51
55
  end
52
56
 
53
57
  def unquoted_true
@@ -55,7 +59,7 @@ module ActiveRecord
55
59
  end
56
60
 
57
61
  def quoted_false
58
- QUOTED_FALSE
62
+ '0'
59
63
  end
60
64
 
61
65
  def unquoted_false
@@ -117,7 +121,7 @@ module ActiveRecord
117
121
  when ActiveRecord::Type::SQLServer::Data
118
122
  value.quoted
119
123
  when String, ActiveSupport::Multibyte::Chars
120
- "#{QUOTED_STRING_PREFIX}#{super}"
124
+ "N#{super}"
121
125
  else
122
126
  super
123
127
  end
@@ -6,13 +6,9 @@ module ActiveRecord
6
6
  module ConnectionAdapters
7
7
  module SQLServer
8
8
  module Utils
9
- QUOTED_STRING_PREFIX = "N"
10
-
11
9
  # Value object to return identifiers from SQL Server names http://bit.ly/1CZ3EiL
12
10
  # Inspired from Rails PostgreSQL::Name adapter object in their own Utils.
13
- #
14
11
  class Name
15
- SEPARATOR = "."
16
12
  UNQUOTED_SCANNER = /\]?\./
17
13
  QUOTED_SCANNER = /\A\[.*?\]\./
18
14
  QUOTED_CHECKER = /\A\[/
@@ -42,7 +38,7 @@ module ActiveRecord
42
38
  end
43
39
 
44
40
  def fully_qualified_database_quoted
45
- [server_quoted, database_quoted].compact.join(SEPARATOR)
41
+ [server_quoted, database_quoted].compact.join('.')
46
42
  end
47
43
 
48
44
  def fully_qualified?
@@ -69,7 +65,7 @@ module ActiveRecord
69
65
  end
70
66
 
71
67
  def quoted
72
- parts.map { |p| quote(p) if p }.join SEPARATOR
68
+ parts.map { |p| quote(p) if p }.join('.')
73
69
  end
74
70
 
75
71
  def quoted_raw
@@ -132,7 +128,7 @@ module ActiveRecord
132
128
  extend self
133
129
 
134
130
  def quote_string(s)
135
- s.to_s.gsub /\'/, "''"
131
+ s.to_s.gsub(/\'/, "''")
136
132
  end
137
133
 
138
134
  def quote_string_single(s)
@@ -140,7 +136,7 @@ module ActiveRecord
140
136
  end
141
137
 
142
138
  def quote_string_single_national(s)
143
- "#{QUOTED_STRING_PREFIX}'#{quote_string(s)}'"
139
+ "N'#{quote_string(s)}'"
144
140
  end
145
141
 
146
142
  def quoted_raw(name)
@@ -53,7 +53,7 @@ module ActiveRecord
53
53
  end
54
54
 
55
55
  def clear_active_connections!
56
- ActiveRecord::Base.connection_handler.clear_active_connections!
56
+ ActiveRecord::Base.connection_handler.clear_active_connections!(:all)
57
57
  end
58
58
 
59
59
  def structure_dump(filename, extra_flags)
@@ -64,6 +64,38 @@ module Arel
64
64
  super
65
65
  end
66
66
 
67
+ def visit_Arel_Nodes_HomogeneousIn(o, collector)
68
+ collector.preparable = false
69
+
70
+ visit o.left, collector
71
+
72
+ if o.type == :in
73
+ collector << " IN ("
74
+ else
75
+ collector << " NOT IN ("
76
+ end
77
+
78
+ values = o.casted_values
79
+
80
+ # Monkey-patch start.
81
+ column_name = o.attribute.name
82
+ column_type = o.attribute.relation.type_for_attribute(column_name)
83
+ column_type = column_type.cast_type if column_type.is_a?(ActiveRecord::Encryption::EncryptedAttributeType) # Use cast_type on encrypted attributes. Don't encrypt them again
84
+
85
+ if values.empty?
86
+ collector << @connection.quote(nil)
87
+ elsif @connection.prepared_statements && !column_type.serialized?
88
+ # Add query attribute bindings rather than just values.
89
+ attrs = values.map { |value| ActiveRecord::Relation::QueryAttribute.new(column_name, value, column_type) }
90
+ collector.add_binds(attrs, &bind_block)
91
+ else
92
+ collector.add_binds(values, o.proc_for_binds, &bind_block)
93
+ end
94
+ # Monkey-patch end.
95
+
96
+ collector << ")"
97
+ end
98
+
67
99
  def visit_Arel_Nodes_SelectStatement(o, collector)
68
100
  @select_statement = o
69
101
  distinct_One_As_One_Is_So_Not_Fetch o
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.rc1
4
+ version: 7.1.0.rc2
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-09 00:00:00.000000000 Z
18
+ date: 2023-11-14 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.rc1/CHANGELOG.md
239
- source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.1.0.rc1
238
+ changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.1.0.rc2/CHANGELOG.md
239
+ source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.1.0.rc2
240
240
  post_install_message:
241
241
  rdoc_options: []
242
242
  require_paths: