Skip to content

Commit e734b9f

Browse files
committed
Freeze strings and constants in pragmas
I'm looking in earnest at Ractor support in Rails. We need some of these constants that SQLite3 uses to be frozen so that when they're accessed via Ractors we don't get an error. This commit just adds frozen string literals, and freezes some constants
1 parent 2724f7b commit e734b9f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/sqlite3/pragmas.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "sqlite3/errors"
24

35
module SQLite3
@@ -77,26 +79,26 @@ def set_int_pragma(name, value)
7779
end
7880

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

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

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

8890
# The list of valid journaling modes.
8991
JOURNAL_MODES = [["delete"], ["truncate"], ["persist"], ["memory"],
90-
["wal"], ["off"]]
92+
["wal"], ["off"]].map(&:freeze).freeze
9193

9294
# The list of valid locking modes.
93-
LOCKING_MODES = [["normal"], ["exclusive"]]
95+
LOCKING_MODES = [["normal"], ["exclusive"]].map(&:freeze).freeze
9496

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

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

101103
def application_id
102104
get_int_pragma "application_id"

0 commit comments

Comments
 (0)