@@ -60,11 +60,20 @@ def get_enum_pragma(name)
60
60
# have duplicate values. See #synchronous, #default_synchronous,
61
61
# #temp_store, and #default_temp_store for usage examples.
62
62
def set_enum_pragma ( name , mode , enums )
63
- match = enums . find { |p | p . find { |i | i . to_s . downcase == mode . to_s . downcase } }
63
+ match = if enums . is_a? ( Array )
64
+ # maybe deprecate this?
65
+ enums . find { |p | p . find { |i | i . to_s . downcase == mode . to_s . downcase } }
66
+ elsif mode . is_a? ( String )
67
+ enums . fetch ( mode . downcase )
68
+ else
69
+ mode
70
+ end
71
+
64
72
unless match
65
73
raise SQLite3 ::Exception , "unrecognized #{ name } #{ mode . inspect } "
66
74
end
67
- execute ( "PRAGMA #{ name } ='#{ match . first . upcase } '" )
75
+
76
+ execute ( "PRAGMA #{ name } ='#{ match } '" )
68
77
end
69
78
70
79
# Returns the value of the given pragma as an integer.
@@ -79,26 +88,57 @@ def set_int_pragma(name, value)
79
88
end
80
89
81
90
# The enumeration of valid synchronous modes.
82
- SYNCHRONOUS_MODES = [ [ "full" , 2 ] , [ "normal" , 1 ] , [ "off" , 0 ] ] . map ( &:freeze ) . freeze
91
+ SYNCHRONOUS_MODES = {
92
+ "full" => 2 ,
93
+ "normal" => 1 ,
94
+ "off" => 0
95
+ } . freeze
83
96
84
97
# The enumeration of valid temp store modes.
85
- TEMP_STORE_MODES = [ [ "default" , 0 ] , [ "file" , 1 ] , [ "memory" , 2 ] ] . map ( &:freeze ) . freeze
98
+ TEMP_STORE_MODES = {
99
+ "default" => 0 ,
100
+ "file" => 1 ,
101
+ "memory" => 2
102
+ } . freeze
86
103
87
104
# The enumeration of valid auto vacuum modes.
88
- AUTO_VACUUM_MODES = [ [ "none" , 0 ] , [ "full" , 1 ] , [ "incremental" , 2 ] ] . map ( &:freeze ) . freeze
105
+ AUTO_VACUUM_MODES = {
106
+ "none" => 0 ,
107
+ "full" => 1 ,
108
+ "incremental" => 2
109
+ } . freeze
89
110
90
111
# The list of valid journaling modes.
91
- JOURNAL_MODES = [ [ "delete" ] , [ "truncate" ] , [ "persist" ] , [ "memory" ] ,
92
- [ "wal" ] , [ "off" ] ] . map ( &:freeze ) . freeze
112
+ JOURNAL_MODES = {
113
+ "delete" => "delete" ,
114
+ "truncate" => "truncate" ,
115
+ "persist" => "persist" ,
116
+ "memory" => "memory" ,
117
+ "wal" => "wal" ,
118
+ "off" => "off"
119
+ } . freeze
93
120
94
121
# The list of valid locking modes.
95
- LOCKING_MODES = [ [ "normal" ] , [ "exclusive" ] ] . map ( &:freeze ) . freeze
122
+ LOCKING_MODES = {
123
+ "normal" => "normal" ,
124
+ "exclusive" => "exclusive"
125
+ } . freeze
96
126
97
127
# The list of valid encodings.
98
- ENCODINGS = [ [ "utf-8" ] , [ "utf-16" ] , [ "utf-16le" ] , [ "utf-16be" ] ] . map ( &:freeze ) . freeze
128
+ ENCODINGS = {
129
+ "utf-8" => "utf-8" ,
130
+ "utf-16" => "utf-16" ,
131
+ "utf-16le" => "utf-16le" ,
132
+ "utf-16be" => "utf-16be"
133
+ } . freeze
99
134
100
135
# The list of valid WAL checkpoints.
101
- WAL_CHECKPOINTS = [ [ "passive" ] , [ "full" ] , [ "restart" ] , [ "truncate" ] ] . map ( &:freeze ) . freeze
136
+ WAL_CHECKPOINTS = {
137
+ "passive" => "passive" ,
138
+ "full" => "full" ,
139
+ "restart" => "restart" ,
140
+ "truncate" => "truncate"
141
+ } . freeze
102
142
103
143
def application_id
104
144
get_int_pragma "application_id"
0 commit comments