|
4 | 4 |
|
5 | 5 | class ActiveSchemaTestSQLServer < ActiveRecord::TestCase
|
6 | 6 | describe "indexes" do
|
7 |
| - |
8 | 7 | before do
|
9 | 8 | connection.create_table :schema_test_table, force: true, id: false do |t|
|
10 | 9 | t.column :foo, :string, limit: 100
|
@@ -54,13 +53,45 @@ class ActiveSchemaTestSQLServer < ActiveRecord::TestCase
|
54 | 53 | end
|
55 | 54 | end
|
56 | 55 |
|
57 |
| - it "create column with NOT NULL and COLLATE" do |
58 |
| - assert_nothing_raised do |
59 |
| - connection.create_table :not_null_with_collation_table, force: true, id: false do |t| |
60 |
| - t.text :not_null_text_with_collation, null: false, collation: "Latin1_General_CS_AS" |
| 56 | + describe 'collation' do |
| 57 | + it "create column with NOT NULL and COLLATE" do |
| 58 | + assert_nothing_raised do |
| 59 | + connection.create_table :not_null_with_collation_table, force: true, id: false do |t| |
| 60 | + t.text :not_null_text_with_collation, null: false, collation: "Latin1_General_CS_AS" |
| 61 | + end |
| 62 | + end |
| 63 | + ensure |
| 64 | + connection.drop_table :not_null_with_collation_table rescue nil |
| 65 | + end |
| 66 | + end |
| 67 | + |
| 68 | + describe 'datetimeoffset precision' do |
| 69 | + it 'valid precisions are correct' do |
| 70 | + assert_nothing_raised do |
| 71 | + connection.create_table :datetimeoffset_precisions do |t| |
| 72 | + t.datetimeoffset :precision_default |
| 73 | + t.datetimeoffset :precision_5, precision: 5 |
| 74 | + t.datetimeoffset :precision_7, precision: 7 |
| 75 | + end |
| 76 | + end |
| 77 | + |
| 78 | + columns = connection.columns("datetimeoffset_precisions") |
| 79 | + |
| 80 | + assert_equal columns.find { |column| column.name == "precision_default" }.precision, 7 |
| 81 | + assert_equal columns.find { |column| column.name == "precision_5" }.precision, 5 |
| 82 | + assert_equal columns.find { |column| column.name == "precision_7" }.precision, 7 |
| 83 | + ensure |
| 84 | + connection.drop_table :datetimeoffset_precisions rescue nil |
| 85 | + end |
| 86 | + |
| 87 | + it 'invalid precision raises exception' do |
| 88 | + assert_raise(ActiveRecord::ActiveRecordError) do |
| 89 | + connection.create_table :datetimeoffset_precisions do |t| |
| 90 | + t.datetimeoffset :precision_8, precision: 8 |
| 91 | + end |
61 | 92 | end
|
| 93 | + ensure |
| 94 | + connection.drop_table :datetimeoffset_precisions rescue nil |
62 | 95 | end
|
63 |
| - ensure |
64 |
| - connection.drop_table :not_null_with_collation_table rescue nil |
65 | 96 | end
|
66 | 97 | end
|
0 commit comments