do_sqlite3 0.9.7 → 0.9.8
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.
- data/Manifest.txt +1 -1
- data/ext/do_sqlite3_ext.c +26 -7
- data/ext/extconf.rb +6 -0
- data/lib/do_sqlite3.rb +3 -3
- data/lib/{sqlite3.dll → do_sqlite3/sqlite3.dll} +0 -0
- data/lib/do_sqlite3/version.rb +1 -1
- metadata +4 -4
data/Manifest.txt
CHANGED
@@ -8,9 +8,9 @@ TODO
|
|
8
8
|
ext/do_sqlite3_ext.c
|
9
9
|
ext/extconf.rb
|
10
10
|
lib/do_sqlite3.rb
|
11
|
+
lib/do_sqlite3/sqlite3.dll
|
11
12
|
lib/do_sqlite3/transaction.rb
|
12
13
|
lib/do_sqlite3/version.rb
|
13
|
-
lib/sqlite3.dll
|
14
14
|
spec/integration/do_sqlite3_spec.rb
|
15
15
|
spec/integration/logging_spec.rb
|
16
16
|
spec/integration/quoting_spec.rb
|
data/ext/do_sqlite3_ext.c
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#include <ruby.h>
|
2
|
-
#include <version.h>
|
3
2
|
#include <string.h>
|
4
3
|
#include <math.h>
|
5
4
|
#include <time.h>
|
@@ -18,6 +17,18 @@
|
|
18
17
|
|
19
18
|
#define TRUE_CLASS CONST_GET(rb_mKernel, "TrueClass")
|
20
19
|
|
20
|
+
#ifndef RSTRING_PTR
|
21
|
+
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
22
|
+
#endif
|
23
|
+
|
24
|
+
#ifndef RSTRING_LEN
|
25
|
+
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
26
|
+
#endif
|
27
|
+
|
28
|
+
#ifndef RARRAY_LEN
|
29
|
+
#define RARRAY_LEN(a) RARRAY(a)->len
|
30
|
+
#endif
|
31
|
+
|
21
32
|
#ifdef _WIN32
|
22
33
|
#define do_int64 signed __int64
|
23
34
|
#else
|
@@ -39,7 +50,11 @@ static VALUE cDO_Reader;
|
|
39
50
|
|
40
51
|
static VALUE rb_cDate;
|
41
52
|
static VALUE rb_cDateTime;
|
53
|
+
|
54
|
+
#ifndef RUBY_19_COMPATIBILITY
|
42
55
|
static VALUE rb_cRational;
|
56
|
+
#endif
|
57
|
+
|
43
58
|
static VALUE rb_cBigDecimal;
|
44
59
|
|
45
60
|
static VALUE mSqlite3;
|
@@ -404,13 +419,13 @@ static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
|
|
404
419
|
// field_types = rb_ary_new();
|
405
420
|
// }
|
406
421
|
|
407
|
-
if ( field_types == Qnil || 0 ==
|
422
|
+
if ( field_types == Qnil || 0 == RARRAY_LEN(field_types) ) {
|
408
423
|
field_types = rb_ary_new();
|
409
|
-
} else if (
|
424
|
+
} else if (RARRAY_LEN(field_types) != field_count) {
|
410
425
|
// Whoops... wrong number of types passed to set_types. Close the reader and raise
|
411
426
|
// and error
|
412
427
|
rb_funcall(reader, rb_intern("close"), 0);
|
413
|
-
rb_raise(eSqlite3Error, "Field-count mismatch. Expected %
|
428
|
+
rb_raise(eSqlite3Error, "Field-count mismatch. Expected %ld fields, but the query yielded %d", RARRAY_LEN(field_types), field_count);
|
414
429
|
}
|
415
430
|
|
416
431
|
|
@@ -454,7 +469,7 @@ static VALUE cReader_next(VALUE self) {
|
|
454
469
|
field_count = NUM2INT(rb_iv_get(self, "@field_count"));
|
455
470
|
|
456
471
|
field_types = rb_iv_get(self, "@field_types");
|
457
|
-
ft_length =
|
472
|
+
ft_length = RARRAY_LEN(field_types);
|
458
473
|
|
459
474
|
result = sqlite3_step(reader);
|
460
475
|
|
@@ -469,7 +484,7 @@ static VALUE cReader_next(VALUE self) {
|
|
469
484
|
value = native_typecast(sqlite3_column_value(reader, i), sqlite3_column_type(reader, i));
|
470
485
|
}
|
471
486
|
else {
|
472
|
-
value = ruby_typecast(sqlite3_column_value(reader, i), rb_class2name(
|
487
|
+
value = ruby_typecast(sqlite3_column_value(reader, i), rb_class2name(RARRAY_PTR(field_types)[i]), sqlite3_column_type(reader, i));
|
473
488
|
}
|
474
489
|
rb_ary_push(arr, value);
|
475
490
|
}
|
@@ -508,7 +523,11 @@ void Init_do_sqlite3_ext() {
|
|
508
523
|
|
509
524
|
rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects"));
|
510
525
|
|
511
|
-
|
526
|
+
#ifdef RUBY_LESS_THAN_186
|
527
|
+
ID_NEW_DATE = rb_intern("new0");
|
528
|
+
#else
|
529
|
+
ID_NEW_DATE = rb_intern("new!");
|
530
|
+
#endif
|
512
531
|
ID_LOGGER = rb_intern("logger");
|
513
532
|
ID_DEBUG = rb_intern("debug");
|
514
533
|
ID_LEVEL = rb_intern("level");
|
data/ext/extconf.rb
CHANGED
@@ -28,6 +28,12 @@ dir_config("sqlite3")
|
|
28
28
|
# NOTE: use GCC flags unless Visual C compiler is used
|
29
29
|
$CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/
|
30
30
|
|
31
|
+
if RUBY_VERSION < '1.8.6'
|
32
|
+
$CFLAGS << ' -DRUBY_LESS_THAN_186'
|
33
|
+
elsif RUBY_VERSION >= '1.9.0'
|
34
|
+
$CFLAGS << ' -DRUBY_19_COMPATIBILITY'
|
35
|
+
end
|
36
|
+
|
31
37
|
# Do the work
|
32
38
|
# create_makefile(extension_name)
|
33
39
|
if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
|
data/lib/do_sqlite3.rb
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
# of the actual extension file.
|
5
5
|
if RUBY_PLATFORM.match(/mingw|mswin/i)
|
6
6
|
libdir = File.expand_path(File.dirname(__FILE__)).gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
7
|
-
ENV['PATH'] = "
|
7
|
+
ENV['PATH'] = File.join(libdir, "do_sqlite3;") + ENV['PATH']
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'rubygems'
|
11
11
|
require 'data_objects'
|
12
|
-
require 'do_sqlite3_ext'
|
13
|
-
require 'do_sqlite3
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3_ext.bundle'))
|
13
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3', 'transaction'))
|
File without changes
|
data/lib/do_sqlite3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do_sqlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernerd Schaefer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-24 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.8
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
@@ -54,9 +54,9 @@ files:
|
|
54
54
|
- ext/do_sqlite3_ext.c
|
55
55
|
- ext/extconf.rb
|
56
56
|
- lib/do_sqlite3.rb
|
57
|
+
- lib/do_sqlite3/sqlite3.dll
|
57
58
|
- lib/do_sqlite3/transaction.rb
|
58
59
|
- lib/do_sqlite3/version.rb
|
59
|
-
- lib/sqlite3.dll
|
60
60
|
- spec/integration/do_sqlite3_spec.rb
|
61
61
|
- spec/integration/logging_spec.rb
|
62
62
|
- spec/integration/quoting_spec.rb
|