sqlite3 1.7.2-x86_64-darwin → 2.0.0-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +160 -1
  3. data/CONTRIBUTING.md +23 -1
  4. data/FAQ.md +0 -43
  5. data/INSTALLATION.md +13 -5
  6. data/LICENSE +18 -22
  7. data/README.md +75 -4
  8. data/dependencies.yml +10 -11
  9. data/ext/sqlite3/aggregator.c +142 -145
  10. data/ext/sqlite3/aggregator.h +2 -4
  11. data/ext/sqlite3/backup.c +74 -65
  12. data/ext/sqlite3/backup.h +2 -2
  13. data/ext/sqlite3/database.c +535 -482
  14. data/ext/sqlite3/database.h +7 -4
  15. data/ext/sqlite3/exception.c +111 -92
  16. data/ext/sqlite3/exception.h +3 -1
  17. data/ext/sqlite3/extconf.rb +21 -22
  18. data/ext/sqlite3/sqlite3.c +159 -115
  19. data/ext/sqlite3/sqlite3_ruby.h +2 -2
  20. data/ext/sqlite3/statement.c +516 -300
  21. data/ext/sqlite3/statement.h +3 -3
  22. data/ext/sqlite3/timespec.h +20 -0
  23. data/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
  24. data/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
  25. data/lib/sqlite3/3.2/sqlite3_native.bundle +0 -0
  26. data/lib/sqlite3/3.3/sqlite3_native.bundle +0 -0
  27. data/lib/sqlite3/constants.rb +171 -47
  28. data/lib/sqlite3/database.rb +105 -165
  29. data/lib/sqlite3/errors.rb +26 -1
  30. data/lib/sqlite3/pragmas.rb +126 -136
  31. data/lib/sqlite3/resultset.rb +14 -97
  32. data/lib/sqlite3/statement.rb +58 -13
  33. data/lib/sqlite3/value.rb +17 -20
  34. data/lib/sqlite3/version.rb +1 -21
  35. data/lib/sqlite3.rb +6 -4
  36. metadata +3 -28
  37. data/API_CHANGES.md +0 -49
  38. data/ChangeLog.cvs +0 -88
  39. data/Gemfile +0 -10
  40. data/LICENSE-DEPENDENCIES +0 -20
  41. data/lib/sqlite3/translator.rb +0 -117
  42. data/test/helper.rb +0 -27
  43. data/test/test_backup.rb +0 -33
  44. data/test/test_collation.rb +0 -82
  45. data/test/test_database.rb +0 -668
  46. data/test/test_database_flags.rb +0 -95
  47. data/test/test_database_readonly.rb +0 -36
  48. data/test/test_database_readwrite.rb +0 -41
  49. data/test/test_deprecated.rb +0 -49
  50. data/test/test_encoding.rb +0 -165
  51. data/test/test_integration.rb +0 -507
  52. data/test/test_integration_aggregate.rb +0 -336
  53. data/test/test_integration_open_close.rb +0 -30
  54. data/test/test_integration_pending.rb +0 -115
  55. data/test/test_integration_resultset.rb +0 -142
  56. data/test/test_integration_statement.rb +0 -194
  57. data/test/test_pragmas.rb +0 -22
  58. data/test/test_result_set.rb +0 -47
  59. data/test/test_sqlite3.rb +0 -30
  60. data/test/test_statement.rb +0 -290
  61. data/test/test_statement_execute.rb +0 -39
@@ -1,59 +1,55 @@
1
- require 'sqlite3/errors'
1
+ require "sqlite3/errors"
2
2
 
3
3
  module SQLite3
4
-
5
4
  # This module is intended for inclusion solely by the Database class. It
6
5
  # defines convenience methods for the various pragmas supported by SQLite3.
7
6
  #
8
7
  # For a detailed description of these pragmas, see the SQLite3 documentation
9
8
  # at http://sqlite.org/pragma.html.
10
9
  module Pragmas
11
-
12
10
  # Returns +true+ or +false+ depending on the value of the named pragma.
13
- def get_boolean_pragma( name )
14
- get_first_value( "PRAGMA #{name}" ) != 0
11
+ def get_boolean_pragma(name)
12
+ get_first_value("PRAGMA #{name}") != 0
15
13
  end
16
14
 
17
15
  # Sets the given pragma to the given boolean value. The value itself
18
16
  # may be +true+ or +false+, or any other commonly used string or
19
17
  # integer that represents truth.
20
- def set_boolean_pragma( name, mode )
18
+ def set_boolean_pragma(name, mode)
21
19
  case mode
22
20
  when String
23
- case mode.downcase
24
- when "on", "yes", "true", "y", "t"; mode = "'ON'"
25
- when "off", "no", "false", "n", "f"; mode = "'OFF'"
26
- else
27
- raise Exception,
28
- "unrecognized pragma parameter #{mode.inspect}"
29
- end
21
+ case mode.downcase
22
+ when "on", "yes", "true", "y", "t" then mode = "'ON'"
23
+ when "off", "no", "false", "n", "f" then mode = "'OFF'"
24
+ else
25
+ raise SQLite3::Exception, "unrecognized pragma parameter #{mode.inspect}"
26
+ end
30
27
  when true, 1
31
- mode = "ON"
28
+ mode = "ON"
32
29
  when false, 0, nil
33
- mode = "OFF"
30
+ mode = "OFF"
34
31
  else
35
- raise Exception,
36
- "unrecognized pragma parameter #{mode.inspect}"
32
+ raise SQLite3::Exception, "unrecognized pragma parameter #{mode.inspect}"
37
33
  end
38
34
 
39
- execute( "PRAGMA #{name}=#{mode}" )
35
+ execute("PRAGMA #{name}=#{mode}")
40
36
  end
41
37
 
42
38
  # Requests the given pragma (and parameters), and if the block is given,
43
39
  # each row of the result set will be yielded to it. Otherwise, the results
44
40
  # are returned as an array.
45
- def get_query_pragma( name, *params, &block ) # :yields: row
41
+ def get_query_pragma(name, *params, &block) # :yields: row
46
42
  if params.empty?
47
- execute( "PRAGMA #{name}", &block )
43
+ execute("PRAGMA #{name}", &block)
48
44
  else
49
45
  args = "'" + params.join("','") + "'"
50
- execute( "PRAGMA #{name}( #{args} )", &block )
46
+ execute("PRAGMA #{name}( #{args} )", &block)
51
47
  end
52
48
  end
53
49
 
54
50
  # Return the value of the given pragma.
55
- def get_enum_pragma( name )
56
- get_first_value( "PRAGMA #{name}" )
51
+ def get_enum_pragma(name)
52
+ get_first_value("PRAGMA #{name}")
57
53
  end
58
54
 
59
55
  # Set the value of the given pragma to +mode+. The +mode+ parameter must
@@ -61,51 +57,52 @@ module SQLite3
61
57
  # the array is another array comprised of elements in the enumeration that
62
58
  # have duplicate values. See #synchronous, #default_synchronous,
63
59
  # #temp_store, and #default_temp_store for usage examples.
64
- def set_enum_pragma( name, mode, enums )
60
+ def set_enum_pragma(name, mode, enums)
65
61
  match = enums.find { |p| p.find { |i| i.to_s.downcase == mode.to_s.downcase } }
66
- raise Exception,
67
- "unrecognized #{name} #{mode.inspect}" unless match
68
- execute( "PRAGMA #{name}='#{match.first.upcase}'" )
62
+ unless match
63
+ raise SQLite3::Exception, "unrecognized #{name} #{mode.inspect}"
64
+ end
65
+ execute("PRAGMA #{name}='#{match.first.upcase}'")
69
66
  end
70
67
 
71
68
  # Returns the value of the given pragma as an integer.
72
- def get_int_pragma( name )
73
- get_first_value( "PRAGMA #{name}" ).to_i
69
+ def get_int_pragma(name)
70
+ get_first_value("PRAGMA #{name}").to_i
74
71
  end
75
72
 
76
73
  # Set the value of the given pragma to the integer value of the +value+
77
74
  # parameter.
78
- def set_int_pragma( name, value )
79
- execute( "PRAGMA #{name}=#{value.to_i}" )
75
+ def set_int_pragma(name, value)
76
+ execute("PRAGMA #{name}=#{value.to_i}")
80
77
  end
81
78
 
82
79
  # The enumeration of valid synchronous modes.
83
- SYNCHRONOUS_MODES = [ [ 'full', 2 ], [ 'normal', 1 ], [ 'off', 0 ] ]
80
+ SYNCHRONOUS_MODES = [["full", 2], ["normal", 1], ["off", 0]]
84
81
 
85
82
  # The enumeration of valid temp store modes.
86
- TEMP_STORE_MODES = [ [ 'default', 0 ], [ 'file', 1 ], [ 'memory', 2 ] ]
83
+ TEMP_STORE_MODES = [["default", 0], ["file", 1], ["memory", 2]]
87
84
 
88
85
  # The enumeration of valid auto vacuum modes.
89
- AUTO_VACUUM_MODES = [ [ 'none', 0 ], [ 'full', 1 ], [ 'incremental', 2 ] ]
86
+ AUTO_VACUUM_MODES = [["none", 0], ["full", 1], ["incremental", 2]]
90
87
 
91
88
  # The list of valid journaling modes.
92
- JOURNAL_MODES = [ [ 'delete' ], [ 'truncate' ], [ 'persist' ], [ 'memory' ],
93
- [ 'wal' ], [ 'off' ] ]
89
+ JOURNAL_MODES = [["delete"], ["truncate"], ["persist"], ["memory"],
90
+ ["wal"], ["off"]]
94
91
 
95
92
  # The list of valid locking modes.
96
- LOCKING_MODES = [ [ 'normal' ], [ 'exclusive' ] ]
93
+ LOCKING_MODES = [["normal"], ["exclusive"]]
97
94
 
98
95
  # The list of valid encodings.
99
- ENCODINGS = [ [ 'utf-8' ], [ 'utf-16' ], [ 'utf-16le' ], [ 'utf-16be ' ] ]
96
+ ENCODINGS = [["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be "]]
100
97
 
101
98
  # The list of valid WAL checkpoints.
102
- WAL_CHECKPOINTS = [ [ 'passive' ], [ 'full' ], [ 'restart' ], [ 'truncate' ] ]
99
+ WAL_CHECKPOINTS = [["passive"], ["full"], ["restart"], ["truncate"]]
103
100
 
104
101
  def application_id
105
102
  get_int_pragma "application_id"
106
103
  end
107
104
 
108
- def application_id=( integer )
105
+ def application_id=(integer)
109
106
  set_int_pragma "application_id", integer
110
107
  end
111
108
 
@@ -113,7 +110,7 @@ module SQLite3
113
110
  get_enum_pragma "auto_vacuum"
114
111
  end
115
112
 
116
- def auto_vacuum=( mode )
113
+ def auto_vacuum=(mode)
117
114
  set_enum_pragma "auto_vacuum", mode, AUTO_VACUUM_MODES
118
115
  end
119
116
 
@@ -121,7 +118,7 @@ module SQLite3
121
118
  get_boolean_pragma "automatic_index"
122
119
  end
123
120
 
124
- def automatic_index=( mode )
121
+ def automatic_index=(mode)
125
122
  set_boolean_pragma "automatic_index", mode
126
123
  end
127
124
 
@@ -129,7 +126,7 @@ module SQLite3
129
126
  get_int_pragma "busy_timeout"
130
127
  end
131
128
 
132
- def busy_timeout=( milliseconds )
129
+ def busy_timeout=(milliseconds)
133
130
  set_int_pragma "busy_timeout", milliseconds
134
131
  end
135
132
 
@@ -137,7 +134,7 @@ module SQLite3
137
134
  get_int_pragma "cache_size"
138
135
  end
139
136
 
140
- def cache_size=( size )
137
+ def cache_size=(size)
141
138
  set_int_pragma "cache_size", size
142
139
  end
143
140
 
@@ -145,11 +142,11 @@ module SQLite3
145
142
  get_boolean_pragma "cache_spill"
146
143
  end
147
144
 
148
- def cache_spill=( mode )
145
+ def cache_spill=(mode)
149
146
  set_boolean_pragma "cache_spill", mode
150
147
  end
151
148
 
152
- def case_sensitive_like=( mode )
149
+ def case_sensitive_like=(mode)
153
150
  set_boolean_pragma "case_sensitive_like", mode
154
151
  end
155
152
 
@@ -157,7 +154,7 @@ module SQLite3
157
154
  get_boolean_pragma "cell_size_check"
158
155
  end
159
156
 
160
- def cell_size_check=( mode )
157
+ def cell_size_check=(mode)
161
158
  set_boolean_pragma "cell_size_check", mode
162
159
  end
163
160
 
@@ -165,15 +162,15 @@ module SQLite3
165
162
  get_boolean_pragma "checkpoint_fullfsync"
166
163
  end
167
164
 
168
- def checkpoint_fullfsync=( mode )
165
+ def checkpoint_fullfsync=(mode)
169
166
  set_boolean_pragma "checkpoint_fullfsync", mode
170
167
  end
171
168
 
172
- def collation_list( &block ) # :yields: row
169
+ def collation_list(&block) # :yields: row
173
170
  get_query_pragma "collation_list", &block
174
171
  end
175
172
 
176
- def compile_options( &block ) # :yields: row
173
+ def compile_options(&block) # :yields: row
177
174
  get_query_pragma "compile_options", &block
178
175
  end
179
176
 
@@ -181,7 +178,7 @@ module SQLite3
181
178
  get_boolean_pragma "count_changes"
182
179
  end
183
180
 
184
- def count_changes=( mode )
181
+ def count_changes=(mode)
185
182
  set_boolean_pragma "count_changes", mode
186
183
  end
187
184
 
@@ -189,7 +186,7 @@ module SQLite3
189
186
  get_int_pragma "data_version"
190
187
  end
191
188
 
192
- def database_list( &block ) # :yields: row
189
+ def database_list(&block) # :yields: row
193
190
  get_query_pragma "database_list", &block
194
191
  end
195
192
 
@@ -197,7 +194,7 @@ module SQLite3
197
194
  get_int_pragma "default_cache_size"
198
195
  end
199
196
 
200
- def default_cache_size=( size )
197
+ def default_cache_size=(size)
201
198
  set_int_pragma "default_cache_size", size
202
199
  end
203
200
 
@@ -205,7 +202,7 @@ module SQLite3
205
202
  get_enum_pragma "default_synchronous"
206
203
  end
207
204
 
208
- def default_synchronous=( mode )
205
+ def default_synchronous=(mode)
209
206
  set_enum_pragma "default_synchronous", mode, SYNCHRONOUS_MODES
210
207
  end
211
208
 
@@ -213,7 +210,7 @@ module SQLite3
213
210
  get_enum_pragma "default_temp_store"
214
211
  end
215
212
 
216
- def default_temp_store=( mode )
213
+ def default_temp_store=(mode)
217
214
  set_enum_pragma "default_temp_store", mode, TEMP_STORE_MODES
218
215
  end
219
216
 
@@ -221,7 +218,7 @@ module SQLite3
221
218
  get_boolean_pragma "defer_foreign_keys"
222
219
  end
223
220
 
224
- def defer_foreign_keys=( mode )
221
+ def defer_foreign_keys=(mode)
225
222
  set_boolean_pragma "defer_foreign_keys", mode
226
223
  end
227
224
 
@@ -229,15 +226,15 @@ module SQLite3
229
226
  get_enum_pragma "encoding"
230
227
  end
231
228
 
232
- def encoding=( mode )
229
+ def encoding=(mode)
233
230
  set_enum_pragma "encoding", mode, ENCODINGS
234
231
  end
235
232
 
236
- def foreign_key_check( *table, &block ) # :yields: row
233
+ def foreign_key_check(*table, &block) # :yields: row
237
234
  get_query_pragma "foreign_key_check", *table, &block
238
235
  end
239
236
 
240
- def foreign_key_list( table, &block ) # :yields: row
237
+ def foreign_key_list(table, &block) # :yields: row
241
238
  get_query_pragma "foreign_key_list", table, &block
242
239
  end
243
240
 
@@ -245,7 +242,7 @@ module SQLite3
245
242
  get_boolean_pragma "foreign_keys"
246
243
  end
247
244
 
248
- def foreign_keys=( mode )
245
+ def foreign_keys=(mode)
249
246
  set_boolean_pragma "foreign_keys", mode
250
247
  end
251
248
 
@@ -257,7 +254,7 @@ module SQLite3
257
254
  get_boolean_pragma "full_column_names"
258
255
  end
259
256
 
260
- def full_column_names=( mode )
257
+ def full_column_names=(mode)
261
258
  set_boolean_pragma "full_column_names", mode
262
259
  end
263
260
 
@@ -265,31 +262,31 @@ module SQLite3
265
262
  get_boolean_pragma "fullfsync"
266
263
  end
267
264
 
268
- def fullfsync=( mode )
265
+ def fullfsync=(mode)
269
266
  set_boolean_pragma "fullfsync", mode
270
267
  end
271
268
 
272
- def ignore_check_constraints=( mode )
269
+ def ignore_check_constraints=(mode)
273
270
  set_boolean_pragma "ignore_check_constraints", mode
274
271
  end
275
272
 
276
- def incremental_vacuum( pages, &block ) # :yields: row
273
+ def incremental_vacuum(pages, &block) # :yields: row
277
274
  get_query_pragma "incremental_vacuum", pages, &block
278
275
  end
279
276
 
280
- def index_info( index, &block ) # :yields: row
277
+ def index_info(index, &block) # :yields: row
281
278
  get_query_pragma "index_info", index, &block
282
279
  end
283
280
 
284
- def index_list( table, &block ) # :yields: row
281
+ def index_list(table, &block) # :yields: row
285
282
  get_query_pragma "index_list", table, &block
286
283
  end
287
284
 
288
- def index_xinfo( index, &block ) # :yields: row
285
+ def index_xinfo(index, &block) # :yields: row
289
286
  get_query_pragma "index_xinfo", index, &block
290
287
  end
291
288
 
292
- def integrity_check( *num_errors, &block ) # :yields: row
289
+ def integrity_check(*num_errors, &block) # :yields: row
293
290
  get_query_pragma "integrity_check", *num_errors, &block
294
291
  end
295
292
 
@@ -297,7 +294,7 @@ module SQLite3
297
294
  get_enum_pragma "journal_mode"
298
295
  end
299
296
 
300
- def journal_mode=( mode )
297
+ def journal_mode=(mode)
301
298
  set_enum_pragma "journal_mode", mode, JOURNAL_MODES
302
299
  end
303
300
 
@@ -305,7 +302,7 @@ module SQLite3
305
302
  get_int_pragma "journal_size_limit"
306
303
  end
307
304
 
308
- def journal_size_limit=( size )
305
+ def journal_size_limit=(size)
309
306
  set_int_pragma "journal_size_limit", size
310
307
  end
311
308
 
@@ -313,7 +310,7 @@ module SQLite3
313
310
  get_boolean_pragma "legacy_file_format"
314
311
  end
315
312
 
316
- def legacy_file_format=( mode )
313
+ def legacy_file_format=(mode)
317
314
  set_boolean_pragma "legacy_file_format", mode
318
315
  end
319
316
 
@@ -321,7 +318,7 @@ module SQLite3
321
318
  get_enum_pragma "locking_mode"
322
319
  end
323
320
 
324
- def locking_mode=( mode )
321
+ def locking_mode=(mode)
325
322
  set_enum_pragma "locking_mode", mode, LOCKING_MODES
326
323
  end
327
324
 
@@ -329,7 +326,7 @@ module SQLite3
329
326
  get_int_pragma "max_page_count"
330
327
  end
331
328
 
332
- def max_page_count=( size )
329
+ def max_page_count=(size)
333
330
  set_int_pragma "max_page_count", size
334
331
  end
335
332
 
@@ -337,7 +334,7 @@ module SQLite3
337
334
  get_int_pragma "mmap_size"
338
335
  end
339
336
 
340
- def mmap_size=( size )
337
+ def mmap_size=(size)
341
338
  set_int_pragma "mmap_size", size
342
339
  end
343
340
 
@@ -349,11 +346,11 @@ module SQLite3
349
346
  get_int_pragma "page_size"
350
347
  end
351
348
 
352
- def page_size=( size )
349
+ def page_size=(size)
353
350
  set_int_pragma "page_size", size
354
351
  end
355
352
 
356
- def parser_trace=( mode )
353
+ def parser_trace=(mode)
357
354
  set_boolean_pragma "parser_trace", mode
358
355
  end
359
356
 
@@ -361,11 +358,11 @@ module SQLite3
361
358
  get_boolean_pragma "query_only"
362
359
  end
363
360
 
364
- def query_only=( mode )
361
+ def query_only=(mode)
365
362
  set_boolean_pragma "query_only", mode
366
363
  end
367
364
 
368
- def quick_check( *num_errors, &block ) # :yields: row
365
+ def quick_check(*num_errors, &block) # :yields: row
369
366
  get_query_pragma "quick_check", *num_errors, &block
370
367
  end
371
368
 
@@ -373,7 +370,7 @@ module SQLite3
373
370
  get_boolean_pragma "read_uncommitted"
374
371
  end
375
372
 
376
- def read_uncommitted=( mode )
373
+ def read_uncommitted=(mode)
377
374
  set_boolean_pragma "read_uncommitted", mode
378
375
  end
379
376
 
@@ -381,7 +378,7 @@ module SQLite3
381
378
  get_boolean_pragma "recursive_triggers"
382
379
  end
383
380
 
384
- def recursive_triggers=( mode )
381
+ def recursive_triggers=(mode)
385
382
  set_boolean_pragma "recursive_triggers", mode
386
383
  end
387
384
 
@@ -389,7 +386,7 @@ module SQLite3
389
386
  get_boolean_pragma "reverse_unordered_selects"
390
387
  end
391
388
 
392
- def reverse_unordered_selects=( mode )
389
+ def reverse_unordered_selects=(mode)
393
390
  set_boolean_pragma "reverse_unordered_selects", mode
394
391
  end
395
392
 
@@ -397,7 +394,7 @@ module SQLite3
397
394
  get_int_pragma "schema_cookie"
398
395
  end
399
396
 
400
- def schema_cookie=( cookie )
397
+ def schema_cookie=(cookie)
401
398
  set_int_pragma "schema_cookie", cookie
402
399
  end
403
400
 
@@ -405,7 +402,7 @@ module SQLite3
405
402
  get_int_pragma "schema_version"
406
403
  end
407
404
 
408
- def schema_version=( version )
405
+ def schema_version=(version)
409
406
  set_int_pragma "schema_version", version
410
407
  end
411
408
 
@@ -413,7 +410,7 @@ module SQLite3
413
410
  get_boolean_pragma "secure_delete"
414
411
  end
415
412
 
416
- def secure_delete=( mode )
413
+ def secure_delete=(mode)
417
414
  set_boolean_pragma "secure_delete", mode
418
415
  end
419
416
 
@@ -421,23 +418,23 @@ module SQLite3
421
418
  get_boolean_pragma "short_column_names"
422
419
  end
423
420
 
424
- def short_column_names=( mode )
421
+ def short_column_names=(mode)
425
422
  set_boolean_pragma "short_column_names", mode
426
423
  end
427
424
 
428
425
  def shrink_memory
429
- execute( "PRAGMA shrink_memory" )
426
+ execute("PRAGMA shrink_memory")
430
427
  end
431
428
 
432
429
  def soft_heap_limit
433
430
  get_int_pragma "soft_heap_limit"
434
431
  end
435
432
 
436
- def soft_heap_limit=( mode )
433
+ def soft_heap_limit=(mode)
437
434
  set_int_pragma "soft_heap_limit", mode
438
435
  end
439
436
 
440
- def stats( &block ) # :yields: row
437
+ def stats(&block) # :yields: row
441
438
  get_query_pragma "stats", &block
442
439
  end
443
440
 
@@ -445,7 +442,7 @@ module SQLite3
445
442
  get_enum_pragma "synchronous"
446
443
  end
447
444
 
448
- def synchronous=( mode )
445
+ def synchronous=(mode)
449
446
  set_enum_pragma "synchronous", mode, SYNCHRONOUS_MODES
450
447
  end
451
448
 
@@ -453,7 +450,7 @@ module SQLite3
453
450
  get_enum_pragma "temp_store"
454
451
  end
455
452
 
456
- def temp_store=( mode )
453
+ def temp_store=(mode)
457
454
  set_enum_pragma "temp_store", mode, TEMP_STORE_MODES
458
455
  end
459
456
 
@@ -461,7 +458,7 @@ module SQLite3
461
458
  get_int_pragma "threads"
462
459
  end
463
460
 
464
- def threads=( count )
461
+ def threads=(count)
465
462
  set_int_pragma "threads", count
466
463
  end
467
464
 
@@ -469,7 +466,7 @@ module SQLite3
469
466
  get_int_pragma "user_cookie"
470
467
  end
471
468
 
472
- def user_cookie=( cookie )
469
+ def user_cookie=(cookie)
473
470
  set_int_pragma "user_cookie", cookie
474
471
  end
475
472
 
@@ -477,19 +474,19 @@ module SQLite3
477
474
  get_int_pragma "user_version"
478
475
  end
479
476
 
480
- def user_version=( version )
477
+ def user_version=(version)
481
478
  set_int_pragma "user_version", version
482
479
  end
483
480
 
484
- def vdbe_addoptrace=( mode )
481
+ def vdbe_addoptrace=(mode)
485
482
  set_boolean_pragma "vdbe_addoptrace", mode
486
483
  end
487
484
 
488
- def vdbe_debug=( mode )
485
+ def vdbe_debug=(mode)
489
486
  set_boolean_pragma "vdbe_debug", mode
490
487
  end
491
488
 
492
- def vdbe_listing=( mode )
489
+ def vdbe_listing=(mode)
493
490
  set_boolean_pragma "vdbe_listing", mode
494
491
  end
495
492
 
@@ -497,7 +494,7 @@ module SQLite3
497
494
  get_boolean_pragma "vdbe_trace"
498
495
  end
499
496
 
500
- def vdbe_trace=( mode )
497
+ def vdbe_trace=(mode)
501
498
  set_boolean_pragma "vdbe_trace", mode
502
499
  end
503
500
 
@@ -505,7 +502,7 @@ module SQLite3
505
502
  get_int_pragma "wal_autocheckpoint"
506
503
  end
507
504
 
508
- def wal_autocheckpoint=( mode )
505
+ def wal_autocheckpoint=(mode)
509
506
  set_int_pragma "wal_autocheckpoint", mode
510
507
  end
511
508
 
@@ -513,11 +510,11 @@ module SQLite3
513
510
  get_enum_pragma "wal_checkpoint"
514
511
  end
515
512
 
516
- def wal_checkpoint=( mode )
513
+ def wal_checkpoint=(mode)
517
514
  set_enum_pragma "wal_checkpoint", mode, WAL_CHECKPOINTS
518
515
  end
519
516
 
520
- def writable_schema=( mode )
517
+ def writable_schema=(mode)
521
518
  set_boolean_pragma "writable_schema", mode
522
519
  end
523
520
 
@@ -525,7 +522,7 @@ module SQLite3
525
522
  # Returns information about +table+. Yields each row of table information
526
523
  # if a block is provided.
527
524
  def table_info table
528
- stmt = prepare "PRAGMA table_info(#{table})"
525
+ stmt = prepare "PRAGMA table_info(#{table})"
529
526
  columns = stmt.columns
530
527
 
531
528
  needs_tweak_default =
@@ -533,21 +530,15 @@ module SQLite3
533
530
 
534
531
  result = [] unless block_given?
535
532
  stmt.each do |row|
536
- new_row = Hash[columns.zip(row)]
537
-
538
- # FIXME: This should be removed but is required for older versions
539
- # of rails
540
- if(Object.const_defined?(:ActiveRecord))
541
- new_row['notnull'] = new_row['notnull'].to_s
542
- end
533
+ new_row = columns.zip(row).to_h
543
534
 
544
535
  tweak_default(new_row) if needs_tweak_default
545
536
 
546
537
  # Ensure the type value is downcased. On Mac and Windows
547
538
  # platforms this value is now being returned as all upper
548
539
  # case.
549
- if new_row['type']
550
- new_row['type'] = new_row['type'].downcase
540
+ if new_row["type"]
541
+ new_row["type"] = new_row["type"].downcase
551
542
  end
552
543
 
553
544
  if block_given?
@@ -563,33 +554,32 @@ module SQLite3
563
554
 
564
555
  private
565
556
 
566
- # Compares two version strings
567
- def version_compare(v1, v2)
568
- v1 = v1.split(".").map { |i| i.to_i }
569
- v2 = v2.split(".").map { |i| i.to_i }
570
- parts = [v1.length, v2.length].max
571
- v1.push 0 while v1.length < parts
572
- v2.push 0 while v2.length < parts
573
- v1.zip(v2).each do |a,b|
574
- return -1 if a < b
575
- return 1 if a > b
576
- end
577
- return 0
557
+ # Compares two version strings
558
+ def version_compare(v1, v2)
559
+ v1 = v1.split(".").map { |i| i.to_i }
560
+ v2 = v2.split(".").map { |i| i.to_i }
561
+ parts = [v1.length, v2.length].max
562
+ v1.push 0 while v1.length < parts
563
+ v2.push 0 while v2.length < parts
564
+ v1.zip(v2).each do |a, b|
565
+ return -1 if a < b
566
+ return 1 if a > b
578
567
  end
579
-
580
- # Since SQLite 3.3.8, the table_info pragma has returned the default
581
- # value of the row as a quoted SQL value. This method essentially
582
- # unquotes those values.
583
- def tweak_default(hash)
584
- case hash["dflt_value"]
585
- when /^null$/i
586
- hash["dflt_value"] = nil
587
- when /^'(.*)'$/m
588
- hash["dflt_value"] = $1.gsub(/''/, "'")
589
- when /^"(.*)"$/m
590
- hash["dflt_value"] = $1.gsub(/""/, '"')
591
- end
568
+ 0
569
+ end
570
+
571
+ # Since SQLite 3.3.8, the table_info pragma has returned the default
572
+ # value of the row as a quoted SQL value. This method essentially
573
+ # unquotes those values.
574
+ def tweak_default(hash)
575
+ case hash["dflt_value"]
576
+ when /^null$/i
577
+ hash["dflt_value"] = nil
578
+ when /^'(.*)'$/m
579
+ hash["dflt_value"] = $1.gsub("''", "'")
580
+ when /^"(.*)"$/m
581
+ hash["dflt_value"] = $1.gsub('""', '"')
592
582
  end
583
+ end
593
584
  end
594
-
595
585
  end