activerecord-jdbcsqlserver-adapter 50.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +27 -0
- data/CHANGELOG.md +124 -0
- data/CODE_OF_CONDUCT.md +31 -0
- data/Dockerfile +20 -0
- data/Gemfile +77 -0
- data/Guardfile +29 -0
- data/MIT-LICENSE +20 -0
- data/RAILS5-TODO.md +5 -0
- data/README.md +93 -0
- data/RUNNING_UNIT_TESTS.md +96 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/activerecord-jdbcsqlserver-adapter.gemspec +21 -0
- data/appveyor.yml +39 -0
- data/docker-compose.ci.yml +11 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +27 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb +25 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/date_time.rb +58 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +47 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain_subscriber.rb +4 -0
- data/lib/active_record/connection_adapters/sqlserver/database_limits.rb +49 -0
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +362 -0
- data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +67 -0
- data/lib/active_record/connection_adapters/sqlserver/errors.rb +7 -0
- data/lib/active_record/connection_adapters/sqlserver/jdbc_overrides.rb +192 -0
- data/lib/active_record/connection_adapters/sqlserver/quoting.rb +99 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +34 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_dumper.rb +16 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +517 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan.rb +66 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +66 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +22 -0
- data/lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb +20 -0
- data/lib/active_record/connection_adapters/sqlserver/table_definition.rb +112 -0
- data/lib/active_record/connection_adapters/sqlserver/transaction.rb +64 -0
- data/lib/active_record/connection_adapters/sqlserver/type.rb +49 -0
- data/lib/active_record/connection_adapters/sqlserver/type/big_integer.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/type/binary.rb +21 -0
- data/lib/active_record/connection_adapters/sqlserver/type/boolean.rb +15 -0
- data/lib/active_record/connection_adapters/sqlserver/type/char.rb +32 -0
- data/lib/active_record/connection_adapters/sqlserver/type/data.rb +30 -0
- data/lib/active_record/connection_adapters/sqlserver/type/date.rb +61 -0
- data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +71 -0
- data/lib/active_record/connection_adapters/sqlserver/type/datetime2.rb +17 -0
- data/lib/active_record/connection_adapters/sqlserver/type/datetimeoffset.rb +23 -0
- data/lib/active_record/connection_adapters/sqlserver/type/decimal.rb +21 -0
- data/lib/active_record/connection_adapters/sqlserver/type/float.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/type/integer.rb +15 -0
- data/lib/active_record/connection_adapters/sqlserver/type/json.rb +11 -0
- data/lib/active_record/connection_adapters/sqlserver/type/money.rb +25 -0
- data/lib/active_record/connection_adapters/sqlserver/type/real.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/type/small_integer.rb +15 -0
- data/lib/active_record/connection_adapters/sqlserver/type/small_money.rb +25 -0
- data/lib/active_record/connection_adapters/sqlserver/type/smalldatetime.rb +29 -0
- data/lib/active_record/connection_adapters/sqlserver/type/string.rb +12 -0
- data/lib/active_record/connection_adapters/sqlserver/type/text.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/type/time.rb +68 -0
- data/lib/active_record/connection_adapters/sqlserver/type/time_value_fractional.rb +93 -0
- data/lib/active_record/connection_adapters/sqlserver/type/timestamp.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/type/tiny_integer.rb +25 -0
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_char.rb +21 -0
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_string.rb +12 -0
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_text.rb +19 -0
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar.rb +26 -0
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar_max.rb +24 -0
- data/lib/active_record/connection_adapters/sqlserver/type/uuid.rb +36 -0
- data/lib/active_record/connection_adapters/sqlserver/type/varbinary.rb +26 -0
- data/lib/active_record/connection_adapters/sqlserver/type/varbinary_max.rb +24 -0
- data/lib/active_record/connection_adapters/sqlserver/type/varchar.rb +26 -0
- data/lib/active_record/connection_adapters/sqlserver/type/varchar_max.rb +24 -0
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +146 -0
- data/lib/active_record/connection_adapters/sqlserver/version.rb +11 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +445 -0
- data/lib/active_record/connection_adapters/sqlserver_column.rb +28 -0
- data/lib/active_record/jdbc_sqlserver_connection_methods.rb +31 -0
- data/lib/active_record/sqlserver_base.rb +16 -0
- data/lib/active_record/tasks/sqlserver_database_tasks.rb +131 -0
- data/lib/activerecord-jdbcsqlserver-adapter.rb +24 -0
- data/lib/activerecord-sqlserver-adapter.rb +1 -0
- data/lib/arel/visitors/sqlserver.rb +205 -0
- data/lib/arel_sqlserver.rb +3 -0
- data/test/appveyor/dbsetup.ps1 +27 -0
- data/test/appveyor/dbsetup.sql +11 -0
- data/test/bin/wait-for.sh +79 -0
- data/test/cases/adapter_test_sqlserver.rb +430 -0
- data/test/cases/coerced_tests.rb +845 -0
- data/test/cases/column_test_sqlserver.rb +812 -0
- data/test/cases/connection_test_sqlserver.rb +71 -0
- data/test/cases/execute_procedure_test_sqlserver.rb +45 -0
- data/test/cases/fetch_test_sqlserver.rb +57 -0
- data/test/cases/fully_qualified_identifier_test_sqlserver.rb +76 -0
- data/test/cases/helper_sqlserver.rb +44 -0
- data/test/cases/index_test_sqlserver.rb +47 -0
- data/test/cases/json_test_sqlserver.rb +32 -0
- data/test/cases/migration_test_sqlserver.rb +61 -0
- data/test/cases/order_test_sqlserver.rb +147 -0
- data/test/cases/pessimistic_locking_test_sqlserver.rb +94 -0
- data/test/cases/rake_test_sqlserver.rb +169 -0
- data/test/cases/schema_dumper_test_sqlserver.rb +234 -0
- data/test/cases/schema_test_sqlserver.rb +54 -0
- data/test/cases/scratchpad_test_sqlserver.rb +8 -0
- data/test/cases/showplan_test_sqlserver.rb +65 -0
- data/test/cases/specific_schema_test_sqlserver.rb +180 -0
- data/test/cases/transaction_test_sqlserver.rb +91 -0
- data/test/cases/utils_test_sqlserver.rb +129 -0
- data/test/cases/uuid_test_sqlserver.rb +49 -0
- data/test/config.yml +38 -0
- data/test/debug.rb +14 -0
- data/test/fixtures/1px.gif +0 -0
- data/test/migrations/transaction_table/1_table_will_never_be_created.rb +11 -0
- data/test/models/sqlserver/booking.rb +3 -0
- data/test/models/sqlserver/customers_view.rb +3 -0
- data/test/models/sqlserver/datatype.rb +3 -0
- data/test/models/sqlserver/datatype_migration.rb +8 -0
- data/test/models/sqlserver/dollar_table_name.rb +3 -0
- data/test/models/sqlserver/dot_table_name.rb +3 -0
- data/test/models/sqlserver/edge_schema.rb +13 -0
- data/test/models/sqlserver/fk_has_fk.rb +3 -0
- data/test/models/sqlserver/fk_has_pk.rb +3 -0
- data/test/models/sqlserver/natural_pk_data.rb +4 -0
- data/test/models/sqlserver/natural_pk_int_data.rb +3 -0
- data/test/models/sqlserver/no_pk_data.rb +3 -0
- data/test/models/sqlserver/object_default.rb +3 -0
- data/test/models/sqlserver/quoted_table.rb +7 -0
- data/test/models/sqlserver/quoted_view_1.rb +3 -0
- data/test/models/sqlserver/quoted_view_2.rb +3 -0
- data/test/models/sqlserver/sst_memory.rb +3 -0
- data/test/models/sqlserver/string_default.rb +3 -0
- data/test/models/sqlserver/string_defaults_big_view.rb +3 -0
- data/test/models/sqlserver/string_defaults_view.rb +3 -0
- data/test/models/sqlserver/tinyint_pk.rb +3 -0
- data/test/models/sqlserver/upper.rb +3 -0
- data/test/models/sqlserver/uppered.rb +3 -0
- data/test/models/sqlserver/uuid.rb +3 -0
- data/test/schema/datatypes/2012.sql +55 -0
- data/test/schema/enable-in-memory-oltp.sql +81 -0
- data/test/schema/sqlserver_specific_schema.rb +238 -0
- data/test/support/coerceable_test_sqlserver.rb +49 -0
- data/test/support/connection_reflection.rb +34 -0
- data/test/support/load_schema_sqlserver.rb +29 -0
- data/test/support/minitest_sqlserver.rb +1 -0
- data/test/support/paths_sqlserver.rb +50 -0
- data/test/support/rake_helpers.rb +41 -0
- data/test/support/sql_counter_sqlserver.rb +28 -0
- data/test/support/test_in_memory_oltp.rb +15 -0
- metadata +310 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'active_record/connection_adapters/sqlserver/showplan/printer_table'
|
2
|
+
require 'active_record/connection_adapters/sqlserver/showplan/printer_xml'
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
module ConnectionAdapters
|
6
|
+
module SQLServer
|
7
|
+
module Showplan
|
8
|
+
|
9
|
+
OPTION_ALL = 'SHOWPLAN_ALL'
|
10
|
+
OPTION_TEXT = 'SHOWPLAN_TEXT'
|
11
|
+
OPTION_XML = 'SHOWPLAN_XML'
|
12
|
+
OPTIONS = [OPTION_ALL, OPTION_TEXT, OPTION_XML]
|
13
|
+
|
14
|
+
def explain(arel, binds = [])
|
15
|
+
sql = to_sql(arel)
|
16
|
+
result = with_showplan_on { sp_executesql(sql, 'EXPLAIN', binds) }
|
17
|
+
printer = showplan_printer.new(result)
|
18
|
+
printer.pp
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def with_showplan_on
|
24
|
+
set_showplan_option(true)
|
25
|
+
yield
|
26
|
+
ensure
|
27
|
+
set_showplan_option(false)
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_showplan_option(enable = true)
|
31
|
+
sql = "SET #{showplan_option} #{enable ? 'ON' : 'OFF'}"
|
32
|
+
raw_connection_do(sql)
|
33
|
+
rescue Exception
|
34
|
+
raise ActiveRecordError, "#{showplan_option} could not be turned #{enable ? 'ON' : 'OFF'}, perhaps you do not have SHOWPLAN permissions?"
|
35
|
+
end
|
36
|
+
|
37
|
+
def showplan_option
|
38
|
+
(SQLServerAdapter.showplan_option || OPTION_ALL).tap do |opt|
|
39
|
+
raise(ArgumentError, "Unknown SHOWPLAN option #{opt.inspect} found.") if OPTIONS.exclude?(opt)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def showplan_all?
|
44
|
+
showplan_option == OPTION_ALL
|
45
|
+
end
|
46
|
+
|
47
|
+
def showplan_text?
|
48
|
+
showplan_option == OPTION_TEXT
|
49
|
+
end
|
50
|
+
|
51
|
+
def showplan_xml?
|
52
|
+
showplan_option == OPTION_XML
|
53
|
+
end
|
54
|
+
|
55
|
+
def showplan_printer
|
56
|
+
case showplan_option
|
57
|
+
when OPTION_XML then PrinterXml
|
58
|
+
when OPTION_ALL, OPTION_TEXT then PrinterTable
|
59
|
+
else PrinterTable
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module ConnectionAdapters
|
3
|
+
module SQLServer
|
4
|
+
module Showplan
|
5
|
+
class PrinterTable
|
6
|
+
cattr_accessor :max_column_width, :cell_padding
|
7
|
+
self.max_column_width = 50
|
8
|
+
self.cell_padding = 1
|
9
|
+
|
10
|
+
attr_reader :result
|
11
|
+
|
12
|
+
def initialize(result)
|
13
|
+
@result = result
|
14
|
+
end
|
15
|
+
|
16
|
+
def pp
|
17
|
+
@widths = compute_column_widths
|
18
|
+
@separator = build_separator
|
19
|
+
pp = []
|
20
|
+
pp << @separator
|
21
|
+
pp << build_cells(result.columns)
|
22
|
+
pp << @separator
|
23
|
+
result.rows.each do |row|
|
24
|
+
pp << build_cells(row)
|
25
|
+
end
|
26
|
+
pp << @separator
|
27
|
+
pp.join("\n") + "\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def compute_column_widths
|
33
|
+
[].tap do |computed_widths|
|
34
|
+
result.columns.each_with_index do |column, i|
|
35
|
+
cells_in_column = [column] + result.rows.map { |r| cast_item(r[i]) }
|
36
|
+
computed_width = cells_in_column.map(&:length).max
|
37
|
+
final_width = computed_width > max_column_width ? max_column_width : computed_width
|
38
|
+
computed_widths << final_width
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_separator
|
44
|
+
'+' + @widths.map { |w| '-' * (w + (cell_padding * 2)) }.join('+') + '+'
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_cells(items)
|
48
|
+
cells = []
|
49
|
+
items.each_with_index do |item, i|
|
50
|
+
cells << cast_item(item).ljust(@widths[i])
|
51
|
+
end
|
52
|
+
"| #{cells.join(' | ')} |"
|
53
|
+
end
|
54
|
+
|
55
|
+
def cast_item(item)
|
56
|
+
case item
|
57
|
+
when NilClass then 'NULL'
|
58
|
+
when Float then item.to_s.to(9)
|
59
|
+
else item.to_s.truncate(max_column_width)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module ConnectionAdapters
|
3
|
+
module SQLServer
|
4
|
+
module Showplan
|
5
|
+
class PrinterXml
|
6
|
+
def initialize(result)
|
7
|
+
@result = result
|
8
|
+
end
|
9
|
+
|
10
|
+
def pp
|
11
|
+
xml = @result.rows.first.first
|
12
|
+
if defined?(Nokogiri)
|
13
|
+
Nokogiri::XML(xml).to_xml indent: 2, encoding: 'UTF-8'
|
14
|
+
else
|
15
|
+
xml
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module ConnectionAdapters
|
3
|
+
module SQLServer
|
4
|
+
class SqlTypeMetadata < ActiveRecord::ConnectionAdapters::SqlTypeMetadata
|
5
|
+
|
6
|
+
def initialize(**kwargs)
|
7
|
+
@sqlserver_options = kwargs.extract!(:sqlserver_options)
|
8
|
+
super(**kwargs)
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def attributes_for_hash
|
14
|
+
super + [@sqlserver_options]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module ConnectionAdapters
|
3
|
+
module SQLServer
|
4
|
+
|
5
|
+
module ColumnMethods
|
6
|
+
|
7
|
+
def primary_key(name, type = :primary_key, **options)
|
8
|
+
return super unless type == :uuid
|
9
|
+
options[:default] = options.fetch(:default, 'NEWID()')
|
10
|
+
options[:primary_key] = true
|
11
|
+
column name, type, options
|
12
|
+
end
|
13
|
+
|
14
|
+
def primary_key_nonclustered(*args, **options)
|
15
|
+
args.each { |name| column(name, :primary_key_nonclustered, options) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def real(*args, **options)
|
19
|
+
args.each { |name| column(name, :real, options) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def money(*args, **options)
|
23
|
+
args.each { |name| column(name, :money, options) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def smalldatetime(*args, **options)
|
27
|
+
args.each { |name| column(name, :smalldatetime, options) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def datetime(*args, **options)
|
31
|
+
args.each do |name|
|
32
|
+
if options[:precision]
|
33
|
+
datetime2(name, options)
|
34
|
+
else
|
35
|
+
column(name, :datetime, options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def datetime2(*args, **options)
|
41
|
+
args.each { |name| column(name, :datetime2, options) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def datetimeoffset(*args, **options)
|
45
|
+
args.each { |name| column(name, :datetimeoffset, options) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def smallmoney(*args, **options)
|
49
|
+
args.each { |name| column(name, :smallmoney, options) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def char(*args, **options)
|
53
|
+
args.each { |name| column(name, :char, options) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def varchar(*args, **options)
|
57
|
+
args.each { |name| column(name, :varchar, options) }
|
58
|
+
end
|
59
|
+
|
60
|
+
def varchar_max(*args, **options)
|
61
|
+
args.each { |name| column(name, :varchar_max, options) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def text_basic(*args, **options)
|
65
|
+
args.each { |name| column(name, :text_basic, options) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def nchar(*args, **options)
|
69
|
+
args.each { |name| column(name, :nchar, options) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def ntext(*args, **options)
|
73
|
+
args.each { |name| column(name, :ntext, options) }
|
74
|
+
end
|
75
|
+
|
76
|
+
def binary_basic(*args, **options)
|
77
|
+
args.each { |name| column(name, :binary_basic, options) }
|
78
|
+
end
|
79
|
+
|
80
|
+
def varbinary(*args, **options)
|
81
|
+
args.each { |name| column(name, :varbinary, options) }
|
82
|
+
end
|
83
|
+
|
84
|
+
def uuid(*args, **options)
|
85
|
+
args.each { |name| column(name, :uniqueidentifier, options) }
|
86
|
+
end
|
87
|
+
|
88
|
+
def ss_timestamp(*args, **options)
|
89
|
+
args.each { |name| column(name, :ss_timestamp, options) }
|
90
|
+
end
|
91
|
+
|
92
|
+
def json(*args, **options)
|
93
|
+
args.each { |name| column(name, :text, options) }
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
|
99
|
+
include ColumnMethods
|
100
|
+
|
101
|
+
def new_column_definition(name, type, options)
|
102
|
+
type = :datetime2 if type == :datetime && options[:precision]
|
103
|
+
super name, type, options
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class Table < ActiveRecord::ConnectionAdapters::Table
|
108
|
+
include ColumnMethods
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'active_record/connection_adapters/abstract/transaction'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters
|
5
|
+
|
6
|
+
module SQLServerTransaction
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def sqlserver?
|
11
|
+
connection.respond_to?(:sqlserver?) && connection.sqlserver?
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_isolation_level
|
15
|
+
return unless sqlserver?
|
16
|
+
level = connection.user_options_isolation_level
|
17
|
+
# When READ_COMMITTED_SNAPSHOT is set to ON,
|
18
|
+
# user_options_isolation_level will be equal to 'read committed
|
19
|
+
# snapshot' which is not a valid isolation level
|
20
|
+
if level.blank? || level == 'read committed snapshot'
|
21
|
+
'READ COMMITTED'
|
22
|
+
else
|
23
|
+
level.upcase
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
Transaction.send :include, SQLServerTransaction
|
30
|
+
|
31
|
+
module SQLServerRealTransaction
|
32
|
+
|
33
|
+
attr_reader :starting_isolation_level
|
34
|
+
|
35
|
+
def initialize(connection, options, run_commit_callbacks: false)
|
36
|
+
@connection = connection
|
37
|
+
@starting_isolation_level = current_isolation_level if options[:isolation]
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def commit
|
42
|
+
super
|
43
|
+
reset_starting_isolation_level
|
44
|
+
end
|
45
|
+
|
46
|
+
def rollback
|
47
|
+
super
|
48
|
+
reset_starting_isolation_level
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def reset_starting_isolation_level
|
54
|
+
if sqlserver? && starting_isolation_level
|
55
|
+
connection.set_transaction_isolation_level(starting_isolation_level)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
RealTransaction.send :include, SQLServerRealTransaction
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'active_record/type'
|
2
|
+
# Behaviors
|
3
|
+
require 'active_record/connection_adapters/sqlserver/type/data'
|
4
|
+
require 'active_record/connection_adapters/sqlserver/type/time_value_fractional'
|
5
|
+
# Exact Numerics
|
6
|
+
require 'active_record/connection_adapters/sqlserver/type/integer'
|
7
|
+
require 'active_record/connection_adapters/sqlserver/type/big_integer'
|
8
|
+
require 'active_record/connection_adapters/sqlserver/type/small_integer'
|
9
|
+
require 'active_record/connection_adapters/sqlserver/type/tiny_integer'
|
10
|
+
require 'active_record/connection_adapters/sqlserver/type/boolean'
|
11
|
+
require 'active_record/connection_adapters/sqlserver/type/decimal'
|
12
|
+
require 'active_record/connection_adapters/sqlserver/type/money'
|
13
|
+
require 'active_record/connection_adapters/sqlserver/type/small_money'
|
14
|
+
# Approximate Numerics
|
15
|
+
require 'active_record/connection_adapters/sqlserver/type/float'
|
16
|
+
require 'active_record/connection_adapters/sqlserver/type/real'
|
17
|
+
# Date and Time
|
18
|
+
require 'active_record/connection_adapters/sqlserver/type/date'
|
19
|
+
require 'active_record/connection_adapters/sqlserver/type/datetime'
|
20
|
+
require 'active_record/connection_adapters/sqlserver/type/datetime2'
|
21
|
+
require 'active_record/connection_adapters/sqlserver/type/datetimeoffset'
|
22
|
+
require 'active_record/connection_adapters/sqlserver/type/smalldatetime'
|
23
|
+
require 'active_record/connection_adapters/sqlserver/type/time'
|
24
|
+
# Character Strings
|
25
|
+
require 'active_record/connection_adapters/sqlserver/type/string'
|
26
|
+
require 'active_record/connection_adapters/sqlserver/type/char'
|
27
|
+
require 'active_record/connection_adapters/sqlserver/type/varchar'
|
28
|
+
require 'active_record/connection_adapters/sqlserver/type/varchar_max'
|
29
|
+
require 'active_record/connection_adapters/sqlserver/type/text'
|
30
|
+
# Unicode Character Strings
|
31
|
+
require 'active_record/connection_adapters/sqlserver/type/unicode_string'
|
32
|
+
require 'active_record/connection_adapters/sqlserver/type/unicode_char'
|
33
|
+
require 'active_record/connection_adapters/sqlserver/type/unicode_varchar'
|
34
|
+
require 'active_record/connection_adapters/sqlserver/type/unicode_varchar_max'
|
35
|
+
require 'active_record/connection_adapters/sqlserver/type/unicode_text'
|
36
|
+
# Binary Strings
|
37
|
+
require 'active_record/connection_adapters/sqlserver/type/binary'
|
38
|
+
require 'active_record/connection_adapters/sqlserver/type/varbinary'
|
39
|
+
require 'active_record/connection_adapters/sqlserver/type/varbinary_max'
|
40
|
+
# Other Data Types
|
41
|
+
require 'active_record/connection_adapters/sqlserver/type/uuid'
|
42
|
+
require 'active_record/connection_adapters/sqlserver/type/timestamp'
|
43
|
+
require 'active_record/connection_adapters/sqlserver/type/json'
|
44
|
+
|
45
|
+
module ActiveRecord
|
46
|
+
module Type
|
47
|
+
SQLServer = ConnectionAdapters::SQLServer::Type
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module ConnectionAdapters
|
3
|
+
module SQLServer
|
4
|
+
module Type
|
5
|
+
class Binary < ActiveRecord::Type::Binary
|
6
|
+
|
7
|
+
def type
|
8
|
+
:binary_basic
|
9
|
+
end
|
10
|
+
|
11
|
+
def sqlserver_type
|
12
|
+
'binary'.tap do |type|
|
13
|
+
type << "(#{limit})" if limit
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|