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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +29 -0
  4. data/CHANGELOG.md +20 -0
  5. data/Gemfile +11 -5
  6. data/Guardfile +9 -8
  7. data/Rakefile +12 -16
  8. data/VERSION +1 -1
  9. data/activerecord-sqlserver-adapter.gemspec +3 -3
  10. data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +0 -4
  11. data/lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb +1 -4
  12. data/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +3 -4
  13. data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +1 -3
  14. data/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb +2 -3
  15. data/lib/active_record/connection_adapters/sqlserver/core_ext/query_methods.rb +2 -3
  16. data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +35 -32
  17. data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +7 -12
  18. data/lib/active_record/connection_adapters/sqlserver/errors.rb +0 -3
  19. data/lib/active_record/connection_adapters/sqlserver/quoting.rb +8 -8
  20. data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +0 -2
  21. data/lib/active_record/connection_adapters/sqlserver/schema_dumper.rb +7 -7
  22. data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +106 -103
  23. data/lib/active_record/connection_adapters/sqlserver/showplan.rb +6 -8
  24. data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +2 -2
  25. data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +1 -1
  26. data/lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb +0 -2
  27. data/lib/active_record/connection_adapters/sqlserver/table_definition.rb +1 -4
  28. data/lib/active_record/connection_adapters/sqlserver/transaction.rb +4 -8
  29. data/lib/active_record/connection_adapters/sqlserver/type.rb +35 -35
  30. data/lib/active_record/connection_adapters/sqlserver/type/big_integer.rb +0 -2
  31. data/lib/active_record/connection_adapters/sqlserver/type/binary.rb +0 -2
  32. data/lib/active_record/connection_adapters/sqlserver/type/boolean.rb +0 -2
  33. data/lib/active_record/connection_adapters/sqlserver/type/char.rb +2 -2
  34. data/lib/active_record/connection_adapters/sqlserver/type/data.rb +0 -2
  35. data/lib/active_record/connection_adapters/sqlserver/type/date.rb +2 -3
  36. data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +2 -3
  37. data/lib/active_record/connection_adapters/sqlserver/type/datetime2.rb +0 -2
  38. data/lib/active_record/connection_adapters/sqlserver/type/datetimeoffset.rb +0 -2
  39. data/lib/active_record/connection_adapters/sqlserver/type/decimal.rb +0 -2
  40. data/lib/active_record/connection_adapters/sqlserver/type/float.rb +0 -2
  41. data/lib/active_record/connection_adapters/sqlserver/type/integer.rb +0 -2
  42. data/lib/active_record/connection_adapters/sqlserver/type/json.rb +0 -1
  43. data/lib/active_record/connection_adapters/sqlserver/type/money.rb +0 -2
  44. data/lib/active_record/connection_adapters/sqlserver/type/real.rb +0 -2
  45. data/lib/active_record/connection_adapters/sqlserver/type/small_integer.rb +0 -2
  46. data/lib/active_record/connection_adapters/sqlserver/type/small_money.rb +0 -2
  47. data/lib/active_record/connection_adapters/sqlserver/type/smalldatetime.rb +0 -2
  48. data/lib/active_record/connection_adapters/sqlserver/type/string.rb +0 -2
  49. data/lib/active_record/connection_adapters/sqlserver/type/text.rb +0 -2
  50. data/lib/active_record/connection_adapters/sqlserver/type/time.rb +2 -3
  51. data/lib/active_record/connection_adapters/sqlserver/type/time_value_fractional.rb +6 -9
  52. data/lib/active_record/connection_adapters/sqlserver/type/timestamp.rb +0 -2
  53. data/lib/active_record/connection_adapters/sqlserver/type/tiny_integer.rb +0 -2
  54. data/lib/active_record/connection_adapters/sqlserver/type/unicode_char.rb +1 -3
  55. data/lib/active_record/connection_adapters/sqlserver/type/unicode_string.rb +0 -2
  56. data/lib/active_record/connection_adapters/sqlserver/type/unicode_text.rb +0 -2
  57. data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar.rb +0 -2
  58. data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar_max.rb +0 -2
  59. data/lib/active_record/connection_adapters/sqlserver/type/uuid.rb +1 -2
  60. data/lib/active_record/connection_adapters/sqlserver/type/varbinary.rb +1 -3
  61. data/lib/active_record/connection_adapters/sqlserver/type/varbinary_max.rb +0 -2
  62. data/lib/active_record/connection_adapters/sqlserver/type/varchar.rb +1 -3
  63. data/lib/active_record/connection_adapters/sqlserver/type/varchar_max.rb +0 -2
  64. data/lib/active_record/connection_adapters/sqlserver/utils.rb +8 -11
  65. data/lib/active_record/connection_adapters/sqlserver/version.rb +0 -2
  66. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +85 -83
  67. data/lib/active_record/connection_adapters/sqlserver_column.rb +0 -2
  68. data/lib/active_record/sqlserver_base.rb +1 -1
  69. data/lib/active_record/tasks/sqlserver_database_tasks.rb +26 -32
  70. data/lib/activerecord-sqlserver-adapter.rb +1 -1
  71. data/lib/arel/visitors/sqlserver.rb +18 -14
  72. data/lib/arel_sqlserver.rb +2 -2
  73. data/test/cases/adapter_test_sqlserver.rb +161 -182
  74. data/test/cases/change_column_null_test_sqlserver.rb +12 -12
  75. data/test/cases/coerced_tests.rb +88 -270
  76. data/test/cases/column_test_sqlserver.rb +281 -283
  77. data/test/cases/connection_test_sqlserver.rb +15 -20
  78. data/test/cases/execute_procedure_test_sqlserver.rb +18 -20
  79. data/test/cases/fetch_test_sqlserver.rb +14 -22
  80. data/test/cases/fully_qualified_identifier_test_sqlserver.rb +12 -18
  81. data/test/cases/helper_sqlserver.rb +13 -15
  82. data/test/cases/in_clause_test_sqlserver.rb +9 -9
  83. data/test/cases/index_test_sqlserver.rb +13 -15
  84. data/test/cases/json_test_sqlserver.rb +23 -25
  85. data/test/cases/migration_test_sqlserver.rb +22 -28
  86. data/test/cases/order_test_sqlserver.rb +51 -54
  87. data/test/cases/pessimistic_locking_test_sqlserver.rb +25 -33
  88. data/test/cases/rake_test_sqlserver.rb +31 -45
  89. data/test/cases/schema_dumper_test_sqlserver.rb +104 -108
  90. data/test/cases/schema_test_sqlserver.rb +18 -26
  91. data/test/cases/scratchpad_test_sqlserver.rb +2 -4
  92. data/test/cases/showplan_test_sqlserver.rb +24 -33
  93. data/test/cases/specific_schema_test_sqlserver.rb +66 -65
  94. data/test/cases/transaction_test_sqlserver.rb +16 -19
  95. data/test/cases/trigger_test_sqlserver.rb +12 -12
  96. data/test/cases/utils_test_sqlserver.rb +68 -70
  97. data/test/cases/uuid_test_sqlserver.rb +11 -13
  98. data/test/debug.rb +6 -6
  99. data/test/migrations/create_clients_and_change_column_null.rb +1 -1
  100. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +2 -4
  101. data/test/models/sqlserver/booking.rb +1 -1
  102. data/test/models/sqlserver/customers_view.rb +1 -1
  103. data/test/models/sqlserver/dollar_table_name.rb +1 -1
  104. data/test/models/sqlserver/edge_schema.rb +1 -3
  105. data/test/models/sqlserver/fk_has_fk.rb +1 -1
  106. data/test/models/sqlserver/fk_has_pk.rb +1 -1
  107. data/test/models/sqlserver/natural_pk_data.rb +2 -2
  108. data/test/models/sqlserver/natural_pk_int_data.rb +1 -1
  109. data/test/models/sqlserver/no_pk_data.rb +1 -1
  110. data/test/models/sqlserver/object_default.rb +1 -1
  111. data/test/models/sqlserver/quoted_table.rb +2 -2
  112. data/test/models/sqlserver/quoted_view_1.rb +1 -1
  113. data/test/models/sqlserver/quoted_view_2.rb +1 -1
  114. data/test/models/sqlserver/sst_memory.rb +1 -1
  115. data/test/models/sqlserver/string_default.rb +1 -1
  116. data/test/models/sqlserver/string_defaults_big_view.rb +1 -1
  117. data/test/models/sqlserver/string_defaults_view.rb +1 -1
  118. data/test/models/sqlserver/tinyint_pk.rb +1 -1
  119. data/test/models/sqlserver/trigger.rb +2 -2
  120. data/test/models/sqlserver/trigger_history.rb +1 -1
  121. data/test/models/sqlserver/upper.rb +1 -1
  122. data/test/models/sqlserver/uppered.rb +1 -1
  123. data/test/models/sqlserver/uuid.rb +1 -1
  124. data/test/schema/sqlserver_specific_schema.rb +20 -22
  125. data/test/support/coerceable_test_sqlserver.rb +1 -4
  126. data/test/support/connection_reflection.rb +1 -2
  127. data/test/support/core_ext/query_cache.rb +1 -1
  128. data/test/support/load_schema_sqlserver.rb +3 -5
  129. data/test/support/minitest_sqlserver.rb +1 -1
  130. data/test/support/paths_sqlserver.rb +9 -11
  131. data/test/support/rake_helpers.rb +12 -10
  132. data/test/support/sql_counter_sqlserver.rb +0 -4
  133. data/test/support/test_in_memory_oltp.rb +7 -7
  134. metadata +5 -4
@@ -1,21 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_record/connection_adapters/sqlserver/showplan/printer_table'
4
- require 'active_record/connection_adapters/sqlserver/showplan/printer_xml'
3
+ require "active_record/connection_adapters/sqlserver/showplan/printer_table"
4
+ require "active_record/connection_adapters/sqlserver/showplan/printer_xml"
5
5
 
6
6
  module ActiveRecord
7
7
  module ConnectionAdapters
8
8
  module SQLServer
9
9
  module Showplan
10
-
11
- OPTION_ALL = 'SHOWPLAN_ALL'
12
- OPTION_TEXT = 'SHOWPLAN_TEXT'
13
- OPTION_XML = 'SHOWPLAN_XML'
10
+ OPTION_ALL = "SHOWPLAN_ALL"
11
+ OPTION_TEXT = "SHOWPLAN_TEXT"
12
+ OPTION_XML = "SHOWPLAN_XML"
14
13
  OPTIONS = [OPTION_ALL, OPTION_TEXT, OPTION_XML]
15
14
 
16
15
  def explain(arel, binds = [])
17
16
  sql = to_sql(arel)
18
- result = with_showplan_on { sp_executesql(sql, 'EXPLAIN', binds) }
17
+ result = with_showplan_on { sp_executesql(sql, "EXPLAIN", binds) }
19
18
  printer = showplan_printer.new(result)
20
19
  printer.pp
21
20
  end
@@ -61,7 +60,6 @@ module ActiveRecord
61
60
  else PrinterTable
62
61
  end
63
62
  end
64
-
65
63
  end
66
64
  end
67
65
  end
@@ -43,7 +43,7 @@ module ActiveRecord
43
43
  end
44
44
 
45
45
  def build_separator
46
- '+' + @widths.map { |w| '-' * (w + (cell_padding * 2)) }.join('+') + '+'
46
+ "+" + @widths.map { |w| "-" * (w + (cell_padding * 2)) }.join("+") + "+"
47
47
  end
48
48
 
49
49
  def build_cells(items)
@@ -56,7 +56,7 @@ module ActiveRecord
56
56
 
57
57
  def cast_item(item)
58
58
  case item
59
- when NilClass then 'NULL'
59
+ when NilClass then "NULL"
60
60
  when Float then item.to_s.to(9)
61
61
  else item.to_s.truncate(max_column_width)
62
62
  end
@@ -12,7 +12,7 @@ module ActiveRecord
12
12
  def pp
13
13
  xml = @result.rows.first.first
14
14
  if defined?(Nokogiri)
15
- Nokogiri::XML(xml).to_xml indent: 2, encoding: 'UTF-8'
15
+ Nokogiri::XML(xml).to_xml indent: 2, encoding: "UTF-8"
16
16
  else
17
17
  xml
18
18
  end
@@ -4,7 +4,6 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module SQLServer
6
6
  class SqlTypeMetadata < ActiveRecord::ConnectionAdapters::SqlTypeMetadata
7
-
8
7
  def initialize(**kwargs)
9
8
  @sqlserver_options = kwargs.extract!(:sqlserver_options)
10
9
  super(**kwargs)
@@ -15,7 +14,6 @@ module ActiveRecord
15
14
  def attributes_for_hash
16
15
  super + [@sqlserver_options]
17
16
  end
18
-
19
17
  end
20
18
  end
21
19
  end
@@ -3,14 +3,12 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module SQLServer
6
-
7
6
  module ColumnMethods
8
-
9
7
  def primary_key(name, type = :primary_key, **options)
10
8
  if [:integer, :bigint].include?(type)
11
9
  options[:is_identity] = true unless options.key?(:default)
12
10
  elsif type == :uuid
13
- options[:default] = options.fetch(:default, 'NEWID()')
11
+ options[:default] = options.fetch(:default, "NEWID()")
14
12
  options[:primary_key] = true
15
13
  end
16
14
  super
@@ -97,7 +95,6 @@ module ActiveRecord
97
95
  def json(*names, **options)
98
96
  names.each { |name| column(name, :text, **options) }
99
97
  end
100
-
101
98
  end
102
99
 
103
100
  class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_record/connection_adapters/abstract/transaction'
3
+ require "active_record/connection_adapters/abstract/transaction"
4
4
 
5
5
  module ActiveRecord
6
6
  module ConnectionAdapters
7
-
8
7
  module SQLServerTransaction
9
-
10
8
  private
11
9
 
12
10
  def sqlserver?
@@ -15,23 +13,22 @@ module ActiveRecord
15
13
 
16
14
  def current_isolation_level
17
15
  return unless sqlserver?
16
+
18
17
  level = connection.user_options_isolation_level
19
18
  # When READ_COMMITTED_SNAPSHOT is set to ON,
20
19
  # user_options_isolation_level will be equal to 'read committed
21
20
  # snapshot' which is not a valid isolation level
22
- if level.blank? || level == 'read committed snapshot'
23
- 'READ COMMITTED'
21
+ if level.blank? || level == "read committed snapshot"
22
+ "READ COMMITTED"
24
23
  else
25
24
  level.upcase
26
25
  end
27
26
  end
28
-
29
27
  end
30
28
 
31
29
  Transaction.send :prepend, SQLServerTransaction
32
30
 
33
31
  module SQLServerRealTransaction
34
-
35
32
  attr_reader :starting_isolation_level
36
33
 
37
34
  def initialize(connection, options, **args)
@@ -57,7 +54,6 @@ module ActiveRecord
57
54
  connection.set_transaction_isolation_level(starting_isolation_level)
58
55
  end
59
56
  end
60
-
61
57
  end
62
58
 
63
59
  RealTransaction.send :prepend, SQLServerRealTransaction
@@ -1,48 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_record/type'
3
+ require "active_record/type"
4
4
  # Behaviors
5
- require 'active_record/connection_adapters/sqlserver/type/data'
6
- require 'active_record/connection_adapters/sqlserver/type/time_value_fractional'
5
+ require "active_record/connection_adapters/sqlserver/type/data"
6
+ require "active_record/connection_adapters/sqlserver/type/time_value_fractional"
7
7
  # Exact Numerics
8
- require 'active_record/connection_adapters/sqlserver/type/integer'
9
- require 'active_record/connection_adapters/sqlserver/type/big_integer'
10
- require 'active_record/connection_adapters/sqlserver/type/small_integer'
11
- require 'active_record/connection_adapters/sqlserver/type/tiny_integer'
12
- require 'active_record/connection_adapters/sqlserver/type/boolean'
13
- require 'active_record/connection_adapters/sqlserver/type/decimal'
14
- require 'active_record/connection_adapters/sqlserver/type/money'
15
- require 'active_record/connection_adapters/sqlserver/type/small_money'
8
+ require "active_record/connection_adapters/sqlserver/type/integer"
9
+ require "active_record/connection_adapters/sqlserver/type/big_integer"
10
+ require "active_record/connection_adapters/sqlserver/type/small_integer"
11
+ require "active_record/connection_adapters/sqlserver/type/tiny_integer"
12
+ require "active_record/connection_adapters/sqlserver/type/boolean"
13
+ require "active_record/connection_adapters/sqlserver/type/decimal"
14
+ require "active_record/connection_adapters/sqlserver/type/money"
15
+ require "active_record/connection_adapters/sqlserver/type/small_money"
16
16
  # Approximate Numerics
17
- require 'active_record/connection_adapters/sqlserver/type/float'
18
- require 'active_record/connection_adapters/sqlserver/type/real'
17
+ require "active_record/connection_adapters/sqlserver/type/float"
18
+ require "active_record/connection_adapters/sqlserver/type/real"
19
19
  # Date and Time
20
- require 'active_record/connection_adapters/sqlserver/type/date'
21
- require 'active_record/connection_adapters/sqlserver/type/datetime'
22
- require 'active_record/connection_adapters/sqlserver/type/datetime2'
23
- require 'active_record/connection_adapters/sqlserver/type/datetimeoffset'
24
- require 'active_record/connection_adapters/sqlserver/type/smalldatetime'
25
- require 'active_record/connection_adapters/sqlserver/type/time'
20
+ require "active_record/connection_adapters/sqlserver/type/date"
21
+ require "active_record/connection_adapters/sqlserver/type/datetime"
22
+ require "active_record/connection_adapters/sqlserver/type/datetime2"
23
+ require "active_record/connection_adapters/sqlserver/type/datetimeoffset"
24
+ require "active_record/connection_adapters/sqlserver/type/smalldatetime"
25
+ require "active_record/connection_adapters/sqlserver/type/time"
26
26
  # Character Strings
27
- require 'active_record/connection_adapters/sqlserver/type/string'
28
- require 'active_record/connection_adapters/sqlserver/type/char'
29
- require 'active_record/connection_adapters/sqlserver/type/varchar'
30
- require 'active_record/connection_adapters/sqlserver/type/varchar_max'
31
- require 'active_record/connection_adapters/sqlserver/type/text'
27
+ require "active_record/connection_adapters/sqlserver/type/string"
28
+ require "active_record/connection_adapters/sqlserver/type/char"
29
+ require "active_record/connection_adapters/sqlserver/type/varchar"
30
+ require "active_record/connection_adapters/sqlserver/type/varchar_max"
31
+ require "active_record/connection_adapters/sqlserver/type/text"
32
32
  # Unicode Character Strings
33
- require 'active_record/connection_adapters/sqlserver/type/unicode_string'
34
- require 'active_record/connection_adapters/sqlserver/type/unicode_char'
35
- require 'active_record/connection_adapters/sqlserver/type/unicode_varchar'
36
- require 'active_record/connection_adapters/sqlserver/type/unicode_varchar_max'
37
- require 'active_record/connection_adapters/sqlserver/type/unicode_text'
33
+ require "active_record/connection_adapters/sqlserver/type/unicode_string"
34
+ require "active_record/connection_adapters/sqlserver/type/unicode_char"
35
+ require "active_record/connection_adapters/sqlserver/type/unicode_varchar"
36
+ require "active_record/connection_adapters/sqlserver/type/unicode_varchar_max"
37
+ require "active_record/connection_adapters/sqlserver/type/unicode_text"
38
38
  # Binary Strings
39
- require 'active_record/connection_adapters/sqlserver/type/binary'
40
- require 'active_record/connection_adapters/sqlserver/type/varbinary'
41
- require 'active_record/connection_adapters/sqlserver/type/varbinary_max'
39
+ require "active_record/connection_adapters/sqlserver/type/binary"
40
+ require "active_record/connection_adapters/sqlserver/type/varbinary"
41
+ require "active_record/connection_adapters/sqlserver/type/varbinary_max"
42
42
  # Other Data Types
43
- require 'active_record/connection_adapters/sqlserver/type/uuid'
44
- require 'active_record/connection_adapters/sqlserver/type/timestamp'
45
- require 'active_record/connection_adapters/sqlserver/type/json'
43
+ require "active_record/connection_adapters/sqlserver/type/uuid"
44
+ require "active_record/connection_adapters/sqlserver/type/timestamp"
45
+ require "active_record/connection_adapters/sqlserver/type/json"
46
46
 
47
47
  module ActiveRecord
48
48
  module Type
@@ -5,11 +5,9 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class BigInteger < Integer
8
-
9
8
  def sqlserver_type
10
9
  "bigint"
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Binary < ActiveRecord::Type::Binary
8
-
9
8
  def type
10
9
  :binary_basic
11
10
  end
@@ -16,7 +15,6 @@ module ActiveRecord
16
15
  type
17
16
  end
18
17
  end
19
-
20
18
  end
21
19
  end
22
20
  end
@@ -5,11 +5,9 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Boolean < ActiveRecord::Type::Boolean
8
-
9
8
  def sqlserver_type
10
9
  "bit"
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Char < String
8
-
9
8
  def type
10
9
  :char
11
10
  end
@@ -13,6 +12,7 @@ module ActiveRecord
13
12
  def serialize(value)
14
13
  return if value.nil?
15
14
  return value if value.is_a?(Data)
15
+
16
16
  Data.new super, self
17
17
  end
18
18
 
@@ -25,9 +25,9 @@ module ActiveRecord
25
25
 
26
26
  def quoted(value)
27
27
  return value.quoted_id if value.respond_to?(:quoted_id)
28
+
28
29
  Utils.quote_string_single(value)
29
30
  end
30
-
31
31
  end
32
32
  end
33
33
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Data
8
-
9
8
  attr_reader :value, :type
10
9
 
11
10
  def initialize(value, type)
@@ -29,7 +28,6 @@ module ActiveRecord
29
28
  self.class == other.class && self.value == other.value
30
29
  end
31
30
  alias :== :eql?
32
-
33
31
  end
34
32
  end
35
33
  end
@@ -5,13 +5,13 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Date < ActiveRecord::Type::Date
8
-
9
8
  def sqlserver_type
10
- 'date'
9
+ "date"
11
10
  end
12
11
 
13
12
  def serialize(value)
14
13
  return unless value.present?
14
+
15
15
  date = super(value).to_s(:_sqlserver_dateformat)
16
16
  Data.new date, self
17
17
  end
@@ -39,7 +39,6 @@ module ActiveRecord
39
39
  def fast_string_to_date_format
40
40
  ::Date::DATE_FORMATS[:_sqlserver_dateformat]
41
41
  end
42
-
43
42
  end
44
43
  end
45
44
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class DateTime < ActiveRecord::Type::DateTime
8
-
9
8
  include TimeValueFractional
10
9
 
11
10
  def sqlserver_type
@@ -15,7 +14,7 @@ module ActiveRecord
15
14
  def serialize(value)
16
15
  value = super
17
16
  return value unless value.acts_like?(:time)
18
-
17
+
19
18
  datetime = "#{value.to_s(:_sqlserver_datetime)}.#{quote_fractional(value)}"
20
19
 
21
20
  Data.new datetime, self
@@ -36,7 +35,7 @@ module ActiveRecord
36
35
  private
37
36
 
38
37
  def fast_string_to_time(string)
39
- time = ActiveSupport::TimeZone['UTC'].strptime(string, fast_string_to_time_format)
38
+ time = ActiveSupport::TimeZone["UTC"].strptime(string, fast_string_to_time_format)
40
39
  new_time(time.year, time.month, time.day, time.hour,
41
40
  time.min, time.sec, Rational(time.nsec, 1_000))
42
41
  rescue ArgumentError
@@ -5,13 +5,11 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class DateTime2 < DateTime
8
-
9
8
  include TimeValueFractional2
10
9
 
11
10
  def sqlserver_type
12
11
  "datetime2(#{precision.to_i})"
13
12
  end
14
-
15
13
  end
16
14
  end
17
15
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class DateTimeOffset < DateTime2
8
-
9
8
  def type
10
9
  :datetimeoffset
11
10
  end
@@ -17,7 +16,6 @@ module ActiveRecord
17
16
  def quoted(value)
18
17
  Utils.quote_string_single(value)
19
18
  end
20
-
21
19
  end
22
20
  end
23
21
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Decimal < ActiveRecord::Type::Decimal
8
-
9
8
  def sqlserver_type
10
9
  "decimal".yield_self do |type|
11
10
  type += "(#{precision.to_i},#{scale.to_i})" if precision || scale
@@ -16,7 +15,6 @@ module ActiveRecord
16
15
  def type_cast_for_schema(value)
17
16
  value.is_a?(BigDecimal) ? value.to_s : value.inspect
18
17
  end
19
-
20
18
  end
21
19
  end
22
20
  end
@@ -5,7 +5,6 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Float < ActiveRecord::Type::Float
8
-
9
8
  def type
10
9
  :float
11
10
  end
@@ -13,7 +12,6 @@ module ActiveRecord
13
12
  def sqlserver_type
14
13
  "float"
15
14
  end
16
-
17
15
  end
18
16
  end
19
17
  end
@@ -5,11 +5,9 @@ module ActiveRecord
5
5
  module SQLServer
6
6
  module Type
7
7
  class Integer < ActiveRecord::Type::Integer
8
-
9
8
  def sqlserver_type
10
9
  "int"
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end