Skip to content

Commit

Permalink
Merge pull request #275 from Edouard-chin/ec-boolean-pragma-fix
Browse files Browse the repository at this point in the history
Fix `get_boolean_pragma` comparison:
  • Loading branch information
tenderlove committed Dec 27, 2022
2 parents cc3fb2e + 1d67e24 commit 998b764
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/sqlite3/pragmas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Pragmas

# Returns +true+ or +false+ depending on the value of the named pragma.
def get_boolean_pragma( name )
get_first_value( "PRAGMA #{name}" ) != "0"
get_first_value( "PRAGMA #{name}" ) != 0
end

# Sets the given pragma to the given boolean value. The value itself
Expand Down Expand Up @@ -260,7 +260,7 @@ def full_column_names
def full_column_names=( mode )
set_boolean_pragma "full_column_names", mode
end

def fullfsync
get_boolean_pragma "fullfsync"
end
Expand Down Expand Up @@ -356,7 +356,7 @@ def page_size=( size )
def parser_trace=( mode )
set_boolean_pragma "parser_trace", mode
end

def query_only
get_boolean_pragma "query_only"
end
Expand Down
22 changes: 22 additions & 0 deletions test/test_pragmas.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'helper'

module SQLite3
class TestPragmas < SQLite3::TestCase
def setup
super
@db = SQLite3::Database.new(":memory:")
end

def test_get_boolean_pragma
refute(@db.get_boolean_pragma("read_uncommitted"))
end

def test_set_boolean_pragma
@db.set_boolean_pragma("read_uncommitted", 1)

assert(@db.get_boolean_pragma("read_uncommitted"))
ensure
@db.set_boolean_pragma("read_uncommitted", 0)
end
end
end

0 comments on commit 998b764

Please sign in to comment.