Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_boolean_pragma comparison: #275

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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