sqlite3 1.3.8-x86-mingw32 → 1.3.9-x86-mingw32
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 +7 -0
- data/CHANGELOG.rdoc +8 -0
- data/README.rdoc +8 -4
- data/ext/sqlite3/database.c +7 -4
- data/ext/sqlite3/extconf.rb +6 -2
- data/ext/sqlite3/sqlite3.c +57 -0
- data/ext/sqlite3/sqlite3_ruby.h +3 -4
- data/ext/sqlite3/statement.c +25 -17
- data/faq/faq.yml +1 -1
- data/lib/sqlite3/1.8/sqlite3_native.so +0 -0
- data/lib/sqlite3/1.9/sqlite3_native.so +0 -0
- data/lib/sqlite3/2.0/sqlite3_native.so +0 -0
- data/lib/sqlite3/database.rb +23 -12
- data/lib/sqlite3/pragmas.rb +2 -2
- data/lib/sqlite3/version.rb +2 -2
- data/setup.rb +2 -2
- data/tasks/gem.rake +1 -1
- data/tasks/vendor_sqlite3.rake +1 -1
- data/test/test_database.rb +17 -0
- data/test/test_encoding.rb +32 -0
- data/test/test_integration.rb +31 -14
- data/test/test_integration_pending.rb +1 -1
- data/test/test_statement.rb +5 -1
- metadata +105 -133
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29a7ebae071d2cd35913bce0539f9f16fe19432c
|
4
|
+
data.tar.gz: aceed526f88434c117ca1d888e2d8538f7ea68f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21e03d4d4e9707c15e9fa16fb4cb7ed98584e5860dca7c794a720121b0700bc73f1ff1a6451a23a20cfc93b6f4c5de542ce26f94928d45c6925db6d4e3148313
|
7
|
+
data.tar.gz: 68f6b0f1682745f73327a72981d3e121defa6c2bb4a4cc4e65d8cc3185053f24ec2c82cdf4eef6dfbc831de92d693b6752c1b9fef6263ac30b61e637e479ab8f
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 1.3.9 / 2014-02-25
|
2
|
+
|
3
|
+
* Bugfixes:
|
4
|
+
* Reset exception message. Closes #80
|
5
|
+
* Reduce warnings due unused pointers. Closes #89
|
6
|
+
* Add BSD-3 license reference to gemspec. Refs #99 and #106
|
7
|
+
|
1
8
|
=== 1.3.8 / 2013-08-17
|
2
9
|
|
3
10
|
* Enhancements:
|
@@ -19,6 +26,7 @@
|
|
19
26
|
|
20
27
|
* Bugfixes
|
21
28
|
* Closing a bad statement twice will not segv.
|
29
|
+
* Aggregate handlers are initialized on each query. Closes #44
|
22
30
|
|
23
31
|
* Internal
|
24
32
|
* Unset environment variables that could affect cross compilation.
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= SQLite3/Ruby Interface
|
2
2
|
|
3
|
-
*
|
3
|
+
* https://github.com/sparklemotion/sqlite3-ruby
|
4
4
|
* http://groups.google.com/group/sqlite3-ruby
|
5
5
|
|
6
6
|
== DESCRIPTION
|
@@ -33,6 +33,10 @@ Note that this module is only compatible with SQLite 3.6.16 or newer.
|
|
33
33
|
}.each do |pair|
|
34
34
|
db.execute "insert into numbers values ( ?, ? )", pair
|
35
35
|
end
|
36
|
+
|
37
|
+
# Execute inserts with parameter markers
|
38
|
+
db.execute("INSERT INTO students (name, email, grade, blog)
|
39
|
+
VALUES (?, ?, ?, ?)", [@name, @email, @grade, @blog])
|
36
40
|
|
37
41
|
# Find a few rows
|
38
42
|
db.execute( "select * from numbers" ) do |row|
|
@@ -75,10 +79,10 @@ can be found here:
|
|
75
79
|
|
76
80
|
Uh oh. After contacting the mailing list, you've found that you've actually
|
77
81
|
discovered a bug. You can file the bug at the
|
78
|
-
{github issues page}[
|
82
|
+
{github issues page}[https://github.com/sparklemotion/sqlite3-ruby/issues]
|
79
83
|
which can be found here:
|
80
84
|
|
81
|
-
*
|
85
|
+
* https://github.com/sparklemotion/sqlite3-ruby/issues
|
82
86
|
|
83
87
|
== Usage
|
84
88
|
|
@@ -91,5 +95,5 @@ FAQ, please send them to {the mailing list}[http://groups.google.com/group/sqlit
|
|
91
95
|
|
92
96
|
The source repository is accessible via git:
|
93
97
|
|
94
|
-
git clone git://github.com/
|
98
|
+
git clone git://github.com/sparklemotion/sqlite3-ruby.git
|
95
99
|
|
data/ext/sqlite3/database.c
CHANGED
@@ -308,13 +308,16 @@ static void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result)
|
|
308
308
|
case T_FIXNUM:
|
309
309
|
sqlite3_result_int64(ctx, (sqlite3_int64)FIX2LONG(result));
|
310
310
|
break;
|
311
|
-
case T_BIGNUM:
|
311
|
+
case T_BIGNUM: {
|
312
312
|
#if SIZEOF_LONG < 8
|
313
|
-
|
314
|
-
|
315
|
-
|
313
|
+
sqlite3_int64 num64;
|
314
|
+
|
315
|
+
if (bignum_to_int64(result, &num64)) {
|
316
|
+
sqlite3_result_int64(ctx, num64);
|
317
|
+
break;
|
316
318
|
}
|
317
319
|
#endif
|
320
|
+
}
|
318
321
|
case T_FLOAT:
|
319
322
|
sqlite3_result_double(ctx, NUM2DBL(result));
|
320
323
|
break;
|
data/ext/sqlite3/extconf.rb
CHANGED
@@ -24,8 +24,9 @@ def asplode missing
|
|
24
24
|
"http://www.sqlite.org/ first."
|
25
25
|
else
|
26
26
|
abort <<-error
|
27
|
-
#{missing} is missing. Try 'port install sqlite3 +universal'
|
28
|
-
|
27
|
+
#{missing} is missing. Try 'port install sqlite3 +universal',
|
28
|
+
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
|
29
|
+
and check your shared library search path (the
|
29
30
|
location where your sqlite3 shared library is located).
|
30
31
|
error
|
31
32
|
end
|
@@ -37,6 +38,9 @@ asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number'
|
|
37
38
|
# Functions defined in 1.9 but not 1.8
|
38
39
|
have_func('rb_proc_arity')
|
39
40
|
|
41
|
+
# Functions defined in 2.1 but not 2.0
|
42
|
+
have_func('rb_integer_pack')
|
43
|
+
|
40
44
|
# These functions may not be defined
|
41
45
|
have_func('sqlite3_initialize')
|
42
46
|
have_func('sqlite3_backup_init')
|
data/ext/sqlite3/sqlite3.c
CHANGED
@@ -3,6 +3,63 @@
|
|
3
3
|
VALUE mSqlite3;
|
4
4
|
VALUE cSqlite3Blob;
|
5
5
|
|
6
|
+
int bignum_to_int64(VALUE value, sqlite3_int64 *result)
|
7
|
+
{
|
8
|
+
#ifdef HAVE_RB_INTEGER_PACK
|
9
|
+
const int nails = 0;
|
10
|
+
int t = rb_integer_pack(value, result, 1, sizeof(*result), nails,
|
11
|
+
INTEGER_PACK_NATIVE_BYTE_ORDER|
|
12
|
+
INTEGER_PACK_2COMP);
|
13
|
+
switch (t) {
|
14
|
+
case -2: case +2:
|
15
|
+
return 0;
|
16
|
+
case +1:
|
17
|
+
if (!nails) {
|
18
|
+
if (*result < 0) return 0;
|
19
|
+
}
|
20
|
+
break;
|
21
|
+
case -1:
|
22
|
+
if (!nails) {
|
23
|
+
if (*result >= 0) return 0;
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
*result += INT64_MIN;
|
27
|
+
}
|
28
|
+
break;
|
29
|
+
}
|
30
|
+
return 1;
|
31
|
+
#else
|
32
|
+
# ifndef RBIGNUM_LEN
|
33
|
+
# define RBIGNUM_LEN(x) RBIGNUM(x)->len
|
34
|
+
# endif
|
35
|
+
const long len = RBIGNUM_LEN(value);
|
36
|
+
if (len == 0) {
|
37
|
+
*result = 0;
|
38
|
+
return 1;
|
39
|
+
}
|
40
|
+
if (len > 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) return 0;
|
41
|
+
if (len == 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) {
|
42
|
+
const BDIGIT *digits = RBIGNUM_DIGITS(value);
|
43
|
+
BDIGIT blast = digits[len-1];
|
44
|
+
BDIGIT bmax = (BDIGIT)1UL << (63 % (CHAR_BIT * SIZEOF_BDIGITS));
|
45
|
+
if (blast > bmax) return 0;
|
46
|
+
if (blast == bmax) {
|
47
|
+
if (RBIGNUM_POSITIVE_P(value)) {
|
48
|
+
return 0;
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
long i = len-1;
|
52
|
+
while (i) {
|
53
|
+
if (digits[--i]) return 0;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
*result = (sqlite3_int64)NUM2LL(value);
|
59
|
+
return 1;
|
60
|
+
#endif
|
61
|
+
}
|
62
|
+
|
6
63
|
static VALUE libversion(VALUE UNUSED(klass))
|
7
64
|
{
|
8
65
|
return INT2NUM(sqlite3_libversion_number());
|
data/ext/sqlite3/sqlite3_ruby.h
CHANGED
@@ -12,13 +12,10 @@
|
|
12
12
|
# define UNUSED(x) x
|
13
13
|
#endif
|
14
14
|
|
15
|
-
#ifndef RBIGNUM_LEN
|
16
|
-
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
|
17
|
-
#endif
|
18
|
-
|
19
15
|
#ifdef HAVE_RUBY_ENCODING_H
|
20
16
|
#include <ruby/encoding.h>
|
21
17
|
|
18
|
+
#define USASCII_P(_obj) (rb_enc_get_index(_obj) == rb_usascii_encindex())
|
22
19
|
#define UTF8_P(_obj) (rb_enc_get_index(_obj) == rb_utf8_encindex())
|
23
20
|
#define UTF16_LE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16LE"))
|
24
21
|
#define UTF16_BE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16BE"))
|
@@ -50,4 +47,6 @@ extern VALUE cSqlite3Blob;
|
|
50
47
|
#include <exception.h>
|
51
48
|
#include <backup.h>
|
52
49
|
|
50
|
+
int bignum_to_int64(VALUE big, sqlite3_int64 *result);
|
51
|
+
|
53
52
|
#endif
|
data/ext/sqlite3/statement.c
CHANGED
@@ -112,7 +112,6 @@ static VALUE step(VALUE self)
|
|
112
112
|
VALUE list;
|
113
113
|
#ifdef HAVE_RUBY_ENCODING_H
|
114
114
|
rb_encoding * internal_encoding;
|
115
|
-
int enc_index;
|
116
115
|
#endif
|
117
116
|
|
118
117
|
Data_Get_Struct(self, sqlite3StmtRuby, ctx);
|
@@ -124,8 +123,7 @@ static VALUE step(VALUE self)
|
|
124
123
|
#ifdef HAVE_RUBY_ENCODING_H
|
125
124
|
{
|
126
125
|
VALUE db = rb_iv_get(self, "@connection");
|
127
|
-
|
128
|
-
enc_index = NIL_P(encoding) ? rb_utf8_encindex() : rb_to_encoding_index(encoding);
|
126
|
+
rb_funcall(db, rb_intern("encoding"), 0);
|
129
127
|
internal_encoding = rb_default_internal_encoding();
|
130
128
|
}
|
131
129
|
#endif
|
@@ -155,7 +153,7 @@ static VALUE step(VALUE self)
|
|
155
153
|
(long)sqlite3_column_bytes(stmt, i)
|
156
154
|
);
|
157
155
|
#ifdef HAVE_RUBY_ENCODING_H
|
158
|
-
rb_enc_associate_index(str,
|
156
|
+
rb_enc_associate_index(str, rb_utf8_encindex());
|
159
157
|
if(internal_encoding)
|
160
158
|
str = rb_str_export_to_enc(str, internal_encoding);
|
161
159
|
#endif
|
@@ -239,15 +237,22 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
239
237
|
SQLITE_TRANSIENT
|
240
238
|
);
|
241
239
|
} else {
|
240
|
+
|
241
|
+
|
242
242
|
#ifdef HAVE_RUBY_ENCODING_H
|
243
|
-
if(
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
243
|
+
if (UTF16_LE_P(value)) {
|
244
|
+
status = sqlite3_bind_text16(
|
245
|
+
ctx->st,
|
246
|
+
index,
|
247
|
+
(const char *)StringValuePtr(value),
|
248
|
+
(int)RSTRING_LEN(value),
|
249
|
+
SQLITE_TRANSIENT
|
250
|
+
);
|
251
|
+
} else {
|
252
|
+
if (!UTF8_P(value) || !USASCII_P(value)) {
|
253
|
+
value = rb_str_encode(value, rb_enc_from_encoding(rb_utf8_encoding()), 0, Qnil);
|
248
254
|
}
|
249
255
|
#endif
|
250
|
-
|
251
256
|
status = sqlite3_bind_text(
|
252
257
|
ctx->st,
|
253
258
|
index,
|
@@ -255,13 +260,18 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
255
260
|
(int)RSTRING_LEN(value),
|
256
261
|
SQLITE_TRANSIENT
|
257
262
|
);
|
263
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
264
|
+
}
|
265
|
+
#endif
|
258
266
|
}
|
259
267
|
break;
|
260
|
-
case T_BIGNUM:
|
261
|
-
|
262
|
-
|
268
|
+
case T_BIGNUM: {
|
269
|
+
sqlite3_int64 num64;
|
270
|
+
if (bignum_to_int64(value, &num64)) {
|
271
|
+
status = sqlite3_bind_int64(ctx->st, index, num64);
|
263
272
|
break;
|
264
273
|
}
|
274
|
+
}
|
265
275
|
case T_FLOAT:
|
266
276
|
status = sqlite3_bind_double(ctx->st, index, NUM2DBL(value));
|
267
277
|
break;
|
@@ -290,12 +300,11 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
290
300
|
static VALUE reset_bang(VALUE self)
|
291
301
|
{
|
292
302
|
sqlite3StmtRubyPtr ctx;
|
293
|
-
int status;
|
294
303
|
|
295
304
|
Data_Get_Struct(self, sqlite3StmtRuby, ctx);
|
296
305
|
REQUIRE_OPEN_STMT(ctx);
|
297
306
|
|
298
|
-
|
307
|
+
sqlite3_reset(ctx->st);
|
299
308
|
|
300
309
|
ctx->done_p = 0;
|
301
310
|
|
@@ -310,12 +319,11 @@ static VALUE reset_bang(VALUE self)
|
|
310
319
|
static VALUE clear_bindings(VALUE self)
|
311
320
|
{
|
312
321
|
sqlite3StmtRubyPtr ctx;
|
313
|
-
int status;
|
314
322
|
|
315
323
|
Data_Get_Struct(self, sqlite3StmtRuby, ctx);
|
316
324
|
REQUIRE_OPEN_STMT(ctx);
|
317
325
|
|
318
|
-
|
326
|
+
sqlite3_clear_bindings(ctx->st);
|
319
327
|
|
320
328
|
ctx->done_p = 0;
|
321
329
|
|
data/faq/faq.yml
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/lib/sqlite3/database.rb
CHANGED
@@ -94,7 +94,7 @@ in version 2.0.0.
|
|
94
94
|
begin
|
95
95
|
yield stmt
|
96
96
|
ensure
|
97
|
-
stmt.close
|
97
|
+
stmt.close unless stmt.closed?
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -221,15 +221,18 @@ Support for this behavior will be removed in version 2.0.0.
|
|
221
221
|
sql = sql.strip
|
222
222
|
until sql.empty? do
|
223
223
|
prepare( sql ) do |stmt|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
stmt.
|
224
|
+
unless stmt.closed?
|
225
|
+
# FIXME: this should probably use sqlite3's api for batch execution
|
226
|
+
# This implementation requires stepping over the results.
|
227
|
+
if bind_vars.length == stmt.bind_parameter_count
|
228
|
+
stmt.bind_params(bind_vars)
|
229
|
+
end
|
230
|
+
stmt.step
|
228
231
|
end
|
229
|
-
stmt.step
|
230
232
|
sql = stmt.remainder.strip
|
231
233
|
end
|
232
234
|
end
|
235
|
+
# FIXME: we should not return `nil` as a success return value
|
233
236
|
nil
|
234
237
|
end
|
235
238
|
|
@@ -428,6 +431,7 @@ Support for this will be removed in version 2.0.0.
|
|
428
431
|
#
|
429
432
|
# class LengthsAggregateHandler
|
430
433
|
# def self.arity; 1; end
|
434
|
+
# def self.name; 'lengths'; end
|
431
435
|
#
|
432
436
|
# def initialize
|
433
437
|
# @total = 0
|
@@ -446,21 +450,28 @@ Support for this will be removed in version 2.0.0.
|
|
446
450
|
# puts db.get_first_value( "select lengths(name) from A" )
|
447
451
|
def create_aggregate_handler( handler )
|
448
452
|
proxy = Class.new do
|
449
|
-
def initialize
|
450
|
-
@
|
451
|
-
@fp
|
453
|
+
def initialize klass
|
454
|
+
@klass = klass
|
455
|
+
@fp = FunctionProxy.new
|
452
456
|
end
|
453
457
|
|
454
458
|
def step( *args )
|
455
|
-
|
459
|
+
instance.step(@fp, *args)
|
456
460
|
end
|
457
461
|
|
458
462
|
def finalize
|
459
|
-
|
463
|
+
instance.finalize @fp
|
464
|
+
@instance = nil
|
460
465
|
@fp.result
|
461
466
|
end
|
467
|
+
|
468
|
+
private
|
469
|
+
|
470
|
+
def instance
|
471
|
+
@instance ||= @klass.new
|
472
|
+
end
|
462
473
|
end
|
463
|
-
define_aggregator(handler.name, proxy.new(handler
|
474
|
+
define_aggregator(handler.name, proxy.new(handler))
|
464
475
|
self
|
465
476
|
end
|
466
477
|
|
data/lib/sqlite3/pragmas.rb
CHANGED
@@ -269,9 +269,9 @@ module SQLite3
|
|
269
269
|
case hash["dflt_value"]
|
270
270
|
when /^null$/i
|
271
271
|
hash["dflt_value"] = nil
|
272
|
-
when /^'(.*)'$/
|
272
|
+
when /^'(.*)'$/m
|
273
273
|
hash["dflt_value"] = $1.gsub(/''/, "'")
|
274
|
-
when /^"(.*)"$/
|
274
|
+
when /^"(.*)"$/m
|
275
275
|
hash["dflt_value"] = $1.gsub(/""/, '"')
|
276
276
|
end
|
277
277
|
end
|
data/lib/sqlite3/version.rb
CHANGED
data/setup.rb
CHANGED
@@ -102,7 +102,7 @@ end
|
|
102
102
|
|
103
103
|
class ConfigTable
|
104
104
|
|
105
|
-
c = ::
|
105
|
+
c = ::RbConfig::CONFIG
|
106
106
|
|
107
107
|
rubypath = c['bindir'] + '/' + c['ruby_install_name']
|
108
108
|
|
@@ -1219,7 +1219,7 @@ class Installer
|
|
1219
1219
|
raise InstallError, "no ruby extention exists: 'ruby #{$0} setup' first"
|
1220
1220
|
end
|
1221
1221
|
|
1222
|
-
DLEXT = /\.#{ ::
|
1222
|
+
DLEXT = /\.#{ ::RbConfig::CONFIG['DLEXT'] }\z/
|
1223
1223
|
|
1224
1224
|
def _ruby_extentions(dir)
|
1225
1225
|
Dir.open(dir) {|d|
|
data/tasks/gem.rake
CHANGED
data/tasks/vendor_sqlite3.rake
CHANGED
@@ -17,7 +17,7 @@ def define_sqlite_task(platform, host)
|
|
17
17
|
|
18
18
|
unless File.exist?(checkpoint)
|
19
19
|
cflags = "-O2 -DSQLITE_ENABLE_COLUMN_METADATA"
|
20
|
-
cflags << " -fPIC" if recipe.host.include?("x86_64")
|
20
|
+
cflags << " -fPIC" if recipe.host && recipe.host.include?("x86_64")
|
21
21
|
recipe.configure_options << "CFLAGS='#{cflags}'"
|
22
22
|
recipe.cook
|
23
23
|
touch checkpoint
|
data/test/test_database.rb
CHANGED
@@ -60,6 +60,14 @@ module SQLite3
|
|
60
60
|
assert_equal [[30]], @db.execute("select number from items")
|
61
61
|
end
|
62
62
|
|
63
|
+
def test_batch_last_comment_is_processed
|
64
|
+
# FIXME: nil as a successful return value is kinda dumb
|
65
|
+
assert_nil @db.execute_batch <<-eosql
|
66
|
+
CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT);
|
67
|
+
-- omg
|
68
|
+
eosql
|
69
|
+
end
|
70
|
+
|
63
71
|
def test_new
|
64
72
|
db = SQLite3::Database.new(':memory:')
|
65
73
|
assert db
|
@@ -107,6 +115,15 @@ module SQLite3
|
|
107
115
|
assert_instance_of(SQLite3::Statement, stmt)
|
108
116
|
end
|
109
117
|
|
118
|
+
def test_block_prepare_does_not_double_close
|
119
|
+
db = SQLite3::Database.new(':memory:')
|
120
|
+
r = db.prepare('select "hello world"') do |stmt|
|
121
|
+
stmt.close
|
122
|
+
:foo
|
123
|
+
end
|
124
|
+
assert_equal :foo, r
|
125
|
+
end
|
126
|
+
|
110
127
|
def test_total_changes
|
111
128
|
db = SQLite3::Database.new(':memory:')
|
112
129
|
db.execute("create table foo ( a integer primary key, b text )")
|
data/test/test_encoding.rb
CHANGED
@@ -11,6 +11,38 @@ module SQLite3
|
|
11
11
|
@db.execute(@create);
|
12
12
|
end
|
13
13
|
|
14
|
+
def test_select_encoding_on_utf_16
|
15
|
+
str = "foo"
|
16
|
+
db = SQLite3::Database.new(':memory:'.encode('UTF-16LE'))
|
17
|
+
db.execute @create
|
18
|
+
db.execute "insert into ex (id, data) values (1, \"#{str}\")"
|
19
|
+
|
20
|
+
stmt = db.prepare 'select * from ex where data = ?'
|
21
|
+
['US-ASCII', 'UTF-16LE', 'EUC-JP', 'UTF-8'].each do |enc|
|
22
|
+
stmt.bind_param 1, str.encode(enc)
|
23
|
+
assert_equal 1, stmt.to_a.length
|
24
|
+
stmt.reset!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_insert_encoding
|
29
|
+
str = "foo"
|
30
|
+
db = SQLite3::Database.new(':memory:'.encode('UTF-16LE'))
|
31
|
+
db.execute @create
|
32
|
+
stmt = db.prepare @insert
|
33
|
+
|
34
|
+
['US-ASCII', 'UTF-16LE', 'UTF-16BE', 'EUC-JP', 'UTF-8'].each_with_index do |enc,i|
|
35
|
+
stmt.bind_param 1, i
|
36
|
+
stmt.bind_param 2, str.encode(enc)
|
37
|
+
stmt.to_a
|
38
|
+
stmt.reset!
|
39
|
+
end
|
40
|
+
|
41
|
+
db.execute('select data from ex').flatten.each do |s|
|
42
|
+
assert_equal str, s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
14
46
|
def test_default_internal_is_honored
|
15
47
|
warn_before = $-w
|
16
48
|
$-w = false
|
data/test/test_integration.rb
CHANGED
@@ -21,12 +21,14 @@ class TC_Database_Integration < SQLite3::TestCase
|
|
21
21
|
|
22
22
|
def test_table_info_with_defaults_for_version_3_3_8_and_higher
|
23
23
|
@db.transaction do
|
24
|
-
@db.execute "create table defaults_test ( a string default NULL, b string default 'Hello' )"
|
24
|
+
@db.execute "create table defaults_test ( a string default NULL, b string default 'Hello', c string default '--- []\n' )"
|
25
25
|
data = @db.table_info( "defaults_test" )
|
26
26
|
assert_equal({"name" => "a", "type" => "string", "dflt_value" => nil, "notnull" => 0, "cid" => 0, "pk" => 0},
|
27
27
|
data[0])
|
28
28
|
assert_equal({"name" => "b", "type" => "string", "dflt_value" => "Hello", "notnull" => 0, "cid" => 1, "pk" => 0},
|
29
29
|
data[1])
|
30
|
+
assert_equal({"name" => "c", "type" => "string", "dflt_value" => "--- []\n", "notnull" => 0, "cid" => 2, "pk" => 0},
|
31
|
+
data[2])
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -236,7 +238,7 @@ class TC_Database_Integration < SQLite3::TestCase
|
|
236
238
|
|
237
239
|
def test_execute2_with_block_with_bind_with_match
|
238
240
|
called = 0
|
239
|
-
@db.execute2( "select * from foo where a = ?", 1 ) do
|
241
|
+
@db.execute2( "select * from foo where a = ?", 1 ) do
|
240
242
|
called += 1
|
241
243
|
end
|
242
244
|
assert_equal 2, called
|
@@ -528,21 +530,36 @@ class TC_Database_Integration < SQLite3::TestCase
|
|
528
530
|
assert_equal 0, value
|
529
531
|
end
|
530
532
|
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
533
|
+
class AggregateHandler
|
534
|
+
class << self
|
535
|
+
def arity; 1; end
|
536
|
+
def text_rep; SQLite3::Constants::TextRep::ANY; end
|
537
|
+
def name; "multiply"; end
|
538
|
+
end
|
539
|
+
def step(ctx, a)
|
540
|
+
ctx[:buffer] ||= 1
|
541
|
+
ctx[:buffer] *= a.to_i
|
542
|
+
end
|
543
|
+
def finalize(ctx); ctx.result = ctx[:buffer]; end
|
544
|
+
end
|
545
|
+
|
546
|
+
def test_aggregate_initialized_twice
|
547
|
+
initialized = 0
|
548
|
+
handler = Class.new(AggregateHandler) do
|
549
|
+
define_method(:initialize) do
|
550
|
+
initialized += 1
|
551
|
+
super()
|
541
552
|
end
|
542
|
-
def finalize(ctx); ctx.result = ctx[:buffer]; end
|
543
553
|
end
|
544
554
|
|
545
|
-
@db.create_aggregate_handler
|
555
|
+
@db.create_aggregate_handler handler
|
556
|
+
@db.get_first_value( "select multiply(a) from foo" )
|
557
|
+
@db.get_first_value( "select multiply(a) from foo" )
|
558
|
+
assert_equal 2, initialized
|
559
|
+
end
|
560
|
+
|
561
|
+
def test_create_aggregate_handler
|
562
|
+
@db.create_aggregate_handler AggregateHandler
|
546
563
|
value = @db.get_first_value( "select multiply(a) from foo" )
|
547
564
|
assert_equal 6, value
|
548
565
|
end
|
data/test/test_statement.rb
CHANGED
@@ -30,7 +30,11 @@ module SQLite3
|
|
30
30
|
stmt.execute('ruby')
|
31
31
|
|
32
32
|
exception = assert_raises(SQLite3::ConstraintException) { stmt.execute('ruby') }
|
33
|
-
|
33
|
+
# SQLite 3.8.2 returns new error message:
|
34
|
+
# UNIQUE constraint failed: *table_name*.*column_name*
|
35
|
+
# Older versions of SQLite return:
|
36
|
+
# column *column_name* is not unique
|
37
|
+
assert_match /(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)/, exception.message
|
34
38
|
end
|
35
39
|
|
36
40
|
###
|
metadata
CHANGED
@@ -1,131 +1,114 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlite3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 8
|
10
|
-
version: 1.3.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.9
|
11
5
|
platform: x86-mingw32
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Jamis Buck
|
14
8
|
- Luis Lavena
|
15
9
|
- Aaron Patterson
|
16
10
|
autorequire:
|
17
11
|
bindir: bin
|
18
12
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Dependency
|
23
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 31
|
29
|
-
segments:
|
30
|
-
- 5
|
31
|
-
- 0
|
32
|
-
version: "5.0"
|
33
|
-
name: minitest
|
34
|
-
prerelease: false
|
35
|
-
type: :development
|
36
|
-
requirement: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 27
|
44
|
-
segments:
|
45
|
-
- 4
|
46
|
-
- 0
|
47
|
-
version: "4.0"
|
13
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
48
16
|
name: rdoc
|
49
|
-
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '4.0'
|
50
22
|
type: :development
|
51
|
-
requirement: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 57
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
- 9
|
62
|
-
- 1
|
63
|
-
version: 0.9.1
|
64
|
-
name: rake-compiler
|
65
23
|
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '4.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake-compiler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.9.1
|
66
36
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
hash: 9
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
- 5
|
78
|
-
- 1
|
79
|
-
version: 0.5.1
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.9.1
|
43
|
+
- !ruby/object:Gem::Dependency
|
80
44
|
name: mini_portile
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.5.1
|
50
|
+
type: :development
|
81
51
|
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.5.1
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: minitest
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '5.0'
|
82
64
|
type: :development
|
83
|
-
requirement: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
|
-
requirements:
|
88
|
-
- - ~>
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
hash: 15
|
91
|
-
segments:
|
92
|
-
- 1
|
93
|
-
- 0
|
94
|
-
version: "1.0"
|
95
|
-
name: hoe-bundler
|
96
65
|
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '5.0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: hoe-bundler
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
97
78
|
type: :development
|
98
|
-
requirement: *id005
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
|
-
requirements:
|
103
|
-
- - ~>
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
hash: 9
|
106
|
-
segments:
|
107
|
-
- 3
|
108
|
-
- 7
|
109
|
-
version: "3.7"
|
110
|
-
name: hoe
|
111
79
|
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '1.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: hoe
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '3.9'
|
112
92
|
type: :development
|
113
|
-
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '3.9'
|
114
99
|
description: |-
|
115
100
|
This module allows Ruby programs to interface with the SQLite3
|
116
101
|
database engine (http://www.sqlite.org). You must have the
|
117
102
|
SQLite engine installed in order to build this module.
|
118
|
-
|
103
|
+
|
119
104
|
Note that this module is only compatible with SQLite 3.6.16 or newer.
|
120
|
-
email:
|
105
|
+
email:
|
121
106
|
- jamis@37signals.com
|
122
107
|
- luislavena@gmail.com
|
123
108
|
- aaron@tenderlovemaking.com
|
124
109
|
executables: []
|
125
|
-
|
126
110
|
extensions: []
|
127
|
-
|
128
|
-
extra_rdoc_files:
|
111
|
+
extra_rdoc_files:
|
129
112
|
- API_CHANGES.rdoc
|
130
113
|
- CHANGELOG.rdoc
|
131
114
|
- Manifest.txt
|
@@ -135,7 +118,8 @@ extra_rdoc_files:
|
|
135
118
|
- ext/sqlite3/exception.c
|
136
119
|
- ext/sqlite3/sqlite3.c
|
137
120
|
- ext/sqlite3/statement.c
|
138
|
-
files:
|
121
|
+
files:
|
122
|
+
- ".gemtest"
|
139
123
|
- API_CHANGES.rdoc
|
140
124
|
- CHANGELOG.rdoc
|
141
125
|
- ChangeLog.cvs
|
@@ -158,6 +142,9 @@ files:
|
|
158
142
|
- faq/faq.rb
|
159
143
|
- faq/faq.yml
|
160
144
|
- lib/sqlite3.rb
|
145
|
+
- lib/sqlite3/1.8/sqlite3_native.so
|
146
|
+
- lib/sqlite3/1.9/sqlite3_native.so
|
147
|
+
- lib/sqlite3/2.0/sqlite3_native.so
|
161
148
|
- lib/sqlite3/constants.rb
|
162
149
|
- lib/sqlite3/database.rb
|
163
150
|
- lib/sqlite3/errors.rb
|
@@ -188,49 +175,34 @@ files:
|
|
188
175
|
- test/test_sqlite3.rb
|
189
176
|
- test/test_statement.rb
|
190
177
|
- test/test_statement_execute.rb
|
191
|
-
|
192
|
-
|
193
|
-
-
|
194
|
-
|
195
|
-
homepage: http://github.com/luislavena/sqlite3-ruby
|
196
|
-
licenses:
|
197
|
-
- MIT
|
178
|
+
homepage: https://github.com/sparklemotion/sqlite3-ruby
|
179
|
+
licenses:
|
180
|
+
- BSD-3
|
181
|
+
metadata: {}
|
198
182
|
post_install_message:
|
199
|
-
rdoc_options:
|
200
|
-
- --main
|
183
|
+
rdoc_options:
|
184
|
+
- "--main"
|
201
185
|
- README.rdoc
|
202
|
-
require_paths:
|
186
|
+
require_paths:
|
203
187
|
- lib
|
204
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
-
|
206
|
-
requirements:
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
207
190
|
- - ">="
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
hash: 57
|
210
|
-
segments:
|
211
|
-
- 1
|
212
|
-
- 8
|
213
|
-
- 7
|
191
|
+
- !ruby/object:Gem::Version
|
214
192
|
version: 1.8.7
|
215
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
|
-
|
217
|
-
requirements:
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
218
195
|
- - ">="
|
219
|
-
- !ruby/object:Gem::Version
|
220
|
-
hash: 17
|
221
|
-
segments:
|
222
|
-
- 1
|
223
|
-
- 3
|
224
|
-
- 5
|
196
|
+
- !ruby/object:Gem::Version
|
225
197
|
version: 1.3.5
|
226
198
|
requirements: []
|
227
|
-
|
228
199
|
rubyforge_project: sqlite3
|
229
|
-
rubygems_version:
|
200
|
+
rubygems_version: 2.2.2
|
230
201
|
signing_key:
|
231
|
-
specification_version:
|
232
|
-
summary: This module allows Ruby programs to interface with the SQLite3 database engine
|
233
|
-
|
202
|
+
specification_version: 4
|
203
|
+
summary: This module allows Ruby programs to interface with the SQLite3 database engine
|
204
|
+
(http://www.sqlite.org)
|
205
|
+
test_files:
|
234
206
|
- test/test_backup.rb
|
235
207
|
- test/test_collation.rb
|
236
208
|
- test/test_database.rb
|