do_sqlite3 0.10.0-java → 0.10.1-java
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/ChangeLog.markdown +32 -0
- data/LICENSE +1 -1
- data/README.markdown +101 -3
- data/Rakefile +56 -9
- data/ext/do_sqlite3/compat.h +55 -0
- data/ext/do_sqlite3/do_sqlite3.c +793 -0
- data/ext/do_sqlite3/error.h +106 -0
- data/ext/do_sqlite3/extconf.rb +26 -0
- data/lib/do_sqlite3.rb +19 -11
- data/lib/do_sqlite3/do_sqlite3.jar +0 -0
- data/lib/do_sqlite3/version.rb +1 -1
- data/spec/command_spec.rb +1 -1
- data/spec/connection_spec.rb +8 -6
- data/spec/reader_spec.rb +1 -1
- data/spec/result_spec.rb +3 -3
- data/spec/spec_helper.rb +19 -32
- data/spec/typecast/array_spec.rb +1 -1
- data/spec/typecast/bigdecimal_spec.rb +1 -1
- data/spec/typecast/boolean_spec.rb +1 -1
- data/spec/typecast/byte_array_spec.rb +1 -2
- data/spec/typecast/class_spec.rb +1 -1
- data/spec/typecast/date_spec.rb +1 -1
- data/spec/typecast/datetime_spec.rb +1 -1
- data/spec/typecast/float_spec.rb +2 -2
- data/spec/typecast/integer_spec.rb +1 -1
- data/spec/typecast/nil_spec.rb +4 -4
- data/spec/typecast/other_spec.rb +8 -0
- data/spec/typecast/range_spec.rb +1 -1
- data/spec/typecast/string_spec.rb +1 -1
- data/spec/typecast/time_spec.rb +1 -1
- data/tasks/compile.rake +64 -0
- data/tasks/release.rake +12 -71
- data/tasks/retrieve.rake +1 -1
- data/tasks/spec.rake +19 -15
- metadata +118 -107
- data/HISTORY.markdown +0 -22
- data/Manifest.txt +0 -31
- data/lib/do_sqlite3_ext.jar +0 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -3
- data/tasks/gem.rake +0 -8
- data/tasks/install.rake +0 -15
- data/tasks/native.rake +0 -35
@@ -0,0 +1,106 @@
|
|
1
|
+
static struct errcodes {
|
2
|
+
int error_no;
|
3
|
+
const char *error_name;
|
4
|
+
const char *exception;
|
5
|
+
} errors [] = {
|
6
|
+
#ifdef SQLITE_ERROR
|
7
|
+
{ SQLITE_ERROR,
|
8
|
+
"SQLITE_ERROR", "SyntaxError"},
|
9
|
+
#endif
|
10
|
+
#ifdef SQLITE_INTERNAL
|
11
|
+
{ SQLITE_INTERNAL,
|
12
|
+
"SQLITE_INTERNAL", "SQLError"},
|
13
|
+
#endif
|
14
|
+
#ifdef SQLITE_PERM
|
15
|
+
{ SQLITE_PERM,
|
16
|
+
"SQLITE_PERM", "ConnectionError"},
|
17
|
+
#endif
|
18
|
+
#ifdef SQLITE_ABORT
|
19
|
+
{ SQLITE_ABORT,
|
20
|
+
"SQLITE_ABORT", "ConnectionError"},
|
21
|
+
#endif
|
22
|
+
#ifdef SQLITE_BUSY
|
23
|
+
{ SQLITE_BUSY,
|
24
|
+
"SQLITE_BUSY", "ConnectionError"},
|
25
|
+
#endif
|
26
|
+
|
27
|
+
#ifdef SQLITE_LOCKED
|
28
|
+
{ SQLITE_LOCKED,
|
29
|
+
"SQLITE_LOCKED", "ConnectionError"},
|
30
|
+
#endif
|
31
|
+
#ifdef SQLITE_NOMEM
|
32
|
+
{ SQLITE_NOMEM,
|
33
|
+
"SQLITE_NOMEM", "ConnectionError"},
|
34
|
+
#endif
|
35
|
+
#ifdef SQLITE_READONLY
|
36
|
+
{ SQLITE_READONLY,
|
37
|
+
"SQLITE_READONLY", "ConnectionError"},
|
38
|
+
#endif
|
39
|
+
#ifdef SQLITE_INTERRUPT
|
40
|
+
{ SQLITE_INTERRUPT,
|
41
|
+
"SQLITE_INTERRUPT", "ConnectionError"},
|
42
|
+
#endif
|
43
|
+
#ifdef SQLITE_IOERR
|
44
|
+
{ SQLITE_IOERR,
|
45
|
+
"SQLITE_IOERR", "ConnectionError"},
|
46
|
+
#endif
|
47
|
+
#ifdef SQLITE_CORRUPT
|
48
|
+
{ SQLITE_CORRUPT,
|
49
|
+
"SQLITE_CORRUPT", "ConnectionError"},
|
50
|
+
#endif
|
51
|
+
#ifdef SQLITE_FULL
|
52
|
+
{ SQLITE_FULL,
|
53
|
+
"SQLITE_FULL", "ConnectionError"},
|
54
|
+
#endif
|
55
|
+
#ifdef SQLITE_CANTOPEN
|
56
|
+
{ SQLITE_CANTOPEN,
|
57
|
+
"SQLITE_CANTOPEN", "ConnectionError"},
|
58
|
+
#endif
|
59
|
+
#ifdef SQLITE_EMPTY
|
60
|
+
{ SQLITE_EMPTY,
|
61
|
+
"SQLITE_EMPTY", "ConnectionError"},
|
62
|
+
#endif
|
63
|
+
#ifdef SQLITE_SCHEMA
|
64
|
+
{ SQLITE_SCHEMA,
|
65
|
+
"SQLITE_SCHEMA", "DataError"},
|
66
|
+
#endif
|
67
|
+
#ifdef SQLITE_TOOBIG
|
68
|
+
{ SQLITE_TOOBIG,
|
69
|
+
"SQLITE_TOOBIG", "DataError"},
|
70
|
+
#endif
|
71
|
+
#ifdef SQLITE_MISMATCH
|
72
|
+
{ SQLITE_MISMATCH,
|
73
|
+
"SQLITE_MISMATCH", "DataError"},
|
74
|
+
#endif
|
75
|
+
#ifdef SQLITE_CONSTRAINT
|
76
|
+
{ SQLITE_CONSTRAINT,
|
77
|
+
"SQLITE_CONSTRAINT", "IntegrityError"},
|
78
|
+
#endif
|
79
|
+
#ifdef SQLITE_MISUSE
|
80
|
+
{ SQLITE_MISUSE,
|
81
|
+
"SQLITE_MISUSE", "SQLError"},
|
82
|
+
#endif
|
83
|
+
|
84
|
+
#ifdef SQLITE_NOLFS
|
85
|
+
{ SQLITE_NOLFS,
|
86
|
+
"SQLITE_NOLFS", "ConnectionError"},
|
87
|
+
#endif
|
88
|
+
#ifdef SQLITE_FORMAT
|
89
|
+
{ SQLITE_FORMAT,
|
90
|
+
"SQLITE_FORMAT", "SyntaxError"},
|
91
|
+
#endif
|
92
|
+
#ifdef SQLITE_RANGE
|
93
|
+
{ SQLITE_RANGE,
|
94
|
+
"SQLITE_RANGE", "DataError"},
|
95
|
+
#endif
|
96
|
+
#ifdef SQLITE_NOTADB
|
97
|
+
{ SQLITE_NOTADB,
|
98
|
+
"SQLITE_NOTADB", "ConnectionError"},
|
99
|
+
#endif
|
100
|
+
|
101
|
+
#ifdef SQLITE_ROW
|
102
|
+
{ SQLITE_ROW,
|
103
|
+
"SQLITE_ROW", "SyntaxError"},
|
104
|
+
#endif
|
105
|
+
{0, NULL, NULL}
|
106
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/
|
2
|
+
|
3
|
+
# Loads mkmf which is used to make makefiles for Ruby extensions
|
4
|
+
require 'mkmf'
|
5
|
+
|
6
|
+
# Allow for custom compiler to be specified.
|
7
|
+
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
8
|
+
|
9
|
+
# Use some default search paths
|
10
|
+
dir_config("sqlite3", ["/usr/local", "/opt/local", "/usr"])
|
11
|
+
|
12
|
+
# NOTE: use GCC flags unless Visual C compiler is used
|
13
|
+
$CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/
|
14
|
+
|
15
|
+
if RUBY_VERSION < '1.8.6'
|
16
|
+
$CFLAGS << ' -DRUBY_LESS_THAN_186'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Do the work
|
20
|
+
# create_makefile(extension_name)
|
21
|
+
if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
|
22
|
+
have_func("sqlite3_prepare_v2")
|
23
|
+
have_func("sqlite3_open_v2")
|
24
|
+
|
25
|
+
create_makefile('do_sqlite3/do_sqlite3')
|
26
|
+
end
|
data/lib/do_sqlite3.rb
CHANGED
@@ -18,22 +18,30 @@ if RUBY_PLATFORM =~ /java/
|
|
18
18
|
java_import driver
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
begin
|
22
|
+
require 'do_sqlite3/do_sqlite3'
|
23
|
+
rescue LoadError
|
24
|
+
if RUBY_PLATFORM =~ /mingw|mswin/ then
|
25
|
+
RUBY_VERSION =~ /(\d+.\d+)/
|
26
|
+
require "do_sqlite3/#{$1}/do_sqlite3"
|
27
|
+
else
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
22
32
|
require 'do_sqlite3/version'
|
23
|
-
require 'do_sqlite3/transaction'
|
33
|
+
require 'do_sqlite3/transaction' if RUBY_PLATFORM !~ /java/
|
24
34
|
|
25
35
|
if RUBY_PLATFORM =~ /java/
|
26
36
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
1
|
34
|
-
end
|
35
|
-
end
|
37
|
+
DataObjects::Sqlite3::Connection.class_eval do
|
38
|
+
|
39
|
+
def self.pool_size
|
40
|
+
# sqlite3 can have only one write access at a time, with this
|
41
|
+
# concurrent write access will result in "Database locked" errors
|
42
|
+
1
|
36
43
|
end
|
44
|
+
|
37
45
|
end
|
38
46
|
|
39
47
|
end
|
Binary file
|
data/lib/do_sqlite3/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
data/spec/connection_spec.rb
CHANGED
@@ -5,14 +5,16 @@ require 'data_objects/spec/connection_spec'
|
|
5
5
|
|
6
6
|
describe DataObjects::Sqlite3::Connection do
|
7
7
|
|
8
|
-
before
|
9
|
-
@driver
|
10
|
-
@user
|
8
|
+
before do
|
9
|
+
@driver = CONFIG.scheme
|
10
|
+
@user = CONFIG.user
|
11
11
|
@password = CONFIG.pass
|
12
|
-
@host
|
13
|
-
@port
|
12
|
+
@host = CONFIG.host
|
13
|
+
@port = CONFIG.port
|
14
14
|
@database = CONFIG.database
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
behaves_like 'a Connection'
|
18
|
+
behaves_like 'a Connection via JDNI' if JRUBY
|
19
|
+
# FIXME: behaves_like 'a Connection with JDBC URL support' if JRUBY
|
18
20
|
end
|
data/spec/reader_spec.rb
CHANGED
data/spec/result_spec.rb
CHANGED
@@ -4,16 +4,16 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/result_spec'
|
5
5
|
|
6
6
|
# splitting the descibe into two separate declaration avoids
|
7
|
-
# concurrent execution of the "
|
7
|
+
# concurrent execution of the "behaves_like ....." calls
|
8
8
|
# which would lock the database
|
9
9
|
|
10
10
|
# TODO
|
11
11
|
# the locked database created a deadlock which is worth exploring since
|
12
12
|
# such situation could appear in the wild too
|
13
13
|
describe DataObjects::Sqlite3::Result do
|
14
|
-
|
14
|
+
behaves_like 'a Result'
|
15
15
|
end
|
16
16
|
|
17
17
|
describe DataObjects::Sqlite3::Result do
|
18
|
-
|
18
|
+
behaves_like 'a Result which returns inserted keys'
|
19
19
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,51 +2,36 @@ $TESTING=true
|
|
2
2
|
JRUBY = RUBY_PLATFORM =~ /java/
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
|
6
|
-
gem 'rspec', '>1.1.12'
|
7
|
-
require 'spec'
|
8
|
-
|
9
5
|
require 'date'
|
10
6
|
require 'ostruct'
|
11
|
-
require 'pathname'
|
12
7
|
require 'fileutils'
|
8
|
+
require 'win32console' if RUBY_PLATFORM =~ /mingw|mswin/
|
9
|
+
|
10
|
+
driver_lib = File.expand_path('../../lib', __FILE__)
|
11
|
+
$LOAD_PATH.unshift(driver_lib) unless $LOAD_PATH.include?(driver_lib)
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
$LOAD_PATH.unshift do_lib_path unless $LOAD_PATH.include?(do_lib_path)
|
21
|
-
|
22
|
-
if JRUBY
|
23
|
-
jdbc_lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
|
24
|
-
$LOAD_PATH.unshift jdbc_lib_path unless $LOAD_PATH.include?(jdbc_lib_path)
|
25
|
-
require 'do_jdbc'
|
13
|
+
# Prepend data_objects/do_jdbc in the repository to the load path.
|
14
|
+
# DO NOT USE installed gems, except when running the specs from gem.
|
15
|
+
repo_root = File.expand_path('../../..', __FILE__)
|
16
|
+
(['data_objects'] << ('do_jdbc' if JRUBY)).compact.each do |lib|
|
17
|
+
lib_path = "#{repo_root}/#{lib}/lib"
|
18
|
+
$LOAD_PATH.unshift(lib_path) if File.directory?(lib_path) && !$LOAD_PATH.include?(lib_path)
|
26
19
|
end
|
27
20
|
|
28
21
|
require 'data_objects'
|
29
|
-
|
30
|
-
DATAOBJECTS_SPEC_ROOT = Pathname(__FILE__).dirname.parent.parent + 'data_objects' + 'spec'
|
31
|
-
Pathname.glob((DATAOBJECTS_SPEC_ROOT + 'lib/**/*.rb').to_s).each { |f| require f }
|
22
|
+
require 'data_objects/spec/bacon'
|
32
23
|
require 'do_sqlite3'
|
33
24
|
|
34
|
-
|
35
|
-
FileUtils.mkdir_p(File.dirname(log_path))
|
36
|
-
|
37
|
-
DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, :debug)
|
38
|
-
|
25
|
+
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, :off)
|
39
26
|
at_exit { DataObjects.logger.flush }
|
40
27
|
|
41
|
-
Spec::Runner.configure do |config|
|
42
|
-
config.include(DataObjects::Spec::PendingHelpers)
|
43
|
-
end
|
44
|
-
|
45
28
|
CONFIG = OpenStruct.new
|
46
29
|
CONFIG.scheme = 'sqlite3'
|
47
|
-
CONFIG.database = ENV['DO_SQLITE3_DATABASE'] || "
|
30
|
+
CONFIG.database = ENV['DO_SQLITE3_DATABASE'] || ":memory:"
|
48
31
|
|
49
|
-
CONFIG.uri = ENV["DO_SQLITE3_SPEC_URI"] || "#{CONFIG.scheme}
|
32
|
+
CONFIG.uri = ENV["DO_SQLITE3_SPEC_URI"] || "#{CONFIG.scheme}:#{CONFIG.database}"
|
33
|
+
CONFIG.jdbc_driver = 'org.sqlite.JDBC'
|
34
|
+
CONFIG.jdbc_uri = CONFIG.uri.sub(/sqlite3/,"jdbc:sqlite")
|
50
35
|
|
51
36
|
module DataObjectsSpecHelpers
|
52
37
|
|
@@ -111,7 +96,7 @@ module DataObjectsSpecHelpers
|
|
111
96
|
|
112
97
|
1.upto(16) do |n|
|
113
98
|
conn.create_command(<<-EOF).execute_non_query
|
114
|
-
insert into widgets(code, name, shelf_location, description, image_data, ad_description, ad_image, whitepaper_text, cad_drawing, super_number, weight) VALUES ('W#{n.to_s.rjust(7,"0")}', 'Widget #{n}', 'A14', 'This is a description', 'IMAGE DATA', 'Buy this product now!', 'AD IMAGE DATA', 'String', '
|
99
|
+
insert into widgets(code, name, shelf_location, description, image_data, ad_description, ad_image, whitepaper_text, cad_drawing, super_number, weight) VALUES ('W#{n.to_s.rjust(7,"0")}', 'Widget #{n}', 'A14', 'This is a description', 'IMAGE DATA', 'Buy this product now!', 'AD IMAGE DATA', 'String', X'434144200120002044524157494e47', 1234, 13.4);
|
115
100
|
EOF
|
116
101
|
end
|
117
102
|
|
@@ -151,3 +136,5 @@ module DataObjectsSpecHelpers
|
|
151
136
|
end
|
152
137
|
|
153
138
|
end
|
139
|
+
|
140
|
+
include DataObjectsSpecHelpers
|
data/spec/typecast/array_spec.rb
CHANGED
@@ -4,6 +4,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/byte_array_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Sqlite3 with ByteArray' do
|
7
|
-
|
8
|
-
# it_should_behave_like 'supporting ByteArray'
|
7
|
+
behaves_like 'supporting ByteArray'
|
9
8
|
end
|
data/spec/typecast/class_spec.rb
CHANGED
data/spec/typecast/date_spec.rb
CHANGED
data/spec/typecast/float_spec.rb
CHANGED
@@ -4,9 +4,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/float_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Sqlite3 with Float' do
|
7
|
-
|
7
|
+
behaves_like 'supporting Float'
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'DataObjects::Sqlite3 with Float' do
|
11
|
-
|
11
|
+
behaves_like 'supporting Float autocasting'
|
12
12
|
end
|
data/spec/typecast/nil_spec.rb
CHANGED
@@ -4,17 +4,17 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/nil_spec'
|
5
5
|
|
6
6
|
# splitting the descibe into two separate declaration avoids
|
7
|
-
# concurrent execution of the "
|
7
|
+
# concurrent execution of the "behaves_like ....." calls
|
8
8
|
# which would lock the database
|
9
9
|
|
10
10
|
describe 'DataObjects::Sqlite3 with Nil' do
|
11
|
-
|
11
|
+
behaves_like 'supporting Nil'
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'DataObjects::Sqlite3 with Nil' do
|
15
|
-
|
15
|
+
behaves_like 'supporting writing an Nil'
|
16
16
|
end
|
17
17
|
|
18
18
|
describe 'DataObjects::Sqlite3 with Nil' do
|
19
|
-
|
19
|
+
behaves_like 'supporting Nil autocasting'
|
20
20
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/other_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::H2 with other (unknown) type' do
|
7
|
+
behaves_like 'supporting other (unknown) type'
|
8
|
+
end
|
data/spec/typecast/range_spec.rb
CHANGED