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