Skip to content

Commit

Permalink
Merge pull request #620 from tenderlove/freeze
Browse files Browse the repository at this point in the history
Freeze strings and constants in pragmas
  • Loading branch information
flavorjones authored Mar 6, 2025
2 parents 2724f7b + e734b9f commit d7e98cd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/sqlite3/pragmas.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "sqlite3/errors"

module SQLite3
Expand Down Expand Up @@ -77,26 +79,26 @@ def set_int_pragma(name, value)
end

# The enumeration of valid synchronous modes.
SYNCHRONOUS_MODES = [["full", 2], ["normal", 1], ["off", 0]]
SYNCHRONOUS_MODES = [["full", 2], ["normal", 1], ["off", 0]].map(&:freeze).freeze

# The enumeration of valid temp store modes.
TEMP_STORE_MODES = [["default", 0], ["file", 1], ["memory", 2]]
TEMP_STORE_MODES = [["default", 0], ["file", 1], ["memory", 2]].map(&:freeze).freeze

# The enumeration of valid auto vacuum modes.
AUTO_VACUUM_MODES = [["none", 0], ["full", 1], ["incremental", 2]]
AUTO_VACUUM_MODES = [["none", 0], ["full", 1], ["incremental", 2]].map(&:freeze).freeze

# The list of valid journaling modes.
JOURNAL_MODES = [["delete"], ["truncate"], ["persist"], ["memory"],
["wal"], ["off"]]
["wal"], ["off"]].map(&:freeze).freeze

# The list of valid locking modes.
LOCKING_MODES = [["normal"], ["exclusive"]]
LOCKING_MODES = [["normal"], ["exclusive"]].map(&:freeze).freeze

# The list of valid encodings.
ENCODINGS = [["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be"]]
ENCODINGS = [["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be"]].map(&:freeze).freeze

# The list of valid WAL checkpoints.
WAL_CHECKPOINTS = [["passive"], ["full"], ["restart"], ["truncate"]]
WAL_CHECKPOINTS = [["passive"], ["full"], ["restart"], ["truncate"]].map(&:freeze).freeze

def application_id
get_int_pragma "application_id"
Expand Down

0 comments on commit d7e98cd

Please sign in to comment.