sqlite3 1.6.3 → 2.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +615 -1
- data/CONTRIBUTING.md +103 -6
- data/{faq/faq.md → FAQ.md} +66 -79
- data/INSTALLATION.md +267 -0
- data/LICENSE +18 -22
- data/README.md +87 -124
- data/dependencies.yml +10 -11
- data/ext/sqlite3/aggregator.c +178 -178
- data/ext/sqlite3/aggregator.h +7 -4
- data/ext/sqlite3/backup.c +92 -65
- data/ext/sqlite3/backup.h +2 -2
- data/ext/sqlite3/database.c +964 -477
- data/ext/sqlite3/database.h +26 -4
- data/ext/sqlite3/exception.c +213 -94
- data/ext/sqlite3/exception.h +26 -1
- data/ext/sqlite3/extconf.rb +59 -29
- data/ext/sqlite3/sqlite3.c +190 -115
- data/ext/sqlite3/sqlite3_ruby.h +5 -2
- data/ext/sqlite3/statement.c +672 -297
- data/ext/sqlite3/statement.h +4 -3
- data/ext/sqlite3/timespec.h +29 -0
- data/lib/sqlite3/constants.rb +195 -47
- data/lib/sqlite3/database.rb +272 -225
- data/lib/sqlite3/errors.rb +54 -1
- data/lib/sqlite3/fork_safety.rb +66 -0
- data/lib/sqlite3/pragmas.rb +194 -141
- data/lib/sqlite3/resultset.rb +30 -111
- data/lib/sqlite3/statement.rb +105 -25
- data/lib/sqlite3/value.rb +17 -20
- data/lib/sqlite3/version.rb +2 -21
- data/lib/sqlite3/version_info.rb +17 -0
- data/lib/sqlite3.rb +8 -4
- data/ports/archives/sqlite-autoconf-3540100.tar.gz +0 -0
- metadata +16 -48
- data/API_CHANGES.md +0 -49
- data/ChangeLog.cvs +0 -88
- data/Gemfile +0 -11
- data/LICENSE-DEPENDENCIES +0 -20
- data/faq/faq.rb +0 -145
- data/faq/faq.yml +0 -426
- data/lib/sqlite3/translator.rb +0 -118
- data/ports/archives/sqlite-autoconf-3420000.tar.gz +0 -0
- data/test/helper.rb +0 -27
- data/test/test_backup.rb +0 -33
- data/test/test_collation.rb +0 -82
- data/test/test_database.rb +0 -569
- data/test/test_database_flags.rb +0 -95
- data/test/test_database_readonly.rb +0 -36
- data/test/test_database_readwrite.rb +0 -41
- data/test/test_deprecated.rb +0 -49
- data/test/test_encoding.rb +0 -165
- data/test/test_integration.rb +0 -507
- data/test/test_integration_aggregate.rb +0 -336
- data/test/test_integration_open_close.rb +0 -30
- data/test/test_integration_pending.rb +0 -115
- data/test/test_integration_resultset.rb +0 -142
- data/test/test_integration_statement.rb +0 -194
- data/test/test_pragmas.rb +0 -22
- data/test/test_result_set.rb +0 -47
- data/test/test_sqlite3.rb +0 -30
- data/test/test_statement.rb +0 -288
- data/test/test_statement_execute.rb +0 -39
data/lib/sqlite3/resultset.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "sqlite3/constants"
|
|
2
|
+
require "sqlite3/errors"
|
|
3
3
|
|
|
4
4
|
module SQLite3
|
|
5
|
-
|
|
6
5
|
# The ResultSet object encapsulates the enumerability of a query's output.
|
|
7
6
|
# It is a simple cursor over the data that the query returns. It will
|
|
8
7
|
# very rarely (if ever) be instantiated directly. Instead, clients should
|
|
@@ -10,76 +9,22 @@ module SQLite3
|
|
|
10
9
|
class ResultSet
|
|
11
10
|
include Enumerable
|
|
12
11
|
|
|
13
|
-
class ArrayWithTypes < Array # :nodoc:
|
|
14
|
-
attr_accessor :types
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class ArrayWithTypesAndFields < Array # :nodoc:
|
|
18
|
-
attr_writer :types
|
|
19
|
-
attr_writer :fields
|
|
20
|
-
|
|
21
|
-
def types
|
|
22
|
-
warn(<<-eowarn) if $VERBOSE
|
|
23
|
-
#{caller[0]} is calling #{self.class}#types. This method will be removed in
|
|
24
|
-
sqlite3 version 2.0.0, please call the `types` method on the SQLite3::ResultSet
|
|
25
|
-
object that created this object
|
|
26
|
-
eowarn
|
|
27
|
-
@types
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def fields
|
|
31
|
-
warn(<<-eowarn) if $VERBOSE
|
|
32
|
-
#{caller[0]} is calling #{self.class}#fields. This method will be removed in
|
|
33
|
-
sqlite3 version 2.0.0, please call the `columns` method on the SQLite3::ResultSet
|
|
34
|
-
object that created this object
|
|
35
|
-
eowarn
|
|
36
|
-
@fields
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# The class of which we return an object in case we want a Hash as
|
|
41
|
-
# result.
|
|
42
|
-
class HashWithTypesAndFields < Hash # :nodoc:
|
|
43
|
-
attr_writer :types
|
|
44
|
-
attr_writer :fields
|
|
45
|
-
|
|
46
|
-
def types
|
|
47
|
-
warn(<<-eowarn) if $VERBOSE
|
|
48
|
-
#{caller[0]} is calling #{self.class}#types. This method will be removed in
|
|
49
|
-
sqlite3 version 2.0.0, please call the `types` method on the SQLite3::ResultSet
|
|
50
|
-
object that created this object
|
|
51
|
-
eowarn
|
|
52
|
-
@types
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def fields
|
|
56
|
-
warn(<<-eowarn) if $VERBOSE
|
|
57
|
-
#{caller[0]} is calling #{self.class}#fields. This method will be removed in
|
|
58
|
-
sqlite3 version 2.0.0, please call the `columns` method on the SQLite3::ResultSet
|
|
59
|
-
object that created this object
|
|
60
|
-
eowarn
|
|
61
|
-
@fields
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def [] key
|
|
65
|
-
key = fields[key] if key.is_a? Numeric
|
|
66
|
-
super key
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
12
|
# Create a new ResultSet attached to the given database, using the
|
|
71
13
|
# given sql text.
|
|
72
14
|
def initialize db, stmt
|
|
73
|
-
@db
|
|
15
|
+
@db = db
|
|
74
16
|
@stmt = stmt
|
|
75
17
|
end
|
|
76
18
|
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
|
|
19
|
+
# Resets the cursor to the first row, so that you can iterate over the
|
|
20
|
+
# result set again after it reaches the end.
|
|
21
|
+
#
|
|
22
|
+
# This method binds each argument to the statement with
|
|
23
|
+
# Statement#bind_params. The values that you bound before stay bound
|
|
24
|
+
# unless you bind new values to the same parameters.
|
|
25
|
+
def reset(*bind_params)
|
|
80
26
|
@stmt.reset!
|
|
81
|
-
@stmt.bind_params(
|
|
82
|
-
@eof = false
|
|
27
|
+
@stmt.bind_params(*bind_params)
|
|
83
28
|
end
|
|
84
29
|
|
|
85
30
|
# Query whether the cursor has reached the end of the result set or not.
|
|
@@ -88,9 +33,7 @@ object that created this object
|
|
|
88
33
|
end
|
|
89
34
|
|
|
90
35
|
# Obtain the next row from the cursor. If there are no more rows to be
|
|
91
|
-
# had, this will return +nil+.
|
|
92
|
-
# corresponding database, the values in the row will be translated
|
|
93
|
-
# according to their types.
|
|
36
|
+
# had, this will return +nil+.
|
|
94
37
|
#
|
|
95
38
|
# The returned value will be an array, unless Database#results_as_hash has
|
|
96
39
|
# been set to +true+, in which case the returned value will be a hash.
|
|
@@ -101,46 +44,29 @@ object that created this object
|
|
|
101
44
|
# For hashes, the column names are the keys of the hash, and the column
|
|
102
45
|
# types are accessible via the +types+ property.
|
|
103
46
|
def next
|
|
104
|
-
|
|
105
|
-
return next_hash
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
row = @stmt.step
|
|
109
|
-
return nil if @stmt.done?
|
|
110
|
-
|
|
111
|
-
row = @db.translate_from_db @stmt.types, row
|
|
112
|
-
|
|
113
|
-
if row.respond_to?(:fields)
|
|
114
|
-
# FIXME: this can only happen if the translator returns something
|
|
115
|
-
# that responds to `fields`. Since we're removing the translator
|
|
116
|
-
# in 2.0, we can remove this branch in 2.0.
|
|
117
|
-
row = ArrayWithTypes.new(row)
|
|
118
|
-
else
|
|
119
|
-
# FIXME: the `fields` and `types` methods are deprecated on this
|
|
120
|
-
# object for version 2.0, so we can safely remove this branch
|
|
121
|
-
# as well.
|
|
122
|
-
row = ArrayWithTypesAndFields.new(row)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
row.fields = @stmt.columns
|
|
126
|
-
row.types = @stmt.types
|
|
127
|
-
row
|
|
47
|
+
@stmt.step
|
|
128
48
|
end
|
|
129
49
|
|
|
130
|
-
#
|
|
131
|
-
#
|
|
50
|
+
# With a block given, iterates over the rows of the result set, passing each
|
|
51
|
+
# to the block. Returns self.
|
|
52
|
+
# With no block given, returns a new Enumerator.
|
|
132
53
|
def each
|
|
133
|
-
|
|
54
|
+
return enum_for(__method__) unless block_given?
|
|
55
|
+
while (node = self.next)
|
|
134
56
|
yield node
|
|
135
57
|
end
|
|
58
|
+
self
|
|
136
59
|
end
|
|
137
60
|
|
|
138
|
-
#
|
|
139
|
-
#
|
|
61
|
+
# With a block given, iterates over the rows of the result set, passing each
|
|
62
|
+
# to the block as a hash. Returns self.
|
|
63
|
+
# With no block given, returns a new Enumerator.
|
|
140
64
|
def each_hash
|
|
141
|
-
|
|
65
|
+
return enum_for(__method__) unless block_given?
|
|
66
|
+
while (node = next_hash)
|
|
142
67
|
yield node
|
|
143
68
|
end
|
|
69
|
+
self
|
|
144
70
|
end
|
|
145
71
|
|
|
146
72
|
# Closes the statement that spawned this result set.
|
|
@@ -170,18 +96,11 @@ object that created this object
|
|
|
170
96
|
row = @stmt.step
|
|
171
97
|
return nil if @stmt.done?
|
|
172
98
|
|
|
173
|
-
|
|
174
|
-
# in 2.0
|
|
175
|
-
row = @db.translate_from_db @stmt.types, row
|
|
176
|
-
|
|
177
|
-
# FIXME: this can be switched to a regular hash in 2.0
|
|
178
|
-
row = HashWithTypesAndFields[*@stmt.columns.zip(row).flatten]
|
|
179
|
-
|
|
180
|
-
# FIXME: these methods are deprecated for version 2.0, so we can remove
|
|
181
|
-
# this code in 2.0
|
|
182
|
-
row.fields = @stmt.columns
|
|
183
|
-
row.types = @stmt.types
|
|
184
|
-
row
|
|
99
|
+
@stmt.columns.zip(row).to_h
|
|
185
100
|
end
|
|
186
101
|
end
|
|
102
|
+
|
|
103
|
+
class HashResultSet < ResultSet # :nodoc:
|
|
104
|
+
alias_method :next, :next_hash
|
|
105
|
+
end
|
|
187
106
|
end
|
data/lib/sqlite3/statement.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "sqlite3/errors"
|
|
2
|
+
require "sqlite3/resultset"
|
|
3
3
|
|
|
4
4
|
class String
|
|
5
5
|
def to_blob
|
|
6
|
-
SQLite3::Blob.new(
|
|
6
|
+
SQLite3::Blob.new(self)
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -19,20 +19,59 @@ module SQLite3
|
|
|
19
19
|
# this will be the empty string.
|
|
20
20
|
attr_reader :remainder
|
|
21
21
|
|
|
22
|
+
# call-seq: SQLite3::Statement.new(db, sql)
|
|
23
|
+
#
|
|
24
|
+
# Create a new statement attached to the given Database instance, and which
|
|
25
|
+
# encapsulates the given SQL text. If the text contains more than one
|
|
26
|
+
# statement (i.e., separated by semicolons), then the #remainder property
|
|
27
|
+
# will be set to the trailing text.
|
|
28
|
+
def initialize(db, sql)
|
|
29
|
+
raise ArgumentError, "prepare called on a closed database" if db.closed?
|
|
30
|
+
|
|
31
|
+
sql = sql.encode(Encoding::UTF_8) if sql && sql.encoding != Encoding::UTF_8
|
|
32
|
+
|
|
33
|
+
@connection = db
|
|
34
|
+
@columns = nil
|
|
35
|
+
@types = nil
|
|
36
|
+
@remainder = prepare db, sql
|
|
37
|
+
end
|
|
38
|
+
|
|
22
39
|
# Binds the given variables to the corresponding placeholders in the SQL
|
|
23
40
|
# text.
|
|
24
41
|
#
|
|
25
42
|
# See Database#execute for a description of the valid placeholder
|
|
26
43
|
# syntaxes.
|
|
27
44
|
#
|
|
45
|
+
# Type mapping from Ruby to SQLite3:
|
|
46
|
+
# - +nil+ → NULL
|
|
47
|
+
# - Integer → INTEGER (or REAL when outside the signed int64 range)
|
|
48
|
+
# - Float → REAL
|
|
49
|
+
# - SQLite3::Blob → BLOB
|
|
50
|
+
# - String with Encoding::ASCII_8BIT
|
|
51
|
+
# (a.k.a. BINARY) → BLOB
|
|
52
|
+
# - String with Encoding::UTF_16LE
|
|
53
|
+
# or Encoding::UTF_16BE → TEXT (bound as UTF-16)
|
|
54
|
+
# - String (all other encodings) → TEXT (re-encoded to UTF-8 if needed)
|
|
55
|
+
# - Any other type → raises RuntimeError
|
|
56
|
+
#
|
|
57
|
+
# Note: a String with Encoding::ASCII_8BIT (BINARY) is always bound as a
|
|
58
|
+
# BLOB, even when its bytes are all valid ASCII. If you want such a string
|
|
59
|
+
# compared or stored as TEXT, re-encode it before binding:
|
|
60
|
+
#
|
|
61
|
+
# stmt.bind_params(my_binary_str.encode(Encoding::UTF_8))
|
|
62
|
+
#
|
|
28
63
|
# Example:
|
|
29
64
|
#
|
|
30
65
|
# stmt = db.prepare( "select * from table where a=? and b=?" )
|
|
31
66
|
# stmt.bind_params( 15, "hello" )
|
|
32
67
|
#
|
|
68
|
+
# The values that this method binds stay bound when you execute or reset
|
|
69
|
+
# the statement. To change a value, bind a new value to the same
|
|
70
|
+
# parameter. To clear all values, call #clear_bindings!.
|
|
71
|
+
#
|
|
33
72
|
# See also #execute, #bind_param, Statement#bind_param, and
|
|
34
73
|
# Statement#bind_params.
|
|
35
|
-
def bind_params(
|
|
74
|
+
def bind_params(*bind_vars)
|
|
36
75
|
index = 1
|
|
37
76
|
bind_vars.flatten.each do |var|
|
|
38
77
|
if Hash === var
|
|
@@ -48,7 +87,17 @@ module SQLite3
|
|
|
48
87
|
# statement's virtual machine. If a block was given, the new ResultSet will
|
|
49
88
|
# be yielded to it; otherwise, the ResultSet will be returned.
|
|
50
89
|
#
|
|
51
|
-
#
|
|
90
|
+
# This method binds each argument to the statement with #bind_params. The
|
|
91
|
+
# values stay bound after this method returns. If a later call to #execute
|
|
92
|
+
# does not give a value for a parameter, the statement uses the value from
|
|
93
|
+
# the earlier call. To set all parameters to NULL before you execute the
|
|
94
|
+
# statement again, call #clear_bindings!:
|
|
95
|
+
#
|
|
96
|
+
# stmt = db.prepare( "select :a, :b" )
|
|
97
|
+
# stmt.execute( a: 1, b: 2 ).to_a # => [[1, 2]]
|
|
98
|
+
# stmt.execute( a: 3 ).to_a # => [[3, 2]]
|
|
99
|
+
# stmt.clear_bindings!
|
|
100
|
+
# stmt.execute( a: 3 ).to_a # => [[3, nil]]
|
|
52
101
|
#
|
|
53
102
|
# Example:
|
|
54
103
|
#
|
|
@@ -57,24 +106,26 @@ module SQLite3
|
|
|
57
106
|
# ...
|
|
58
107
|
# end
|
|
59
108
|
#
|
|
60
|
-
# See also #bind_params, #execute!.
|
|
61
|
-
def execute(
|
|
109
|
+
# See also #bind_params, #execute!, #clear_bindings!.
|
|
110
|
+
def execute(*bind_vars)
|
|
62
111
|
reset! if active? || done?
|
|
63
112
|
|
|
64
113
|
bind_params(*bind_vars) unless bind_vars.empty?
|
|
65
|
-
|
|
114
|
+
results = @connection.build_result_set self
|
|
66
115
|
|
|
67
|
-
step if
|
|
116
|
+
step if column_count == 0
|
|
68
117
|
|
|
69
|
-
yield
|
|
70
|
-
|
|
118
|
+
yield results if block_given?
|
|
119
|
+
results
|
|
71
120
|
end
|
|
72
121
|
|
|
73
122
|
# Execute the statement. If no block was given, this returns an array of
|
|
74
123
|
# rows returned by executing the statement. Otherwise, each row will be
|
|
75
124
|
# yielded to the block.
|
|
76
125
|
#
|
|
77
|
-
#
|
|
126
|
+
# This method binds each argument to the statement with #bind_params. The
|
|
127
|
+
# values stay bound after this method returns. For more information, see
|
|
128
|
+
# #execute.
|
|
78
129
|
#
|
|
79
130
|
# Example:
|
|
80
131
|
#
|
|
@@ -84,9 +135,9 @@ module SQLite3
|
|
|
84
135
|
# end
|
|
85
136
|
#
|
|
86
137
|
# See also #bind_params, #execute.
|
|
87
|
-
def execute!(
|
|
138
|
+
def execute!(*bind_vars, &block)
|
|
88
139
|
execute(*bind_vars)
|
|
89
|
-
|
|
140
|
+
block ? each(&block) : to_a
|
|
90
141
|
end
|
|
91
142
|
|
|
92
143
|
# Returns true if the statement is currently active, meaning it has an
|
|
@@ -95,12 +146,12 @@ module SQLite3
|
|
|
95
146
|
!done?
|
|
96
147
|
end
|
|
97
148
|
|
|
98
|
-
# Return
|
|
99
|
-
# may execute the statement in order to
|
|
100
|
-
# a (potentially) expensive operation.
|
|
149
|
+
# Return a frozen array of the column names for this statement, as frozen
|
|
150
|
+
# UTF-8 strings. Note that this may execute the statement in order to
|
|
151
|
+
# obtain the metadata; this makes it a (potentially) expensive operation.
|
|
101
152
|
def columns
|
|
102
153
|
get_metadata unless @columns
|
|
103
|
-
|
|
154
|
+
@columns
|
|
104
155
|
end
|
|
105
156
|
|
|
106
157
|
def each
|
|
@@ -111,9 +162,11 @@ module SQLite3
|
|
|
111
162
|
end
|
|
112
163
|
end
|
|
113
164
|
|
|
114
|
-
# Return
|
|
115
|
-
#
|
|
116
|
-
#
|
|
165
|
+
# Return a frozen array of the declared types of the columns in this
|
|
166
|
+
# statement, as frozen UTF-8 strings with ASCII letters downcased. A column
|
|
167
|
+
# with no declared type, such as an expression, has a +nil+ type. Note that
|
|
168
|
+
# this may execute the statement in order to obtain the metadata; this makes
|
|
169
|
+
# it a (potentially) expensive operation.
|
|
117
170
|
def types
|
|
118
171
|
must_be_open!
|
|
119
172
|
get_metadata unless @types
|
|
@@ -128,18 +181,45 @@ module SQLite3
|
|
|
128
181
|
end
|
|
129
182
|
end
|
|
130
183
|
|
|
184
|
+
# Returns a Hash containing information about the statement.
|
|
185
|
+
# The contents of the hash are implementation specific and may change in
|
|
186
|
+
# the future without notice. The hash includes information about internal
|
|
187
|
+
# statistics about the statement such as:
|
|
188
|
+
# - +fullscan_steps+: the number of times that SQLite has stepped forward
|
|
189
|
+
# in a table as part of a full table scan
|
|
190
|
+
# - +sorts+: the number of sort operations that have occurred
|
|
191
|
+
# - +autoindexes+: the number of rows inserted into transient indices
|
|
192
|
+
# that were created automatically in order to help joins run faster
|
|
193
|
+
# - +vm_steps+: the number of virtual machine operations executed by the
|
|
194
|
+
# prepared statement
|
|
195
|
+
# - +reprepares+: the number of times that the prepare statement has been
|
|
196
|
+
# automatically regenerated due to schema changes or changes to bound
|
|
197
|
+
# parameters that might affect the query plan
|
|
198
|
+
# - +runs+: the number of times that the prepared statement has been run
|
|
199
|
+
# - +filter_misses+: the number of times that the Bloom filter returned
|
|
200
|
+
# a find, and thus the join step had to be processed as normal
|
|
201
|
+
# - +filter_hits+: the number of times that a join step was bypassed
|
|
202
|
+
# because a Bloom filter returned not-found
|
|
203
|
+
def stat key = nil
|
|
204
|
+
if key
|
|
205
|
+
stat_for(key)
|
|
206
|
+
else
|
|
207
|
+
stats_as_hash
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
131
211
|
private
|
|
212
|
+
|
|
132
213
|
# A convenience method for obtaining the metadata about the query. Note
|
|
133
214
|
# that this will actually execute the SQL, which means it can be a
|
|
134
215
|
# (potentially) expensive operation.
|
|
135
216
|
def get_metadata
|
|
136
217
|
@columns = Array.new(column_count) do |column|
|
|
137
218
|
column_name column
|
|
138
|
-
end
|
|
219
|
+
end.freeze
|
|
139
220
|
@types = Array.new(column_count) do |column|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
end
|
|
221
|
+
column_decltype_downcased(column)
|
|
222
|
+
end.freeze
|
|
143
223
|
end
|
|
144
224
|
end
|
|
145
225
|
end
|
data/lib/sqlite3/value.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "sqlite3/constants"
|
|
2
2
|
|
|
3
3
|
module SQLite3
|
|
4
|
-
|
|
5
4
|
class Value
|
|
6
5
|
attr_reader :handle
|
|
7
6
|
|
|
8
|
-
def initialize(
|
|
7
|
+
def initialize(db, handle)
|
|
9
8
|
@driver = db.driver
|
|
10
9
|
@handle = handle
|
|
11
10
|
end
|
|
@@ -15,43 +14,41 @@ module SQLite3
|
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
def to_blob
|
|
18
|
-
@driver.value_blob(
|
|
17
|
+
@driver.value_blob(@handle)
|
|
19
18
|
end
|
|
20
19
|
|
|
21
|
-
def length(
|
|
20
|
+
def length(utf16 = false)
|
|
22
21
|
if utf16
|
|
23
|
-
@driver.value_bytes16(
|
|
22
|
+
@driver.value_bytes16(@handle)
|
|
24
23
|
else
|
|
25
|
-
@driver.value_bytes(
|
|
24
|
+
@driver.value_bytes(@handle)
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
def to_f
|
|
30
|
-
@driver.value_double(
|
|
29
|
+
@driver.value_double(@handle)
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
def to_i
|
|
34
|
-
@driver.value_int(
|
|
33
|
+
@driver.value_int(@handle)
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
def to_int64
|
|
38
|
-
@driver.value_int64(
|
|
37
|
+
@driver.value_int64(@handle)
|
|
39
38
|
end
|
|
40
39
|
|
|
41
|
-
def to_s(
|
|
42
|
-
@driver.value_text(
|
|
40
|
+
def to_s(utf16 = false)
|
|
41
|
+
@driver.value_text(@handle, utf16)
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
def type
|
|
46
|
-
case @driver.value_type(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
case @driver.value_type(@handle)
|
|
46
|
+
when Constants::ColumnType::INTEGER then :int
|
|
47
|
+
when Constants::ColumnType::FLOAT then :float
|
|
48
|
+
when Constants::ColumnType::TEXT then :text
|
|
49
|
+
when Constants::ColumnType::BLOB then :blob
|
|
50
|
+
when Constants::ColumnType::NULL then :null
|
|
52
51
|
end
|
|
53
52
|
end
|
|
54
|
-
|
|
55
53
|
end
|
|
56
|
-
|
|
57
54
|
end
|
data/lib/sqlite3/version.rb
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
module SQLite3
|
|
2
|
-
|
|
3
|
-
VERSION = "
|
|
4
|
-
|
|
5
|
-
module VersionProxy
|
|
6
|
-
MAJOR = 1
|
|
7
|
-
MINOR = 6
|
|
8
|
-
TINY = 3
|
|
9
|
-
BUILD = nil
|
|
10
|
-
|
|
11
|
-
STRING = [ MAJOR, MINOR, TINY, BUILD ].compact.join( "." )
|
|
12
|
-
|
|
13
|
-
VERSION = ::SQLite3::VERSION
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.const_missing(name)
|
|
17
|
-
return super unless name == :Version
|
|
18
|
-
warn(<<-eowarn) if $VERBOSE
|
|
19
|
-
#{caller[0]}: SQLite::Version will be removed in sqlite3-ruby version 2.0.0
|
|
20
|
-
eowarn
|
|
21
|
-
VersionProxy
|
|
22
|
-
end
|
|
2
|
+
# (String) the version of the sqlite3 gem, e.g. "2.1.1"
|
|
3
|
+
VERSION = "2.10.2"
|
|
23
4
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module SQLite3
|
|
2
|
+
# a hash of descriptive metadata about the current version of the sqlite3 gem
|
|
3
|
+
VERSION_INFO = {
|
|
4
|
+
ruby: RUBY_DESCRIPTION,
|
|
5
|
+
gem: {
|
|
6
|
+
version: SQLite3::VERSION
|
|
7
|
+
},
|
|
8
|
+
sqlite: {
|
|
9
|
+
compiled: SQLite3::SQLITE_VERSION,
|
|
10
|
+
loaded: SQLite3::SQLITE_LOADED_VERSION,
|
|
11
|
+
packaged: SQLite3::SQLITE_PACKAGED_LIBRARIES,
|
|
12
|
+
precompiled: SQLite3::SQLITE_PRECOMPILED_LIBRARIES,
|
|
13
|
+
sqlcipher: SQLite3.sqlcipher?,
|
|
14
|
+
threadsafe: SQLite3.threadsafe?
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
end
|
data/lib/sqlite3.rb
CHANGED
|
@@ -3,13 +3,17 @@ begin
|
|
|
3
3
|
RUBY_VERSION =~ /(\d+\.\d+)/
|
|
4
4
|
require "sqlite3/#{$1}/sqlite3_native"
|
|
5
5
|
rescue LoadError
|
|
6
|
-
require
|
|
6
|
+
require "sqlite3/sqlite3_native"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
require
|
|
10
|
-
require
|
|
9
|
+
require "sqlite3/database"
|
|
10
|
+
require "sqlite3/version"
|
|
11
11
|
|
|
12
12
|
module SQLite3
|
|
13
13
|
# Was sqlite3 compiled with thread safety on?
|
|
14
|
-
def self.threadsafe
|
|
14
|
+
def self.threadsafe?
|
|
15
|
+
threadsafe > 0
|
|
16
|
+
end
|
|
15
17
|
end
|
|
18
|
+
|
|
19
|
+
require "sqlite3/version_info"
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sqlite3
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.10.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jamis Buck
|
|
8
8
|
- Luis Lavena
|
|
9
9
|
- Aaron Patterson
|
|
10
|
-
|
|
10
|
+
- Mike Dalessio
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: mini_portile2
|
|
@@ -26,19 +26,13 @@ dependencies:
|
|
|
26
26
|
- - "~>"
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
28
|
version: 2.8.0
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
database engine (http://www.sqlite.org). You must have the
|
|
33
|
-
SQLite engine installed in order to build this module.
|
|
34
|
-
|
|
35
|
-
Note that this module is only compatible with SQLite 3.6.16 or newer.
|
|
36
|
-
email:
|
|
29
|
+
description: |
|
|
30
|
+
Ruby library to interface with the SQLite3 database engine (http://www.sqlite.org). Precompiled
|
|
31
|
+
binaries are available for common platforms for recent versions of Ruby.
|
|
37
32
|
executables: []
|
|
38
33
|
extensions:
|
|
39
34
|
- ext/sqlite3/extconf.rb
|
|
40
35
|
extra_rdoc_files:
|
|
41
|
-
- API_CHANGES.md
|
|
42
36
|
- CHANGELOG.md
|
|
43
37
|
- README.md
|
|
44
38
|
- ext/sqlite3/aggregator.c
|
|
@@ -49,13 +43,11 @@ extra_rdoc_files:
|
|
|
49
43
|
- ext/sqlite3/statement.c
|
|
50
44
|
files:
|
|
51
45
|
- ".gemtest"
|
|
52
|
-
- API_CHANGES.md
|
|
53
46
|
- CHANGELOG.md
|
|
54
47
|
- CONTRIBUTING.md
|
|
55
|
-
-
|
|
56
|
-
-
|
|
48
|
+
- FAQ.md
|
|
49
|
+
- INSTALLATION.md
|
|
57
50
|
- LICENSE
|
|
58
|
-
- LICENSE-DEPENDENCIES
|
|
59
51
|
- README.md
|
|
60
52
|
- dependencies.yml
|
|
61
53
|
- ext/sqlite3/aggregator.c
|
|
@@ -71,52 +63,30 @@ files:
|
|
|
71
63
|
- ext/sqlite3/sqlite3_ruby.h
|
|
72
64
|
- ext/sqlite3/statement.c
|
|
73
65
|
- ext/sqlite3/statement.h
|
|
74
|
-
-
|
|
75
|
-
- faq/faq.rb
|
|
76
|
-
- faq/faq.yml
|
|
66
|
+
- ext/sqlite3/timespec.h
|
|
77
67
|
- lib/sqlite3.rb
|
|
78
68
|
- lib/sqlite3/constants.rb
|
|
79
69
|
- lib/sqlite3/database.rb
|
|
80
70
|
- lib/sqlite3/errors.rb
|
|
71
|
+
- lib/sqlite3/fork_safety.rb
|
|
81
72
|
- lib/sqlite3/pragmas.rb
|
|
82
73
|
- lib/sqlite3/resultset.rb
|
|
83
74
|
- lib/sqlite3/statement.rb
|
|
84
|
-
- lib/sqlite3/translator.rb
|
|
85
75
|
- lib/sqlite3/value.rb
|
|
86
76
|
- lib/sqlite3/version.rb
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
- test/test_backup.rb
|
|
90
|
-
- test/test_collation.rb
|
|
91
|
-
- test/test_database.rb
|
|
92
|
-
- test/test_database_flags.rb
|
|
93
|
-
- test/test_database_readonly.rb
|
|
94
|
-
- test/test_database_readwrite.rb
|
|
95
|
-
- test/test_deprecated.rb
|
|
96
|
-
- test/test_encoding.rb
|
|
97
|
-
- test/test_integration.rb
|
|
98
|
-
- test/test_integration_aggregate.rb
|
|
99
|
-
- test/test_integration_open_close.rb
|
|
100
|
-
- test/test_integration_pending.rb
|
|
101
|
-
- test/test_integration_resultset.rb
|
|
102
|
-
- test/test_integration_statement.rb
|
|
103
|
-
- test/test_pragmas.rb
|
|
104
|
-
- test/test_result_set.rb
|
|
105
|
-
- test/test_sqlite3.rb
|
|
106
|
-
- test/test_statement.rb
|
|
107
|
-
- test/test_statement_execute.rb
|
|
77
|
+
- lib/sqlite3/version_info.rb
|
|
78
|
+
- ports/archives/sqlite-autoconf-3540100.tar.gz
|
|
108
79
|
homepage: https://github.com/sparklemotion/sqlite3-ruby
|
|
109
80
|
licenses:
|
|
110
81
|
- BSD-3-Clause
|
|
111
82
|
metadata:
|
|
112
83
|
homepage_uri: https://github.com/sparklemotion/sqlite3-ruby
|
|
113
84
|
bug_tracker_uri: https://github.com/sparklemotion/sqlite3-ruby/issues
|
|
114
|
-
documentation_uri: https://
|
|
85
|
+
documentation_uri: https://sparklemotion.github.io/sqlite3-ruby/
|
|
115
86
|
changelog_uri: https://github.com/sparklemotion/sqlite3-ruby/blob/master/CHANGELOG.md
|
|
116
87
|
source_code_uri: https://github.com/sparklemotion/sqlite3-ruby
|
|
117
88
|
msys2_mingw_dependencies: sqlite3
|
|
118
89
|
rubygems_mfa_required: 'true'
|
|
119
|
-
post_install_message:
|
|
120
90
|
rdoc_options:
|
|
121
91
|
- "--main"
|
|
122
92
|
- README.md
|
|
@@ -126,16 +96,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
126
96
|
requirements:
|
|
127
97
|
- - ">="
|
|
128
98
|
- !ruby/object:Gem::Version
|
|
129
|
-
version:
|
|
99
|
+
version: '3.2'
|
|
130
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
101
|
requirements:
|
|
132
102
|
- - ">="
|
|
133
103
|
- !ruby/object:Gem::Version
|
|
134
104
|
version: '0'
|
|
135
105
|
requirements: []
|
|
136
|
-
rubygems_version:
|
|
137
|
-
signing_key:
|
|
106
|
+
rubygems_version: 4.0.20
|
|
138
107
|
specification_version: 4
|
|
139
|
-
summary:
|
|
140
|
-
(http://www.sqlite.org)
|
|
108
|
+
summary: Ruby library to interface with the SQLite3 database engine (http://www.sqlite.org).
|
|
141
109
|
test_files: []
|