-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with default view value not being found because of case sen…
…sitivity (#1113)
- Loading branch information
1 parent
5b720b6
commit 0871ed8
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cases/helper_sqlserver" | ||
|
||
class ViewTestSQLServer < ActiveRecord::TestCase | ||
let(:connection) { ActiveRecord::Base.connection } | ||
|
||
describe 'view with default values' do | ||
before do | ||
connection.drop_table :view_casing_table rescue nil | ||
connection.create_table :view_casing_table, force: true do |t| | ||
t.boolean :Default_Falsey, null: false, default: false | ||
t.boolean :Default_Truthy, null: false, default: true | ||
end | ||
|
||
connection.execute("DROP VIEW IF EXISTS view_casing_table_view;") | ||
connection.execute("CREATE VIEW view_casing_table_view AS SELECT id AS id, default_falsey AS falsey, default_truthy AS truthy FROM view_casing_table") | ||
end | ||
|
||
it "default values are correct when column casing used in tables and views are different" do | ||
klass = Class.new(ActiveRecord::Base) do | ||
self.table_name = "view_casing_table_view" | ||
end | ||
|
||
obj = klass.new | ||
assert_equal false, obj.falsey | ||
assert_equal true, obj.truthy | ||
assert_equal 0, klass.count | ||
|
||
obj.save! | ||
assert_equal false, obj.falsey | ||
assert_equal true, obj.truthy | ||
assert_equal 1, klass.count | ||
end | ||
end | ||
end |