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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +29 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +11 -5
- data/Guardfile +9 -8
- data/Rakefile +12 -16
- data/VERSION +1 -1
- data/activerecord-sqlserver-adapter.gemspec +3 -3
- data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +0 -4
- data/lib/active_record/connection_adapters/sqlserver/core_ext/attribute_methods.rb +1 -4
- data/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +3 -4
- data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +1 -3
- data/lib/active_record/connection_adapters/sqlserver/core_ext/finder_methods.rb +2 -3
- data/lib/active_record/connection_adapters/sqlserver/core_ext/query_methods.rb +2 -3
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +35 -32
- data/lib/active_record/connection_adapters/sqlserver/database_tasks.rb +7 -12
- data/lib/active_record/connection_adapters/sqlserver/errors.rb +0 -3
- data/lib/active_record/connection_adapters/sqlserver/quoting.rb +8 -8
- data/lib/active_record/connection_adapters/sqlserver/schema_creation.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/schema_dumper.rb +7 -7
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +106 -103
- data/lib/active_record/connection_adapters/sqlserver/showplan.rb +6 -8
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +2 -2
- data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +1 -1
- data/lib/active_record/connection_adapters/sqlserver/sql_type_metadata.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/table_definition.rb +1 -4
- data/lib/active_record/connection_adapters/sqlserver/transaction.rb +4 -8
- data/lib/active_record/connection_adapters/sqlserver/type.rb +35 -35
- data/lib/active_record/connection_adapters/sqlserver/type/big_integer.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/binary.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/boolean.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/char.rb +2 -2
- data/lib/active_record/connection_adapters/sqlserver/type/data.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/date.rb +2 -3
- data/lib/active_record/connection_adapters/sqlserver/type/datetime.rb +2 -3
- data/lib/active_record/connection_adapters/sqlserver/type/datetime2.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/datetimeoffset.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/decimal.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/float.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/integer.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/json.rb +0 -1
- data/lib/active_record/connection_adapters/sqlserver/type/money.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/real.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/small_integer.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/small_money.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/smalldatetime.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/string.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/text.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/time.rb +2 -3
- data/lib/active_record/connection_adapters/sqlserver/type/time_value_fractional.rb +6 -9
- data/lib/active_record/connection_adapters/sqlserver/type/timestamp.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/tiny_integer.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_char.rb +1 -3
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_string.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_text.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/unicode_varchar_max.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/uuid.rb +1 -2
- data/lib/active_record/connection_adapters/sqlserver/type/varbinary.rb +1 -3
- data/lib/active_record/connection_adapters/sqlserver/type/varbinary_max.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/type/varchar.rb +1 -3
- data/lib/active_record/connection_adapters/sqlserver/type/varchar_max.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +8 -11
- data/lib/active_record/connection_adapters/sqlserver/version.rb +0 -2
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +85 -83
- data/lib/active_record/connection_adapters/sqlserver_column.rb +0 -2
- data/lib/active_record/sqlserver_base.rb +1 -1
- data/lib/active_record/tasks/sqlserver_database_tasks.rb +26 -32
- data/lib/activerecord-sqlserver-adapter.rb +1 -1
- data/lib/arel/visitors/sqlserver.rb +18 -14
- data/lib/arel_sqlserver.rb +2 -2
- data/test/cases/adapter_test_sqlserver.rb +161 -182
- data/test/cases/change_column_null_test_sqlserver.rb +12 -12
- data/test/cases/coerced_tests.rb +88 -270
- data/test/cases/column_test_sqlserver.rb +281 -283
- data/test/cases/connection_test_sqlserver.rb +15 -20
- data/test/cases/execute_procedure_test_sqlserver.rb +18 -20
- data/test/cases/fetch_test_sqlserver.rb +14 -22
- data/test/cases/fully_qualified_identifier_test_sqlserver.rb +12 -18
- data/test/cases/helper_sqlserver.rb +13 -15
- data/test/cases/in_clause_test_sqlserver.rb +9 -9
- data/test/cases/index_test_sqlserver.rb +13 -15
- data/test/cases/json_test_sqlserver.rb +23 -25
- data/test/cases/migration_test_sqlserver.rb +22 -28
- data/test/cases/order_test_sqlserver.rb +51 -54
- data/test/cases/pessimistic_locking_test_sqlserver.rb +25 -33
- data/test/cases/rake_test_sqlserver.rb +31 -45
- data/test/cases/schema_dumper_test_sqlserver.rb +104 -108
- data/test/cases/schema_test_sqlserver.rb +18 -26
- data/test/cases/scratchpad_test_sqlserver.rb +2 -4
- data/test/cases/showplan_test_sqlserver.rb +24 -33
- data/test/cases/specific_schema_test_sqlserver.rb +66 -65
- data/test/cases/transaction_test_sqlserver.rb +16 -19
- data/test/cases/trigger_test_sqlserver.rb +12 -12
- data/test/cases/utils_test_sqlserver.rb +68 -70
- data/test/cases/uuid_test_sqlserver.rb +11 -13
- data/test/debug.rb +6 -6
- data/test/migrations/create_clients_and_change_column_null.rb +1 -1
- data/test/migrations/transaction_table/1_table_will_never_be_created.rb +2 -4
- data/test/models/sqlserver/booking.rb +1 -1
- data/test/models/sqlserver/customers_view.rb +1 -1
- data/test/models/sqlserver/dollar_table_name.rb +1 -1
- data/test/models/sqlserver/edge_schema.rb +1 -3
- data/test/models/sqlserver/fk_has_fk.rb +1 -1
- data/test/models/sqlserver/fk_has_pk.rb +1 -1
- data/test/models/sqlserver/natural_pk_data.rb +2 -2
- data/test/models/sqlserver/natural_pk_int_data.rb +1 -1
- data/test/models/sqlserver/no_pk_data.rb +1 -1
- data/test/models/sqlserver/object_default.rb +1 -1
- data/test/models/sqlserver/quoted_table.rb +2 -2
- data/test/models/sqlserver/quoted_view_1.rb +1 -1
- data/test/models/sqlserver/quoted_view_2.rb +1 -1
- data/test/models/sqlserver/sst_memory.rb +1 -1
- data/test/models/sqlserver/string_default.rb +1 -1
- data/test/models/sqlserver/string_defaults_big_view.rb +1 -1
- data/test/models/sqlserver/string_defaults_view.rb +1 -1
- data/test/models/sqlserver/tinyint_pk.rb +1 -1
- data/test/models/sqlserver/trigger.rb +2 -2
- data/test/models/sqlserver/trigger_history.rb +1 -1
- data/test/models/sqlserver/upper.rb +1 -1
- data/test/models/sqlserver/uppered.rb +1 -1
- data/test/models/sqlserver/uuid.rb +1 -1
- data/test/schema/sqlserver_specific_schema.rb +20 -22
- data/test/support/coerceable_test_sqlserver.rb +1 -4
- data/test/support/connection_reflection.rb +1 -2
- data/test/support/core_ext/query_cache.rb +1 -1
- data/test/support/load_schema_sqlserver.rb +3 -5
- data/test/support/minitest_sqlserver.rb +1 -1
- data/test/support/paths_sqlserver.rb +9 -11
- data/test/support/rake_helpers.rb +12 -10
- data/test/support/sql_counter_sqlserver.rb +0 -4
- data/test/support/test_in_memory_oltp.rb +7 -7
- metadata +5 -4
@@ -1,30 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "cases/helper_sqlserver"
|
4
4
|
|
5
5
|
class SQLServerTriggerTest < ActiveRecord::TestCase
|
6
|
-
after
|
6
|
+
after { exclude_output_inserted_table_names.clear }
|
7
7
|
|
8
8
|
let(:exclude_output_inserted_table_names) do
|
9
9
|
ActiveRecord::ConnectionAdapters::SQLServerAdapter.exclude_output_inserted_table_names
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
13
|
-
exclude_output_inserted_table_names[
|
12
|
+
it "can insert into a table with output inserted - with a true setting for table name" do
|
13
|
+
exclude_output_inserted_table_names["sst_table_with_trigger"] = true
|
14
14
|
assert SSTestTriggerHistory.all.empty?
|
15
|
-
obj = SSTestTrigger.create! event_name:
|
16
|
-
_([
|
17
|
-
_(obj.event_name).must_equal
|
15
|
+
obj = SSTestTrigger.create! event_name: "test trigger"
|
16
|
+
_(["Fixnum", "Integer"]).must_include obj.id.class.name
|
17
|
+
_(obj.event_name).must_equal "test trigger"
|
18
18
|
_(obj.id).must_be :present?
|
19
19
|
_(obj.id.to_s).must_equal SSTestTriggerHistory.first.id_source
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
exclude_output_inserted_table_names[
|
22
|
+
it "can insert into a table with output inserted - with a uniqueidentifier value" do
|
23
|
+
exclude_output_inserted_table_names["sst_table_with_uuid_trigger"] = "uniqueidentifier"
|
24
24
|
assert SSTestTriggerHistory.all.empty?
|
25
|
-
obj = SSTestTriggerUuid.create! event_name:
|
26
|
-
_(obj.id.class.name).must_equal
|
27
|
-
_(obj.event_name).must_equal
|
25
|
+
obj = SSTestTriggerUuid.create! event_name: "test uuid trigger"
|
26
|
+
_(obj.id.class.name).must_equal "String"
|
27
|
+
_(obj.event_name).must_equal "test uuid trigger"
|
28
28
|
_(obj.id).must_be :present?
|
29
29
|
_(obj.id.to_s).must_equal SSTestTriggerHistory.first.id_source
|
30
30
|
end
|
@@ -1,61 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "cases/helper_sqlserver"
|
4
4
|
|
5
5
|
class UtilsTestSQLServer < ActiveRecord::TestCase
|
6
|
-
|
7
|
-
it '.quote_string' do
|
6
|
+
it ".quote_string" do
|
8
7
|
_(SQLServer::Utils.quote_string("I'll store this in C:\\Users")).must_equal "I''ll store this in C:\\Users"
|
9
8
|
end
|
10
9
|
|
11
|
-
it
|
10
|
+
it ".unquote_string" do
|
12
11
|
_(SQLServer::Utils.unquote_string("I''ll store this in C:\\Users")).must_equal "I'll store this in C:\\Users"
|
13
12
|
end
|
14
13
|
|
15
|
-
it
|
14
|
+
it ".quoted_raw" do
|
16
15
|
_(SQLServer::Utils.quoted_raw("some.Name")).must_equal "[some.Name]"
|
17
16
|
end
|
18
17
|
|
19
|
-
describe
|
20
|
-
|
18
|
+
describe ".extract_identifiers constructor and thus SQLServer::Utils::Name value object" do
|
21
19
|
let(:valid_names) { valid_names_unquoted + valid_names_quoted }
|
22
20
|
|
23
|
-
let(:valid_names_unquoted) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
21
|
+
let(:valid_names_unquoted) {
|
22
|
+
[
|
23
|
+
"server.database.schema.object",
|
24
|
+
"server.database..object",
|
25
|
+
"server..schema.object",
|
26
|
+
"server...object",
|
27
|
+
"database.schema.object",
|
28
|
+
"database..object",
|
29
|
+
"schema.object",
|
30
|
+
"object"
|
31
|
+
]
|
32
|
+
}
|
33
|
+
|
34
|
+
let(:valid_names_quoted) {
|
35
|
+
[
|
36
|
+
"[server].[database].[schema].[object]",
|
37
|
+
"[server].[database]..[object]",
|
38
|
+
"[server]..[schema].[object]",
|
39
|
+
"[server]...[object]",
|
40
|
+
"[database].[schema].[object]",
|
41
|
+
"[database]..[object]",
|
42
|
+
"[schema].[object]",
|
43
|
+
"[object]"
|
44
|
+
]
|
45
|
+
}
|
44
46
|
|
45
47
|
let(:server_names) { valid_names.partition { |name| name =~ /server/ } }
|
46
48
|
let(:database_names) { valid_names.partition { |name| name =~ /database/ } }
|
47
49
|
let(:schema_names) { valid_names.partition { |name| name =~ /schema/ } }
|
48
50
|
|
49
|
-
it
|
51
|
+
it "extracts and returns #object identifier unquoted by default or quoted as needed" do
|
50
52
|
valid_names.each do |n|
|
51
53
|
name = extract_identifiers(n)
|
52
|
-
_(name.object).must_equal
|
53
|
-
_(name.object_quoted).must_equal
|
54
|
+
_(name.object).must_equal "object", "With #{n.inspect} for #object"
|
55
|
+
_(name.object_quoted).must_equal "[object]", "With #{n.inspect} for #object_quoted"
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
57
59
|
[:schema, :database, :server].each do |part|
|
58
|
-
|
59
60
|
it "extracts and returns #{part} identifier unquoted by default or quoted as needed" do
|
60
61
|
present, blank = send(:"#{part}_names")
|
61
62
|
present.each do |n|
|
@@ -69,57 +70,55 @@ class UtilsTestSQLServer < ActiveRecord::TestCase
|
|
69
70
|
_(name.send(:"#{part}_quoted")).must_be_nil "With #{n.inspect} for ##{part}_quoted method"
|
70
71
|
end
|
71
72
|
end
|
72
|
-
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
75
|
+
it "does not blow up on nil or blank string name" do
|
76
76
|
_(extract_identifiers(nil).object).must_be_nil
|
77
|
-
_(extract_identifiers(
|
77
|
+
_(extract_identifiers(" ").object).must_be_nil
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
_(extract_identifiers(
|
82
|
-
_(extract_identifiers(
|
83
|
-
_(extract_identifiers(
|
80
|
+
it "has a #quoted that returns a fully quoted name with all identifiers as orginially passed in" do
|
81
|
+
_(extract_identifiers("object").quoted).must_equal "[object]"
|
82
|
+
_(extract_identifiers("server.database..object").quoted).must_equal "[server].[database]..[object]"
|
83
|
+
_(extract_identifiers("[server]...[object]").quoted).must_equal "[server]...[object]"
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
87
|
-
_(extract_identifiers(:object).object).must_equal
|
86
|
+
it "can take a symbol argument" do
|
87
|
+
_(extract_identifiers(:object).object).must_equal "object"
|
88
88
|
end
|
89
89
|
|
90
|
-
it
|
91
|
-
_(extract_identifiers(
|
92
|
-
_(extract_identifiers(
|
90
|
+
it "allows identifiers with periods to work" do
|
91
|
+
_(extract_identifiers("[obj.name]").quoted).must_equal "[obj.name]"
|
92
|
+
_(extract_identifiers("[obj.name].[foo]").quoted).must_equal "[obj.name].[foo]"
|
93
93
|
end
|
94
94
|
|
95
|
-
it
|
96
|
-
_(extract_identifiers(
|
97
|
-
_(extract_identifiers(
|
98
|
-
_(extract_identifiers(
|
99
|
-
_(extract_identifiers(
|
100
|
-
_(extract_identifiers(
|
101
|
-
_(extract_identifiers(
|
102
|
-
_(extract_identifiers(
|
103
|
-
_(extract_identifiers(
|
104
|
-
_(extract_identifiers(
|
105
|
-
_(extract_identifiers(
|
106
|
-
_(extract_identifiers(
|
107
|
-
_(extract_identifiers(
|
108
|
-
_(extract_identifiers(
|
109
|
-
_(extract_identifiers(
|
110
|
-
_(extract_identifiers(
|
111
|
-
_(extract_identifiers(
|
95
|
+
it "should indicate if a name is fully qualitified" do
|
96
|
+
_(extract_identifiers("object").fully_qualified?).must_equal false
|
97
|
+
_(extract_identifiers("schema.object").fully_qualified?).must_equal false
|
98
|
+
_(extract_identifiers("database.schema.object").fully_qualified?).must_equal false
|
99
|
+
_(extract_identifiers("database.object").fully_qualified?).must_equal false
|
100
|
+
_(extract_identifiers("server...object").fully_qualified?).must_equal false
|
101
|
+
_(extract_identifiers("server.database..object").fully_qualified?).must_equal false
|
102
|
+
_(extract_identifiers("server.database.schema.object").fully_qualified?).must_equal true
|
103
|
+
_(extract_identifiers("server.database.schema.").fully_qualified?).must_equal true
|
104
|
+
_(extract_identifiers("[obj.name]").fully_qualified?).must_equal false
|
105
|
+
_(extract_identifiers("[schema].[obj.name]").fully_qualified?).must_equal false
|
106
|
+
_(extract_identifiers("[database].[schema].[obj.name]").fully_qualified?).must_equal false
|
107
|
+
_(extract_identifiers("[database].[obj.name]").fully_qualified?).must_equal false
|
108
|
+
_(extract_identifiers("[server.name]...[obj.name]").fully_qualified?).must_equal false
|
109
|
+
_(extract_identifiers("[server.name].[database]..[obj.name]").fully_qualified?).must_equal false
|
110
|
+
_(extract_identifiers("[server.name].[database].[schema].[obj.name]").fully_qualified?).must_equal true
|
111
|
+
_(extract_identifiers("[server.name].[database].[schema].").fully_qualified?).must_equal true
|
112
112
|
end
|
113
113
|
|
114
|
-
it
|
115
|
-
name = extract_identifiers(
|
116
|
-
_(name.fully_qualified_database_quoted).must_equal
|
117
|
-
name = extract_identifiers(
|
118
|
-
_(name.fully_qualified_database_quoted).must_equal
|
119
|
-
name = extract_identifiers(
|
120
|
-
_(name.fully_qualified_database_quoted).must_equal
|
114
|
+
it "can return fully qualified quoted table name" do
|
115
|
+
name = extract_identifiers("[my.server].db.schema.")
|
116
|
+
_(name.fully_qualified_database_quoted).must_equal "[my.server].[db]"
|
117
|
+
name = extract_identifiers("[server.name].[database].[schema].[object]")
|
118
|
+
_(name.fully_qualified_database_quoted).must_equal "[server.name].[database]"
|
119
|
+
name = extract_identifiers("server.database.schema.object")
|
120
|
+
_(name.fully_qualified_database_quoted).must_equal "[server].[database]"
|
121
121
|
end
|
122
|
-
|
123
122
|
end
|
124
123
|
|
125
124
|
private
|
@@ -127,5 +126,4 @@ class UtilsTestSQLServer < ActiveRecord::TestCase
|
|
127
126
|
def extract_identifiers(name)
|
128
127
|
SQLServer::Utils.extract_identifiers(name)
|
129
128
|
end
|
130
|
-
|
131
129
|
end
|
@@ -1,48 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "cases/helper_sqlserver"
|
4
4
|
|
5
5
|
class SQLServerUuidTest < ActiveRecord::TestCase
|
6
|
-
|
7
6
|
let(:acceptable_uuid) { ActiveRecord::ConnectionAdapters::SQLServer::Type::Uuid::ACCEPTABLE_UUID }
|
8
7
|
|
9
|
-
it
|
10
|
-
_(SSTestUuid.columns_hash[
|
8
|
+
it "has a uuid primary key" do
|
9
|
+
_(SSTestUuid.columns_hash["id"].type).must_equal :uuid
|
11
10
|
assert SSTestUuid.primary_key
|
12
11
|
end
|
13
12
|
|
14
|
-
it
|
13
|
+
it "can create with a new pk" do
|
15
14
|
obj = SSTestUuid.create!
|
16
15
|
_(obj.id).must_be :present?
|
17
16
|
_(obj.id).must_match acceptable_uuid
|
18
17
|
end
|
19
18
|
|
20
|
-
it
|
19
|
+
it "can create other uuid column on reload" do
|
21
20
|
obj = SSTestUuid.create!
|
22
21
|
obj.reload
|
23
22
|
_(obj.other_uuid).must_match acceptable_uuid
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
27
|
-
_(connection.primary_key(SSTestUuid.table_name)).must_equal
|
25
|
+
it "can find uuid pk via connection" do
|
26
|
+
_(connection.primary_key(SSTestUuid.table_name)).must_equal "id"
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
29
|
+
it "changing column default" do
|
31
30
|
table_name = SSTestUuid.table_name
|
32
31
|
connection.add_column table_name, :thingy, :uuid, null: false, default: "NEWSEQUENTIALID()"
|
33
32
|
SSTestUuid.reset_column_information
|
34
|
-
column = SSTestUuid.columns_hash[
|
33
|
+
column = SSTestUuid.columns_hash["thingy"]
|
35
34
|
_(column.default_function).must_equal "newsequentialid()"
|
36
35
|
# Now to a different function.
|
37
36
|
connection.change_column table_name, :thingy, :uuid, null: false, default: "NEWID()"
|
38
37
|
SSTestUuid.reset_column_information
|
39
|
-
column = SSTestUuid.columns_hash[
|
38
|
+
column = SSTestUuid.columns_hash["thingy"]
|
40
39
|
_(column.default_function).must_equal "newid()"
|
41
40
|
end
|
42
41
|
|
43
|
-
it
|
42
|
+
it "can insert even when use_output_inserted to false " do
|
44
43
|
obj = with_use_output_inserted_disabled { SSTestUuid.create!(name: "😢") }
|
45
44
|
_(obj.id).must_be :nil?
|
46
45
|
end
|
47
|
-
|
48
46
|
end
|
data/test/debug.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# require 'rails/all'
|
4
|
-
require
|
4
|
+
require "tiny_tds"
|
5
5
|
|
6
6
|
c = TinyTds::Client.new(
|
7
|
-
host: ENV[
|
8
|
-
username:
|
9
|
-
password: ENV[
|
10
|
-
database:
|
7
|
+
host: ENV["CI_AZURE_HOST"],
|
8
|
+
username: "rails",
|
9
|
+
password: ENV["CI_AZURE_PASS"],
|
10
|
+
database: "activerecord_unittest",
|
11
11
|
azure: true,
|
12
|
-
tds_version:
|
12
|
+
tds_version: "7.3"
|
13
13
|
)
|
14
14
|
|
15
15
|
puts c.execute("SELECT 1 AS [one]").each
|
@@ -11,7 +11,7 @@ class CreateClientsAndChangeColumnNull < ActiveRecord::Migration[5.2]
|
|
11
11
|
end
|
12
12
|
|
13
13
|
change_column :clients, :name, :string, limit: 15
|
14
|
-
change_column :clients, :code, :string, default:
|
14
|
+
change_column :clients, :code, :string, default: "n/a"
|
15
15
|
change_column :clients, :value, :decimal, precision: 32, scale: 8
|
16
16
|
|
17
17
|
change_column_null :clients, :name, false
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class TableWillNeverBeCreated < ActiveRecord::Migration
|
4
|
-
|
5
4
|
def self.up
|
6
|
-
create_table(:sqlserver_trans_table1) {
|
7
|
-
create_table(:sqlserver_trans_table2) { raise(
|
5
|
+
create_table(:sqlserver_trans_table1) {}
|
6
|
+
create_table(:sqlserver_trans_table2) { raise("HELL") }
|
8
7
|
end
|
9
8
|
|
10
9
|
def self.down
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class SSTestEdgeSchema < ActiveRecord::Base
|
4
|
-
|
5
|
-
self.table_name = 'sst_edge_schemas'
|
4
|
+
self.table_name = "sst_edge_schemas"
|
6
5
|
|
7
6
|
def with_spaces
|
8
7
|
read_attribute :'with spaces'
|
@@ -11,5 +10,4 @@ class SSTestEdgeSchema < ActiveRecord::Base
|
|
11
10
|
def with_spaces=(value)
|
12
11
|
write_attribute :'with spaces', value
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class SSTestQuotedTable < ActiveRecord::Base
|
4
|
-
self.table_name =
|
4
|
+
self.table_name = "[sst_quoted-table]"
|
5
5
|
end
|
6
6
|
|
7
7
|
class SSTestQuotedTableUser < ActiveRecord::Base
|
8
|
-
self.table_name =
|
8
|
+
self.table_name = "[dbo].[sst_quoted-table]"
|
9
9
|
end
|