do_sqlite3 0.9.12-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -0
- data/LICENSE +20 -0
- data/Manifest.txt +31 -0
- data/README.txt +3 -0
- data/Rakefile +16 -0
- data/ext/do_sqlite3_ext/do_sqlite3_ext.c +706 -0
- data/ext/do_sqlite3_ext/extconf.rb +42 -0
- data/lib/do_sqlite3.rb +38 -0
- data/lib/do_sqlite3/transaction.rb +36 -0
- data/lib/do_sqlite3/version.rb +5 -0
- data/lib/do_sqlite3_ext.so +0 -0
- data/spec/command_spec.rb +8 -0
- data/spec/connection_spec.rb +18 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +3 -0
- data/spec/reader_spec.rb +8 -0
- data/spec/result_spec.rb +9 -0
- data/spec/spec_helper.rb +124 -0
- data/spec/typecast/array_spec.rb +8 -0
- data/spec/typecast/bigdecimal_spec.rb +8 -0
- data/spec/typecast/boolean_spec.rb +8 -0
- data/spec/typecast/byte_array_spec.rb +9 -0
- data/spec/typecast/class_spec.rb +8 -0
- data/spec/typecast/date_spec.rb +8 -0
- data/spec/typecast/datetime_spec.rb +8 -0
- data/spec/typecast/float_spec.rb +8 -0
- data/spec/typecast/integer_spec.rb +8 -0
- data/spec/typecast/nil_spec.rb +10 -0
- data/spec/typecast/range_spec.rb +8 -0
- data/spec/typecast/string_spec.rb +8 -0
- data/spec/typecast/time_spec.rb +8 -0
- data/tasks/gem.rake +61 -0
- data/tasks/install.rake +15 -0
- data/tasks/native.rake +35 -0
- data/tasks/release.rake +75 -0
- data/tasks/retrieve.rake +104 -0
- data/tasks/spec.rake +18 -0
- metadata +129 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# ENV["RC_ARCHS"] = `uname -m`.chomp if `uname -sr` =~ /^Darwin/
|
2
|
+
#
|
3
|
+
# require 'mkmf'
|
4
|
+
#
|
5
|
+
# SWIG_WRAP = "sqlite3_api_wrap.c"
|
6
|
+
#
|
7
|
+
# dir_config( "sqlite3", "/usr/local" )
|
8
|
+
#
|
9
|
+
# if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
|
10
|
+
# create_makefile( "sqlite3_c" )
|
11
|
+
# end
|
12
|
+
|
13
|
+
if RUBY_PLATFORM =~ /darwin/
|
14
|
+
ENV["RC_ARCHS"] = `uname -m`.chomp if `uname -sr` =~ /^Darwin/
|
15
|
+
|
16
|
+
# On PowerPC the defaults are fine
|
17
|
+
ENV["RC_ARCHS"] = '' if `uname -m` =~ /^Power Macintosh/
|
18
|
+
end
|
19
|
+
|
20
|
+
# Loads mkmf which is used to make makefiles for Ruby extensions
|
21
|
+
require 'mkmf'
|
22
|
+
|
23
|
+
# Give it a name
|
24
|
+
extension_name = 'do_sqlite3_ext'
|
25
|
+
|
26
|
+
dir_config("sqlite3")
|
27
|
+
|
28
|
+
# NOTE: use GCC flags unless Visual C compiler is used
|
29
|
+
$CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/
|
30
|
+
|
31
|
+
if RUBY_VERSION < '1.8.6'
|
32
|
+
$CFLAGS << ' -DRUBY_LESS_THAN_186'
|
33
|
+
end
|
34
|
+
|
35
|
+
# Do the work
|
36
|
+
# create_makefile(extension_name)
|
37
|
+
if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
|
38
|
+
have_func("sqlite3_prepare_v2")
|
39
|
+
have_func("sqlite3_open_v2")
|
40
|
+
|
41
|
+
create_makefile(extension_name)
|
42
|
+
end
|
data/lib/do_sqlite3.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# HACK: If running on Windows, then add the current directory to the PATH
|
2
|
+
# for the current process so it can find the bundled dlls before the require
|
3
|
+
# of the actual extension file.
|
4
|
+
if RUBY_PLATFORM.match(/mingw|mswin/i)
|
5
|
+
libdir = File.expand_path(File.dirname(__FILE__)).gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
6
|
+
ENV['PATH'] = "#{libdir};" + ENV['PATH']
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rubygems'
|
10
|
+
require 'data_objects'
|
11
|
+
if RUBY_PLATFORM =~ /java/
|
12
|
+
require 'do_jdbc'
|
13
|
+
require 'java'
|
14
|
+
gem 'jdbc-sqlite3'
|
15
|
+
require 'jdbc/sqlite3' # the JDBC driver, packaged as a gem
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'do_sqlite3_ext'
|
19
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3', 'version'))
|
20
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3', 'transaction'))
|
21
|
+
|
22
|
+
if RUBY_PLATFORM =~ /java/
|
23
|
+
# Another way of loading the JDBC Class. This seems to be more reliable
|
24
|
+
# than Class.forName() within the data_objects.Connection Java class,
|
25
|
+
# which is currently not working as expected.
|
26
|
+
import 'org.sqlite.JDBC'
|
27
|
+
|
28
|
+
module DataObjects
|
29
|
+
module Sqlite3
|
30
|
+
class Connection
|
31
|
+
def self.pool_size
|
32
|
+
20
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
module DataObjects
|
3
|
+
|
4
|
+
module Sqlite3
|
5
|
+
|
6
|
+
class Transaction < DataObjects::Transaction
|
7
|
+
|
8
|
+
def begin
|
9
|
+
cmd = "BEGIN"
|
10
|
+
connection.create_command(cmd).execute_non_query
|
11
|
+
end
|
12
|
+
|
13
|
+
def commit
|
14
|
+
cmd = "COMMIT"
|
15
|
+
connection.create_command(cmd).execute_non_query
|
16
|
+
end
|
17
|
+
|
18
|
+
def rollback
|
19
|
+
cmd = "ROLLBACK"
|
20
|
+
connection.create_command(cmd).execute_non_query
|
21
|
+
end
|
22
|
+
|
23
|
+
def rollback_prepared
|
24
|
+
cmd = "ROLLBACK"
|
25
|
+
connection.create_command(cmd).execute_non_query
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepare
|
29
|
+
# Eek, I don't know how to do this. Lets hope a commit arrives soon...
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
+
require 'data_objects/spec/connection_spec'
|
5
|
+
|
6
|
+
describe DataObjects::Sqlite3::Connection do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@driver = CONFIG.scheme
|
10
|
+
@user = CONFIG.user
|
11
|
+
@password = CONFIG.pass
|
12
|
+
@host = CONFIG.host
|
13
|
+
@port = CONFIG.port
|
14
|
+
@database = CONFIG.database
|
15
|
+
end
|
16
|
+
|
17
|
+
it_should_behave_like 'a Connection'
|
18
|
+
end
|
data/spec/reader_spec.rb
ADDED
data/spec/result_spec.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
+
require 'data_objects/spec/result_spec'
|
5
|
+
|
6
|
+
describe DataObjects::Sqlite3::Result do
|
7
|
+
it_should_behave_like 'a Result'
|
8
|
+
it_should_behave_like 'a Result which returns inserted keys'
|
9
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
$TESTING=true
|
2
|
+
JRUBY = RUBY_PLATFORM =~ /java/
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
gem 'rspec', '>1.1.12'
|
7
|
+
require 'spec'
|
8
|
+
|
9
|
+
require 'date'
|
10
|
+
require 'ostruct'
|
11
|
+
require 'pathname'
|
12
|
+
require 'fileutils'
|
13
|
+
|
14
|
+
# put data_objects from repository in the load path
|
15
|
+
# DO NOT USE installed gem of data_objects!
|
16
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data_objects', 'lib'))
|
17
|
+
require 'data_objects'
|
18
|
+
|
19
|
+
DATAOBJECTS_SPEC_ROOT = Pathname(__FILE__).dirname.parent.parent + 'data_objects' + 'spec'
|
20
|
+
Pathname.glob((DATAOBJECTS_SPEC_ROOT + 'lib/**/*.rb').to_s).each { |f| require f }
|
21
|
+
|
22
|
+
if JRUBY
|
23
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
|
24
|
+
require 'do_jdbc'
|
25
|
+
end
|
26
|
+
|
27
|
+
# put the pre-compiled extension in the path to be found
|
28
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
29
|
+
require 'do_sqlite3'
|
30
|
+
|
31
|
+
log_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log', 'do.log'))
|
32
|
+
FileUtils.mkdir_p(File.dirname(log_path))
|
33
|
+
|
34
|
+
DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, :debug)
|
35
|
+
|
36
|
+
at_exit { DataObjects.logger.flush }
|
37
|
+
|
38
|
+
Spec::Runner.configure do |config|
|
39
|
+
config.include(DataObjects::Spec::PendingHelpers)
|
40
|
+
end
|
41
|
+
|
42
|
+
CONFIG = OpenStruct.new
|
43
|
+
CONFIG.scheme = 'sqlite3'
|
44
|
+
CONFIG.database = ENV['DO_SQLITE3_DATABASE'] || "#{File.expand_path(File.dirname(__FILE__))}/test.db"
|
45
|
+
|
46
|
+
CONFIG.uri = ENV["DO_SQLITE3_SPEC_URI"] || "#{CONFIG.scheme}://#{CONFIG.database}"
|
47
|
+
|
48
|
+
module DataObjectsSpecHelpers
|
49
|
+
|
50
|
+
def setup_test_environment
|
51
|
+
conn = DataObjects::Connection.new(CONFIG.uri)
|
52
|
+
|
53
|
+
conn.create_command(<<-EOF).execute_non_query
|
54
|
+
DROP TABLE IF EXISTS "invoices"
|
55
|
+
EOF
|
56
|
+
|
57
|
+
conn.create_command(<<-EOF).execute_non_query
|
58
|
+
DROP TABLE IF EXISTS "users"
|
59
|
+
EOF
|
60
|
+
|
61
|
+
conn.create_command(<<-EOF).execute_non_query
|
62
|
+
DROP TABLE IF EXISTS "widgets"
|
63
|
+
EOF
|
64
|
+
|
65
|
+
conn.create_command(<<-EOF).execute_non_query
|
66
|
+
CREATE TABLE "users" (
|
67
|
+
"id" SERIAL,
|
68
|
+
"name" VARCHAR(200) default 'Billy' NULL,
|
69
|
+
"fired_at" timestamp,
|
70
|
+
PRIMARY KEY ("id")
|
71
|
+
);
|
72
|
+
EOF
|
73
|
+
|
74
|
+
conn.create_command(<<-EOF).execute_non_query
|
75
|
+
CREATE TABLE "invoices" (
|
76
|
+
"id" SERIAL,
|
77
|
+
"invoice_number" varchar(50) NOT NULL,
|
78
|
+
PRIMARY KEY ("id")
|
79
|
+
);
|
80
|
+
EOF
|
81
|
+
|
82
|
+
conn.create_command(<<-EOF).execute_non_query
|
83
|
+
CREATE TABLE "widgets" (
|
84
|
+
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
85
|
+
"code" char(8) default 'A14' NULL,
|
86
|
+
"name" varchar(200) default 'Super Widget' NULL,
|
87
|
+
"shelf_location" text NULL,
|
88
|
+
"description" text NULL,
|
89
|
+
"image_data" blob NULL,
|
90
|
+
"ad_description" text NULL,
|
91
|
+
"ad_image" blob NULL,
|
92
|
+
"whitepaper_text" text NULL,
|
93
|
+
"cad_drawing" blob,
|
94
|
+
"flags" char default 'f',
|
95
|
+
"number_in_stock" smallint default 500,
|
96
|
+
"number_sold" integer default 0,
|
97
|
+
"super_number" bigint default 9223372036854775807,
|
98
|
+
"weight" float default 1.23,
|
99
|
+
"cost1" double precision default 10.23,
|
100
|
+
"cost2" decimal(8,2) default 50.23,
|
101
|
+
"release_date" date default '2008-02-14',
|
102
|
+
"release_datetime" timestamp default '2008-02-14T00:31:12+00:00',
|
103
|
+
"release_timestamp" timestamp with time zone default '2008-02-14 00:31:31'
|
104
|
+
);
|
105
|
+
EOF
|
106
|
+
|
107
|
+
1.upto(16) do |n|
|
108
|
+
conn.create_command(<<-EOF).execute_non_query
|
109
|
+
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', 'CAD DRAWING', 1234, 13.4);
|
110
|
+
EOF
|
111
|
+
end
|
112
|
+
|
113
|
+
conn.create_command(<<-EOF).execute_non_query
|
114
|
+
update widgets set flags = 't' where id = 2
|
115
|
+
EOF
|
116
|
+
|
117
|
+
conn.create_command(<<-EOF).execute_non_query
|
118
|
+
update widgets set ad_description = NULL where id = 3
|
119
|
+
EOF
|
120
|
+
|
121
|
+
conn.close
|
122
|
+
end
|
123
|
+
|
124
|
+
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/bigdecimal_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Sqlite3 with BigDecimal' do
|
7
|
+
it_should_behave_like 'supporting BigDecimal'
|
8
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/byte_array_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Sqlite3 with ByteArray' do
|
7
|
+
# We need to switch to using parameter binding for this to work with Sqlite3
|
8
|
+
# it_should_behave_like 'supporting ByteArray'
|
9
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/nil_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::Sqlite3 with Nil' do
|
7
|
+
it_should_behave_like 'supporting Nil'
|
8
|
+
# it_should_behave_like 'supporting writing an Nil'
|
9
|
+
it_should_behave_like 'supporting Nil autocasting'
|
10
|
+
end
|