Permalink
Browse files

Fix Database#upcase_identifiers? if Sequel.upcase_identifiers = true

Note to self that using ||= with a boolean variable is a recipe for
problems.
  • Loading branch information...
jeremyevans committed Dec 4, 2008
1 parent 2e8753b commit 9c52f6218e88533756c4aea2da1b057e0dfba70d
Showing with 16 additions and 1 deletion.
  1. +2 −1 lib/sequel_core/database.rb
  2. +14 −0 spec/sequel_core/database_spec.rb
@@ -488,7 +488,8 @@ def typecast_value(column_type, value)
# Returns true if the database upcases identifiers.
def upcase_identifiers?
- @upcase_identifiers ||= @opts.include?(:upcase_identifiers) ? @opts[:upcase_identifiers] : (@@upcase_identifiers.nil? ? upcase_identifiers_default : @@upcase_identifiers)
+ return @upcase_identifiers unless @upcase_identifiers.nil?
+ @upcase_identifiers = @opts.include?(:upcase_identifiers) ? @opts[:upcase_identifiers] : (@@upcase_identifiers.nil? ? upcase_identifiers_default : @@upcase_identifiers)
end
# Returns the URI identifying the database.
@@ -55,10 +55,24 @@
end
specify "should respect the :upcase_identifiers option" do
+ Sequel.upcase_identifiers = false
+ db = Sequel::Database.new(:upcase_identifiers=>false)
+ db.upcase_identifiers?.should == false
+ db.upcase_identifiers = true
+ db.upcase_identifiers?.should == true
+ db = Sequel::Database.new(:upcase_identifiers=>true)
+ db.upcase_identifiers?.should == true
+ db.upcase_identifiers = false
+ db.upcase_identifiers?.should == false
+ Sequel.upcase_identifiers = true
db = Sequel::Database.new(:upcase_identifiers=>false)
db.upcase_identifiers?.should == false
+ db.upcase_identifiers = true
+ db.upcase_identifiers?.should == true
db = Sequel::Database.new(:upcase_identifiers=>true)
db.upcase_identifiers?.should == true
+ db.upcase_identifiers = false
+ db.upcase_identifiers?.should == false
end
specify "should use the default Sequel.quote_identifiers value" do

0 comments on commit 9c52f62

Please sign in to comment.