activerecord-sqlserver-adapter 4.2.18 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -223
  3. data/Gemfile +18 -17
  4. data/RAILS5-TODO.md +36 -0
  5. data/README.md +27 -8
  6. data/RUNNING_UNIT_TESTS.md +0 -17
  7. data/Rakefile +2 -7
  8. data/VERSION +1 -1
  9. data/activerecord-sqlserver-adapter.gemspec +1 -1
  10. data/appveyor.yml +0 -2
  11. data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +15 -8
  12. data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +45 -97
  13. data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +1 -2
  14. data/lib/active_record/connection_adapters/sqlserver/quoting.rb +31 -10
  15. data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +0 -18
  16. data/lib/active_record/connection_adapters/sqlserver/schema_dumper.rb +16 -0
  17. data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +101 -58
  18. data/lib/active_record/connection_adapters/sqlserver/showplan.rb +7 -7
  19. data/lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb +20 -0
  20. data/lib/active_record/connection_adapters/sqlserver/table_definition.rb +56 -32
  21. data/lib/active_record/connection_adapters/sqlserver/transaction.rb +1 -1
  22. data/lib/active_record/connection_adapters/sqlserver/type.rb +34 -32
  23. data/lib/active_record/connection_adapters/sqlserver/type/big_integer.rb +4 -0
  24. data/lib/active_record/connection_adapters/sqlserver/type/binary.rb +6 -0
  25. data/lib/active_record/connection_adapters/sqlserver/type/boolean.rb +3 -0
  26. data/lib/active_record/connection_adapters/sqlserver/type/char.rb +9 -20
  27. data/lib/active_record/connection_adapters/sqlserver/type/data.rb +30 -0
  28. data/lib/active_record/connection_adapters/sqlserver/type/date.rb +28 -4
  29. data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +28 -14
  30. data/lib/active_record/connection_adapters/sqlserver/type/datetime2.rb +2 -2
  31. data/lib/active_record/connection_adapters/sqlserver/type/datetimeoffset.rb +4 -16
  32. data/lib/active_record/connection_adapters/sqlserver/type/decimal.rb +9 -0
  33. data/lib/active_record/connection_adapters/sqlserver/type/float.rb +4 -0
  34. data/lib/active_record/connection_adapters/sqlserver/type/integer.rb +3 -0
  35. data/lib/active_record/connection_adapters/sqlserver/type/money.rb +5 -1
  36. data/lib/active_record/connection_adapters/sqlserver/type/real.rb +4 -0
  37. data/lib/active_record/connection_adapters/sqlserver/type/small_integer.rb +3 -1
  38. data/lib/active_record/connection_adapters/sqlserver/type/small_money.rb +5 -1
  39. data/lib/active_record/connection_adapters/sqlserver/type/smalldatetime.rb +8 -1
  40. data/lib/active_record/connection_adapters/sqlserver/type/text.rb +4 -0
  41. data/lib/active_record/connection_adapters/sqlserver/type/time.rb +20 -8
  42. data/lib/active_record/connection_adapters/sqlserver/type/time_value_fractional.rb +25 -10
  43. data/lib/active_record/connection_adapters/sqlserver/type/timestamp.rb +4 -0
  44. data/lib/active_record/connection_adapters/sqlserver/type/tiny_integer.rb +3 -0
  45. data/lib/active_record/connection_adapters/sqlserver/type/unicode_char.rb +6 -0
  46. data/lib/active_record/connection_adapters/sqlserver/type/unicode_text.rb +4 -0
  47. data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar.rb +7 -1
  48. data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar_max.rb +5 -1
  49. data/lib/active_record/connection_adapters/sqlserver/type/uuid.rb +15 -2
  50. data/lib/active_record/connection_adapters/sqlserver/type/varbinary.rb +7 -1
  51. data/lib/active_record/connection_adapters/sqlserver/type/varbinary_max.rb +5 -1
  52. data/lib/active_record/connection_adapters/sqlserver/type/varchar.rb +7 -1
  53. data/lib/active_record/connection_adapters/sqlserver/type/varchar_max.rb +5 -1
  54. data/lib/active_record/connection_adapters/sqlserver/utils.rb +10 -0
  55. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +71 -57
  56. data/lib/active_record/connection_adapters/sqlserver_column.rb +5 -30
  57. data/lib/active_record/sqlserver_base.rb +1 -5
  58. data/lib/arel/visitors/sqlserver.rb +11 -20
  59. data/test/bin/setup.sh +4 -6
  60. data/test/cases/adapter_test_sqlserver.rb +11 -20
  61. data/test/cases/coerced_tests.rb +233 -138
  62. data/test/cases/column_test_sqlserver.rb +244 -227
  63. data/test/cases/connection_test_sqlserver.rb +5 -76
  64. data/test/cases/fully_qualified_identifier_test_sqlserver.rb +7 -7
  65. data/test/cases/helper_sqlserver.rb +4 -15
  66. data/test/cases/pessimistic_locking_test_sqlserver.rb +1 -1
  67. data/test/cases/rake_test_sqlserver.rb +20 -14
  68. data/test/cases/schema_dumper_test_sqlserver.rb +94 -63
  69. data/test/cases/schema_test_sqlserver.rb +2 -2
  70. data/test/cases/showplan_test_sqlserver.rb +1 -1
  71. data/test/cases/specific_schema_test_sqlserver.rb +7 -14
  72. data/test/cases/transaction_test_sqlserver.rb +1 -1
  73. data/test/cases/uuid_test_sqlserver.rb +0 -1
  74. data/test/config.yml +0 -10
  75. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +1 -1
  76. data/test/schema/sqlserver_specific_schema.rb +0 -16
  77. data/test/support/coerceable_test_sqlserver.rb +6 -2
  78. data/test/support/connection_reflection.rb +0 -4
  79. data/test/support/sql_counter_sqlserver.rb +17 -21
  80. metadata +9 -7
  81. data/lib/active_record/connection_adapters/sqlserver/core_ext/odbc.rb +0 -34
  82. data/lib/active_record/connection_adapters/sqlserver/schema_cache.rb +0 -114
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.2.18
1
+ 5.0.0
@@ -16,5 +16,5 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
- spec.add_dependency 'activerecord', '~> 4.2.1'
19
+ spec.add_dependency 'activerecord', '~> 5.0.0'
20
20
  end
data/appveyor.yml CHANGED
@@ -12,8 +12,6 @@ install:
12
12
  - ruby --version
13
13
  - gem --version
14
14
  - bundle install
15
- - gem uninstall bcrypt
16
- - gem install bcrypt --platform=ruby
17
15
  build: off
18
16
  test_script:
19
17
  - powershell -File "%APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.ps1"
@@ -4,11 +4,14 @@ module ActiveRecord
4
4
  module CoreExt
5
5
  module Explain
6
6
 
7
- SQLSERVER_STATEMENT_PREFIX = 'EXEC sp_executesql '
8
- SQLSERVER_PARAM_MATCHER = /@\d+ =/
7
+ SQLSERVER_STATEMENT_PREFIX = 'EXEC sp_executesql '.freeze
8
+ SQLSERVER_PARAM_MATCHER = /@\d+ = (.*)/
9
+ SQLSERVER_NATIONAL_STRING_MATCHER = /N'(.*)'/m
9
10
 
10
11
  def exec_explain(queries)
11
- unprepared_queries = queries.map { |sql, bind| [unprepare_sqlserver_statement(sql), bind] }
12
+ unprepared_queries = queries.map do |(sql, binds)|
13
+ [unprepare_sqlserver_statement(sql), binds]
14
+ end
12
15
  super(unprepared_queries)
13
16
  end
14
17
 
@@ -20,11 +23,15 @@ module ActiveRecord
20
23
  def unprepare_sqlserver_statement(sql)
21
24
  if sql.starts_with?(SQLSERVER_STATEMENT_PREFIX)
22
25
  executesql = sql.from(SQLSERVER_STATEMENT_PREFIX.length)
23
- executesql_args = executesql.split(', ')
24
- found_args = executesql_args.reject! { |arg| arg =~ SQLSERVER_PARAM_MATCHER }
25
- executesql_args.pop if found_args && executesql_args.many?
26
- executesql = executesql_args.join(', ').strip.match(/N'(.*)'/m)[1]
27
- Utils.unquote_string(executesql)
26
+ args = executesql.split(', ')
27
+ unprepared_sql = args.shift.strip.match(SQLSERVER_NATIONAL_STRING_MATCHER)[1]
28
+ unprepared_sql = Utils.unquote_string(unprepared_sql)
29
+ args = args.from(args.length / 2)
30
+ args.each_with_index do |arg, index|
31
+ value = arg.match(SQLSERVER_PARAM_MATCHER)[1]
32
+ unprepared_sql.sub! "@#{index}", value
33
+ end
34
+ unprepared_sql
28
35
  else
29
36
  sql
30
37
  end
@@ -15,15 +15,13 @@ module ActiveRecord
15
15
  end
16
16
  end
17
17
 
18
- def exec_query(sql, name = 'SQL', binds = [], sqlserver_options = {})
19
- sp_executesql(sql, name, binds)
18
+ def exec_query(sql, name = 'SQL', binds = [], prepare: false)
19
+ sp_executesql(sql, name, binds, prepare: prepare)
20
20
  end
21
21
 
22
- def exec_insert(sql, name, binds, _pk = nil, _sequence_name = nil)
23
- id_insert = binds_have_identity_column?(binds)
24
- id_table = table_name_from_binds(binds) if id_insert
25
- if id_insert && id_table
26
- with_identity_insert_enabled(id_table) { exec_query(sql, name, binds) }
22
+ def exec_insert(sql, name, binds, pk = nil, _sequence_name = nil)
23
+ if pk && id_insert_table_name = query_requires_identity_insert?(sql)
24
+ with_identity_insert_enabled(id_insert_table_name) { exec_query(sql, name, binds) }
27
25
  else
28
26
  exec_query(sql, name, binds)
29
27
  end
@@ -81,26 +79,18 @@ module ActiveRecord
81
79
  def release_savepoint(name = current_savepoint_name)
82
80
  end
83
81
 
84
- def case_sensitive_modifier(node, table_attribute)
85
- node = Arel::Nodes.build_quoted node, table_attribute
86
- Arel::Nodes::Bin.new(node)
87
- end
88
-
89
82
  def case_sensitive_comparison(table, attribute, column, value)
90
- if column.case_sensitive?
91
- table[attribute].eq(value)
83
+ if value && value.acts_like?(:string)
84
+ table[attribute].eq(Arel::Nodes::Bin.new(Arel::Nodes::BindParam.new))
92
85
  else
93
86
  super
94
87
  end
95
88
  end
96
89
 
97
- def case_insensitive_comparison(table, attribute, column, value)
98
- if column.case_sensitive?
99
- super
100
- else
101
- table[attribute].eq(value)
102
- end
90
+ def can_perform_case_insensitive_comparison_for?(column)
91
+ column.type == :string
103
92
  end
93
+ private :can_perform_case_insensitive_comparison_for?
104
94
 
105
95
  # === SQLServer Specific ======================================== #
106
96
 
@@ -122,24 +112,12 @@ module ActiveRecord
122
112
  yield(r) if block_given?
123
113
  end
124
114
  result.each.map { |row| row.is_a?(Hash) ? row.with_indifferent_access : row }
125
- when :odbc
126
- results = []
127
- raw_connection_run(sql) do |handle|
128
- get_rows = lambda do
129
- rows = handle_to_names_and_values handle, fetch: :all
130
- rows.each_with_index { |r, i| rows[i] = r.with_indifferent_access }
131
- results << rows
132
- end
133
- get_rows.call
134
- get_rows.call while handle_more_results?(handle)
135
- end
136
- results.many? ? results : results.first
137
115
  end
138
116
  end
139
117
  end
140
118
 
141
119
  def with_identity_insert_enabled(table_name)
142
- table_name = quote_table_name(table_name_or_views_table_name(table_name))
120
+ table_name = quote_table_name(table_name)
143
121
  set_identity_insert(table_name, true)
144
122
  yield
145
123
  ensure
@@ -154,9 +132,7 @@ module ActiveRecord
154
132
 
155
133
  def user_options
156
134
  return {} if sqlserver_azure?
157
- rows = select_rows('DBCC USEROPTIONS WITH NO_INFOMSGS', 'SCHEMA')
158
- rows = rows.first if rows.size == 2 && rows.last.empty?
159
- rows.reduce(HashWithIndifferentAccess.new) do |values, row|
135
+ select_rows('dbcc useroptions', 'SCHEMA').reduce(HashWithIndifferentAccess.new) do |values, row|
160
136
  if row.instance_of? Hash
161
137
  set_option = row.values[0].gsub(/\s+/, '_')
162
138
  user_value = row.values[1]
@@ -213,36 +189,22 @@ module ActiveRecord
213
189
 
214
190
  protected
215
191
 
216
- def select(sql, name = nil, binds = [])
217
- exec_query(sql, name, binds)
218
- end
219
-
220
192
  def sql_for_insert(sql, pk, id_value, sequence_name, binds)
221
- sql = if pk && self.class.use_output_inserted && !database_prefix_remote_server?
222
- quoted_pk = SQLServer::Utils.extract_identifiers(pk).quoted
223
- sql.insert sql.index(/ (DEFAULT )?VALUES/), " OUTPUT INSERTED.#{quoted_pk}"
224
- else
225
- "#{sql}; SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident"
193
+ if pk.nil?
194
+ table_name = query_requires_identity_insert?(sql)
195
+ pk = primary_key(table_name)
226
196
  end
197
+ sql = if pk && self.class.use_output_inserted && !database_prefix_remote_server?
198
+ quoted_pk = SQLServer::Utils.extract_identifiers(pk).quoted
199
+ sql.insert sql.index(/ (DEFAULT )?VALUES/), " OUTPUT INSERTED.#{quoted_pk}"
200
+ else
201
+ "#{sql}; SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident"
202
+ end
227
203
  super
228
204
  end
229
205
 
230
206
  # === SQLServer Specific ======================================== #
231
207
 
232
- def binds_have_identity_column?(binds)
233
- binds.any? do |column_value|
234
- column, value = column_value
235
- SQLServerColumn === column && column.is_identity?
236
- end
237
- end
238
-
239
- def table_name_from_binds(binds)
240
- binds.detect { |column_value|
241
- column, value = column_value
242
- SQLServerColumn === column
243
- }.try(:first).try(:table_name)
244
- end
245
-
246
208
  def set_identity_insert(table_name, enable = true)
247
209
  do_execute "SET IDENTITY_INSERT #{table_name} #{enable ? 'ON' : 'OFF'}"
248
210
  rescue Exception
@@ -257,27 +219,39 @@ module ActiveRecord
257
219
 
258
220
  def sp_executesql(sql, name, binds, options = {})
259
221
  options[:ar_result] = true if options[:fetch] != :rows
260
- types, params = sp_executesql_types_and_parameters(binds)
261
- sql = sp_executesql_sql(sql, types, params, name)
222
+ unless without_prepared_statement?(binds)
223
+ types, params = sp_executesql_types_and_parameters(binds)
224
+ sql = sp_executesql_sql(sql, types, params, name)
225
+ end
262
226
  raw_select sql, name, binds, options
263
227
  end
264
228
 
265
229
  def sp_executesql_types_and_parameters(binds)
266
230
  types, params = [], []
267
- binds.each_with_index do |(column, value), index|
268
- types << "@#{index} #{sp_executesql_sql_type(column, value)}"
269
- params << quote(value, column)
231
+ binds.each_with_index do |attr, index|
232
+ types << "@#{index} #{sp_executesql_sql_type(attr)}"
233
+ params << sp_executesql_sql_param(attr)
270
234
  end
271
235
  [types, params]
272
236
  end
273
237
 
274
- def sp_executesql_sql_type(column, value)
275
- return column.sql_type_for_statement if SQLServerColumn === column
276
- if value.is_a?(Numeric)
277
- 'int'
278
- # We can do more here later.
238
+ def sp_executesql_sql_type(attr)
239
+ return attr.type.sqlserver_type if attr.type.respond_to?(:sqlserver_type)
240
+ case value = attr.value_for_database
241
+ when Numeric
242
+ 'int'.freeze
243
+ else
244
+ 'nvarchar(max)'.freeze
245
+ end
246
+ end
247
+
248
+ def sp_executesql_sql_param(attr)
249
+ case attr.value_for_database
250
+ when Type::Binary::Data,
251
+ ActiveRecord::Type::SQLServer::Data
252
+ quote(attr.value_for_database)
279
253
  else
280
- 'nvarchar(max)'
254
+ quote(type_cast(attr.value_for_database))
281
255
  end
282
256
  end
283
257
 
@@ -285,7 +259,7 @@ module ActiveRecord
285
259
  if name == 'EXPLAIN'
286
260
  params.each.with_index do |param, index|
287
261
  substitute_at_finder = /(@#{index})(?=(?:[^']|'[^']*')*$)/ # Finds unquoted @n values.
288
- sql.sub! substitute_at_finder, param
262
+ sql.sub! substitute_at_finder, param.to_s
289
263
  end
290
264
  else
291
265
  types = quote(types.join(', '))
@@ -300,8 +274,6 @@ module ActiveRecord
300
274
  case @connection_options[:mode]
301
275
  when :dblib
302
276
  @connection.execute(sql).do
303
- when :odbc
304
- @connection.do(sql)
305
277
  end
306
278
  ensure
307
279
  @update_sql = false
@@ -324,16 +296,12 @@ module ActiveRecord
324
296
  case @connection_options[:mode]
325
297
  when :dblib
326
298
  @connection.execute(sql)
327
- when :odbc
328
- block_given? ? @connection.run_block(sql) { |handle| yield(handle) } : @connection.run(sql)
329
299
  end
330
300
  end
331
301
 
332
302
  def handle_more_results?(handle)
333
303
  case @connection_options[:mode]
334
304
  when :dblib
335
- when :odbc
336
- handle.more_results
337
305
  end
338
306
  end
339
307
 
@@ -341,8 +309,6 @@ module ActiveRecord
341
309
  case @connection_options[:mode]
342
310
  when :dblib
343
311
  handle_to_names_and_values_dblib(handle, options)
344
- when :odbc
345
- handle_to_names_and_values_odbc(handle, options)
346
312
  end
347
313
  end
348
314
 
@@ -356,28 +322,10 @@ module ActiveRecord
356
322
  options[:ar_result] ? ActiveRecord::Result.new(columns, results) : results
357
323
  end
358
324
 
359
- def handle_to_names_and_values_odbc(handle, options = {})
360
- @connection.use_utc = ActiveRecord::Base.default_timezone == :utc
361
- if options[:ar_result]
362
- columns = lowercase_schema_reflection ? handle.columns(true).map { |c| c.name.downcase } : handle.columns(true).map { |c| c.name }
363
- rows = handle.fetch_all || []
364
- ActiveRecord::Result.new(columns, rows)
365
- else
366
- case options[:fetch]
367
- when :all
368
- handle.each_hash || []
369
- when :rows
370
- handle.fetch_all || []
371
- end
372
- end
373
- end
374
-
375
325
  def finish_statement_handle(handle)
376
326
  case @connection_options[:mode]
377
327
  when :dblib
378
328
  handle.cancel if handle
379
- when :odbc
380
- handle.drop if handle && handle.respond_to?(:drop) && !handle.finished?
381
329
  end
382
330
  handle
383
331
  end
@@ -24,10 +24,9 @@ module ActiveRecord
24
24
  end
25
25
 
26
26
  def collation
27
- select_value "SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation')"
27
+ @collation ||= select_value "SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation')"
28
28
  end
29
29
 
30
-
31
30
  private
32
31
 
33
32
  def create_database_options(options={})
@@ -3,23 +3,44 @@ module ActiveRecord
3
3
  module SQLServer
4
4
  module Quoting
5
5
 
6
- QUOTED_TRUE = '1'
7
- QUOTED_FALSE = '0'
8
- QUOTED_STRING_PREFIX = 'N'
6
+ QUOTED_TRUE = '1'.freeze
7
+ QUOTED_FALSE = '0'.freeze
8
+ QUOTED_STRING_PREFIX = 'N'.freeze
9
+
10
+ def fetch_type_metadata(sql_type, sqlserver_options = {})
11
+ cast_type = lookup_cast_type(sql_type)
12
+ SQLServer::SqlTypeMetadata.new(
13
+ sql_type: sql_type,
14
+ type: cast_type.type,
15
+ limit: cast_type.limit,
16
+ precision: cast_type.precision,
17
+ scale: cast_type.scale,
18
+ sqlserver_options: sqlserver_options
19
+ )
20
+ end
9
21
 
10
22
  def quote_string(s)
11
23
  SQLServer::Utils.quote_string(s)
12
24
  end
13
25
 
26
+ def quote_string_single(s)
27
+ SQLServer::Utils.quote_string_single(s)
28
+ end
29
+
30
+ def quote_string_single_national(s)
31
+ SQLServer::Utils.quote_string_single_national(s)
32
+ end
33
+
14
34
  def quote_column_name(name)
15
35
  SQLServer::Utils.extract_identifiers(name).quoted
16
36
  end
17
37
 
18
- def quote_default_value(value, column)
19
- if column.type == :uuid && value =~ /\(\)/
38
+ def quote_default_expression(value, column)
39
+ cast_type = lookup_cast_type(column.sql_type)
40
+ if cast_type.type == :uuid && value =~ /\(\)/
20
41
  value
21
42
  else
22
- quote(value, column)
43
+ super
23
44
  end
24
45
  end
25
46
 
@@ -41,9 +62,9 @@ module ActiveRecord
41
62
 
42
63
  def quoted_date(value)
43
64
  if value.acts_like?(:date)
44
- Type::Date.new.type_cast_for_database(value)
65
+ Type::Date.new.serialize(value)
45
66
  else value.acts_like?(:time)
46
- Type::DateTime.new.type_cast_for_database(value)
67
+ Type::DateTime.new.serialize(value)
47
68
  end
48
69
  end
49
70
 
@@ -54,7 +75,7 @@ module ActiveRecord
54
75
  case value
55
76
  when Type::Binary::Data
56
77
  "0x#{value.hex}"
57
- when ActiveRecord::Type::SQLServer::Char::Data
78
+ when ActiveRecord::Type::SQLServer::Data
58
79
  value.quoted
59
80
  when String, ActiveSupport::Multibyte::Chars
60
81
  "#{QUOTED_STRING_PREFIX}#{super}"
@@ -65,7 +86,7 @@ module ActiveRecord
65
86
 
66
87
  def _type_cast(value)
67
88
  case value
68
- when ActiveRecord::Type::SQLServer::Char::Data
89
+ when ActiveRecord::Type::SQLServer::Data
69
90
  value.to_s
70
91
  else
71
92
  super
@@ -5,15 +5,6 @@ module ActiveRecord
5
5
 
6
6
  private
7
7
 
8
- def visit_ColumnDefinition(o)
9
- sql = super
10
- if o.primary_key? && o.type == :uuid
11
- sql << ' PRIMARY KEY '
12
- add_column_options!(sql, column_options(o))
13
- end
14
- sql
15
- end
16
-
17
8
  def visit_TableDefinition(o)
18
9
  if o.as
19
10
  table_name = quote_table_name(o.temporary ? "##{o.name}" : o.name)
@@ -25,15 +16,6 @@ module ActiveRecord
25
16
  end
26
17
  end
27
18
 
28
- def add_column_options!(sql, options)
29
- column = options.fetch(:column) { return super }
30
- if (column.type == :uuid || column.type == :uniqueidentifier) && options[:default] =~ /\(\)/
31
- sql << " DEFAULT #{options.delete(:default)}"
32
- else
33
- super
34
- end
35
- end
36
-
37
19
  def action_sql(action, dependency)
38
20
  case dependency
39
21
  when :restrict
@@ -0,0 +1,16 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ module SQLServer
4
+ module SchemaDumper
5
+
6
+ private
7
+
8
+ def schema_collation(column)
9
+ return unless column.collation
10
+ column.collation if column.collation != collation
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end