activerecord-sqlserver-adapter 5.2.1 → 6.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +9 -0
- data/.github/issue_template.md +23 -0
- data/.travis.yml +6 -8
- data/CHANGELOG.md +22 -32
- data/{Dockerfile → Dockerfile.ci} +1 -1
- data/Gemfile +42 -41
- data/README.md +9 -30
- data/RUNNING_UNIT_TESTS.md +3 -0
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/activerecord-sqlserver-adapter.gemspec +25 -14
- data/appveyor.yml +24 -17
- data/docker-compose.ci.yml +7 -5
- data/guides/RELEASING.md +11 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain_subscriber.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb +6 -4
- data/lib/active_record/connection_adapters/sqlserver/core_ext/preloader.rb +36 -0
- data/lib/active_record/connection_adapters/sqlserver/core_ext/query_methods.rb +4 -1
- data/lib/active_record/connection_adapters/sqlserver/database_limits.rb +9 -0
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +55 -14
- data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/errors.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/quoting.rb +38 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +16 -3
- data/lib/active_record/connection_adapters/sqlserver/schema_dumper.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +93 -70
- data/lib/active_record/connection_adapters/sqlserver/showplan.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/table_definition.rb +42 -40
- data/lib/active_record/connection_adapters/sqlserver/transaction.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/big_integer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/binary.rb +5 -2
- data/lib/active_record/connection_adapters/sqlserver/type/boolean.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/char.rb +5 -2
- data/lib/active_record/connection_adapters/sqlserver/type/data.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/date.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +7 -6
- data/lib/active_record/connection_adapters/sqlserver/type/datetime2.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/datetimeoffset.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/decimal.rb +5 -2
- data/lib/active_record/connection_adapters/sqlserver/type/float.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/integer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/json.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/money.rb +4 -2
- data/lib/active_record/connection_adapters/sqlserver/type/real.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/small_integer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/small_money.rb +4 -2
- data/lib/active_record/connection_adapters/sqlserver/type/smalldatetime.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/string.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/text.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/time.rb +5 -4
- data/lib/active_record/connection_adapters/sqlserver/type/time_value_fractional.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/timestamp.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/tiny_integer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_char.rb +5 -2
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_string.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_text.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar.rb +6 -3
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar_max.rb +4 -2
- data/lib/active_record/connection_adapters/sqlserver/type/uuid.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/type/varbinary.rb +6 -3
- data/lib/active_record/connection_adapters/sqlserver/type/varbinary_max.rb +4 -2
- data/lib/active_record/connection_adapters/sqlserver/type/varchar.rb +6 -3
- data/lib/active_record/connection_adapters/sqlserver/type/varchar_max.rb +4 -2
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver/version.rb +2 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +44 -10
- data/lib/active_record/connection_adapters/sqlserver_column.rb +9 -3
- data/lib/active_record/sqlserver_base.rb +8 -0
- data/lib/active_record/tasks/sqlserver_database_tasks.rb +2 -0
- data/lib/activerecord-sqlserver-adapter.rb +2 -0
- data/lib/arel/visitors/sqlserver.rb +40 -10
- data/lib/arel_sqlserver.rb +2 -0
- data/test/appveyor/dbsetup.ps1 +4 -4
- data/test/cases/adapter_test_sqlserver.rb +65 -1
- data/test/cases/change_column_null_test_sqlserver.rb +2 -0
- data/test/cases/coerced_tests.rb +644 -187
- data/test/cases/column_test_sqlserver.rb +2 -1
- data/test/cases/connection_test_sqlserver.rb +2 -0
- data/test/cases/execute_procedure_test_sqlserver.rb +2 -0
- data/test/cases/fetch_test_sqlserver.rb +2 -0
- data/test/cases/fully_qualified_identifier_test_sqlserver.rb +4 -2
- data/test/cases/helper_sqlserver.rb +2 -0
- data/test/cases/in_clause_test_sqlserver.rb +36 -0
- data/test/cases/index_test_sqlserver.rb +2 -0
- data/test/cases/json_test_sqlserver.rb +2 -0
- data/test/cases/migration_test_sqlserver.rb +4 -2
- data/test/cases/order_test_sqlserver.rb +2 -0
- data/test/cases/pessimistic_locking_test_sqlserver.rb +2 -0
- data/test/cases/rake_test_sqlserver.rb +2 -0
- data/test/cases/schema_dumper_test_sqlserver.rb +3 -1
- data/test/cases/schema_test_sqlserver.rb +2 -0
- data/test/cases/scratchpad_test_sqlserver.rb +2 -0
- data/test/cases/showplan_test_sqlserver.rb +4 -2
- data/test/cases/specific_schema_test_sqlserver.rb +2 -0
- data/test/cases/transaction_test_sqlserver.rb +2 -1
- data/test/cases/trigger_test_sqlserver.rb +2 -1
- data/test/cases/utils_test_sqlserver.rb +2 -0
- data/test/cases/uuid_test_sqlserver.rb +2 -1
- data/test/debug.rb +2 -0
- data/test/migrations/create_clients_and_change_column_null.rb +2 -0
- data/test/migrations/transaction_table/1_table_will_never_be_created.rb +2 -0
- data/test/models/sqlserver/booking.rb +2 -0
- data/test/models/sqlserver/customers_view.rb +2 -0
- data/test/models/sqlserver/datatype.rb +2 -0
- data/test/models/sqlserver/datatype_migration.rb +2 -0
- data/test/models/sqlserver/dollar_table_name.rb +2 -0
- data/test/models/sqlserver/edge_schema.rb +2 -0
- data/test/models/sqlserver/fk_has_fk.rb +2 -0
- data/test/models/sqlserver/fk_has_pk.rb +2 -0
- data/test/models/sqlserver/natural_pk_data.rb +2 -0
- data/test/models/sqlserver/natural_pk_int_data.rb +2 -0
- data/test/models/sqlserver/no_pk_data.rb +2 -0
- data/test/models/sqlserver/object_default.rb +2 -0
- data/test/models/sqlserver/quoted_table.rb +2 -0
- data/test/models/sqlserver/quoted_view_1.rb +2 -0
- data/test/models/sqlserver/quoted_view_2.rb +2 -0
- data/test/models/sqlserver/sst_memory.rb +2 -0
- data/test/models/sqlserver/string_default.rb +2 -0
- data/test/models/sqlserver/string_defaults_big_view.rb +2 -0
- data/test/models/sqlserver/string_defaults_view.rb +2 -0
- data/test/models/sqlserver/tinyint_pk.rb +2 -0
- data/test/models/sqlserver/trigger.rb +2 -0
- data/test/models/sqlserver/trigger_history.rb +2 -0
- data/test/models/sqlserver/upper.rb +2 -0
- data/test/models/sqlserver/uppered.rb +2 -0
- data/test/models/sqlserver/uuid.rb +2 -0
- data/test/schema/sqlserver_specific_schema.rb +2 -0
- data/test/support/coerceable_test_sqlserver.rb +14 -5
- data/test/support/connection_reflection.rb +2 -0
- data/test/support/core_ext/query_cache.rb +3 -0
- data/test/support/load_schema_sqlserver.rb +2 -0
- data/test/support/minitest_sqlserver.rb +2 -0
- data/test/support/paths_sqlserver.rb +2 -0
- data/test/support/rake_helpers.rb +1 -0
- data/test/support/sql_counter_sqlserver.rb +3 -0
- data/test/support/test_in_memory_oltp.rb +2 -0
- metadata +18 -9
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -9,8 +11,9 @@ module ActiveRecord
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def sqlserver_type
|
12
|
-
|
13
|
-
type
|
14
|
+
"binary".yield_self do |type|
|
15
|
+
type += "(#{limit})" if limit
|
16
|
+
type
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -15,8 +17,9 @@ module ActiveRecord
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def sqlserver_type
|
18
|
-
|
19
|
-
type
|
20
|
+
"char".yield_self do |type|
|
21
|
+
type += "(#{limit})" if limit
|
22
|
+
type
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -5,7 +7,7 @@ module ActiveRecord
|
|
5
7
|
class Date < ActiveRecord::Type::Date
|
6
8
|
|
7
9
|
def sqlserver_type
|
8
|
-
'date'
|
10
|
+
'date'
|
9
11
|
end
|
10
12
|
|
11
13
|
def serialize(value)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -7,16 +9,15 @@ module ActiveRecord
|
|
7
9
|
include TimeValueFractional
|
8
10
|
|
9
11
|
def sqlserver_type
|
10
|
-
|
12
|
+
"datetime"
|
11
13
|
end
|
12
14
|
|
13
15
|
def serialize(value)
|
14
16
|
value = super
|
15
17
|
return value unless value.acts_like?(:time)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
18
|
+
|
19
|
+
datetime = "#{value.to_s(:_sqlserver_datetime)}.#{quote_fractional(value)}"
|
20
|
+
|
20
21
|
Data.new datetime, self
|
21
22
|
end
|
22
23
|
|
@@ -43,7 +44,7 @@ module ActiveRecord
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def fast_string_to_time_format
|
46
|
-
"#{::Time::DATE_FORMATS[:_sqlserver_datetime]}.%N"
|
47
|
+
"#{::Time::DATE_FORMATS[:_sqlserver_datetime]}.%N"
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -5,8 +7,9 @@ module ActiveRecord
|
|
5
7
|
class Decimal < ActiveRecord::Type::Decimal
|
6
8
|
|
7
9
|
def sqlserver_type
|
8
|
-
|
9
|
-
type
|
10
|
+
"decimal".yield_self do |type|
|
11
|
+
type += "(#{precision.to_i},#{scale.to_i})" if precision || scale
|
12
|
+
type
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
4
6
|
module Type
|
5
7
|
class Money < Decimal
|
6
8
|
|
7
|
-
def initialize(
|
9
|
+
def initialize(**args)
|
8
10
|
super
|
9
11
|
@precision = 19
|
10
12
|
@scale = 4
|
@@ -15,7 +17,7 @@ module ActiveRecord
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def sqlserver_type
|
18
|
-
|
20
|
+
"money"
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
4
6
|
module Type
|
5
7
|
class SmallMoney < Money
|
6
8
|
|
7
|
-
def initialize(
|
9
|
+
def initialize(**args)
|
8
10
|
super
|
9
11
|
@precision = 10
|
10
12
|
@scale = 4
|
@@ -15,7 +17,7 @@ module ActiveRecord
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def sqlserver_type
|
18
|
-
|
20
|
+
"smallmoney"
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -9,10 +11,9 @@ module ActiveRecord
|
|
9
11
|
def serialize(value)
|
10
12
|
value = super
|
11
13
|
return value unless value.acts_like?(:time)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
14
|
+
|
15
|
+
time = "#{value.to_s(:_sqlserver_time)}.#{quote_fractional(value)}"
|
16
|
+
|
16
17
|
Data.new time, self
|
17
18
|
end
|
18
19
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -9,8 +11,9 @@ module ActiveRecord
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def sqlserver_type
|
12
|
-
'nchar'.
|
13
|
-
type
|
14
|
+
'nchar'.yield_self do |type|
|
15
|
+
type += "(#{limit})" if limit
|
16
|
+
type
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
4
6
|
module Type
|
5
7
|
class UnicodeVarchar < UnicodeChar
|
6
8
|
|
7
|
-
def initialize(
|
9
|
+
def initialize(**args)
|
8
10
|
super
|
9
11
|
@limit = 4000 if @limit.to_i == 0
|
10
12
|
end
|
@@ -14,8 +16,9 @@ module ActiveRecord
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def sqlserver_type
|
17
|
-
|
18
|
-
type
|
19
|
+
"nvarchar".yield_self do |type|
|
20
|
+
type += "(#{limit})" if limit
|
21
|
+
type
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
4
6
|
module Type
|
5
7
|
class UnicodeVarcharMax < UnicodeVarchar
|
6
8
|
|
7
|
-
def initialize(
|
9
|
+
def initialize(**args)
|
8
10
|
super
|
9
11
|
@limit = 2_147_483_647
|
10
12
|
end
|
@@ -14,7 +16,7 @@ module ActiveRecord
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def sqlserver_type
|
17
|
-
|
19
|
+
"nvarchar(max)"
|
18
20
|
end
|
19
21
|
|
20
22
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module SQLServer
|
@@ -13,7 +15,7 @@ module ActiveRecord
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def sqlserver_type
|
16
|
-
|
18
|
+
"uniqueidentifier"
|
17
19
|
end
|
18
20
|
|
19
21
|
def serialize(value)
|