|
159 | 159 | @db[:fk].select_order_map([:a, :b, :c, :d, :e]).must_equal [[100, 10, 211, 212, 213]]
|
160 | 160 | @db.schema(:fk).map{|_,v| v[:generated]}.must_equal [false, false, true, true, true]
|
161 | 161 | end if DB.sqlite_version >= 33100
|
| 162 | + |
| 163 | + it "should support dropping a unique column" do |
| 164 | + @db.create_table!(:fk){Integer :a; Integer :b, :unique=>true} |
| 165 | + @db[:fk].insert(:a=>1, :b=>2) |
| 166 | + @db.alter_table(:fk){drop_column :b} |
| 167 | + @db[:fk].all.must_equal [{:a=>1}] |
| 168 | + end |
| 169 | + |
| 170 | + it "should support dropping a column with scalar index" do |
| 171 | + @db.create_table!(:fk){Integer :a; Integer :b, index: true} |
| 172 | + @db[:fk].insert(:a=>1, :b=>2) |
| 173 | + @db.alter_table(:fk){drop_column :b} |
| 174 | + @db[:fk].all.must_equal [{:a=>1}] |
| 175 | + end |
| 176 | + |
| 177 | + it "should support dropping a column that is part of a composite index" do |
| 178 | + @db.create_table!(:fk){Integer :a; Integer :b; index [:a, :b]} |
| 179 | + @db[:fk].insert(:a=>1, :b=>2) |
| 180 | + @db.alter_table(:fk){drop_column :b} |
| 181 | + @db[:fk].all.must_equal [{:a=>1}] |
| 182 | + end |
| 183 | + |
| 184 | + it "should support dropping a column that is not part of an index" do |
| 185 | + @db.create_table!(:fk){Integer :a, index: true; Integer :b} |
| 186 | + @db[:fk].insert(:a=>1, :b=>2) |
| 187 | + @db.alter_table(:fk){drop_column :b} |
| 188 | + @db[:fk].all.must_equal [{:a=>1}] |
| 189 | + end |
| 190 | + |
| 191 | + it "should support dropping a column for a table without an index" do |
| 192 | + @db.create_table!(:fk){Integer :a; Integer :b} |
| 193 | + @db[:fk].insert(:a=>1, :b=>2) |
| 194 | + @db.alter_table(:fk){drop_column :b} |
| 195 | + @db[:fk].all.must_equal [{:a=>1}] |
| 196 | + end |
162 | 197 | end
|
163 | 198 |
|
164 | 199 | describe "SQLite temporary views" do
|
|
0 commit comments