Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/active_record/connection_adapters/sqlserver/type/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module SQLServer
module Type
class Time < ActiveRecord::Type::Time

# Default fractional scale for 'time' (See https://docs.microsoft.com/en-us/sql/t-sql/data-types/time-transact-sql)
DEFAULT_FRACTIONAL_SCALE = 7

include TimeValueFractional2

def serialize(value)
Expand Down Expand Up @@ -45,7 +42,7 @@ def cast_value(value)
end

def fractional_scale
precision || DEFAULT_FRACTIONAL_SCALE
precision
end

end
Expand Down
6 changes: 4 additions & 2 deletions lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class SQLServerAdapter < AbstractAdapter

ADAPTER_NAME = 'SQLServer'.freeze

# Default precision for 'time' (See https://docs.microsoft.com/en-us/sql/t-sql/data-types/time-transact-sql)
DEFAULT_TIME_PRECISION = 7

attr_reader :spid

cattr_accessor :cs_equality_operator, instance_accessor: false
Expand Down Expand Up @@ -297,8 +300,7 @@ def initialize_type_map(m = type_map)
end
m.register_type 'smalldatetime', SQLServer::Type::SmallDateTime.new
m.register_type %r{\Atime}i do |sql_type|
scale = extract_scale(sql_type)
precision = extract_precision(sql_type)
precision = extract_precision(sql_type) || DEFAULT_TIME_PRECISION
SQLServer::Type::Time.new precision: precision
end
# Character Strings
Expand Down