do_sqlite3 0.9.12-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,18 @@
1
- == 0.9.11 2009-01-19
1
+ ## 0.10.0 2009-10-15
2
+ * Improvements
3
+ * JRuby Support (using *do_jdbc*)
4
+
5
+ ## 0.9.12 2009-05-17
6
+ * Improvements
7
+ * rake-compiler for Windows support
8
+
9
+ ## 0.9.11 2009-01-19
2
10
  * Improvements
3
11
  * Ruby 1.9 support
4
12
  * Fixes
5
13
  * Fix Windows gem
6
14
 
7
- == 0.9.9 2008-11-27
15
+ ## 0.9.9 2008-11-27
8
16
  * Improvements
9
17
  * Added cross compile rake tasks for Windows gems [Jonathan Stott, Luis Lavena]
10
18
  * Added initial support for Ruby 1.9 [John Harrison]
data/Manifest.txt CHANGED
@@ -1,8 +1,8 @@
1
1
  .gitignore
2
- History.txt
2
+ HISTORY.markdown
3
3
  LICENSE
4
4
  Manifest.txt
5
- README.txt
5
+ README.markdown
6
6
  Rakefile
7
7
  buildfile
8
8
  ext-java/src/main/java/DoSqlite3ExtService.java
@@ -1,3 +1,4 @@
1
- = do_sqlite3
1
+ do_sqlite3
2
+ ==========
2
3
 
3
4
  A DataObjects driver for SQLite3
data/Rakefile CHANGED
@@ -8,9 +8,9 @@ require 'lib/do_sqlite3/version'
8
8
  ROOT = Pathname(__FILE__).dirname.expand_path
9
9
  JRUBY = RUBY_PLATFORM =~ /java/
10
10
  WINDOWS = Gem.win_platform?
11
- SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
11
+ SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
12
12
  BINARY_VERSION = '3_6_13'
13
13
 
14
- Dir['tasks/*.rake'].each { |f| import f }
14
+ Dir['tasks/*.rake'].sort.each { |f| import f }
15
15
 
16
16
  CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_sqlite3_ext/Makefile ext-java/target ])
data/lib/do_sqlite3.rb CHANGED
@@ -1,35 +1,36 @@
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
1
  require 'data_objects'
11
2
  if RUBY_PLATFORM =~ /java/
12
3
  require 'do_jdbc'
13
4
  require 'java'
14
- gem 'jdbc-sqlite3'
15
- require 'jdbc/sqlite3' # the JDBC driver, packaged as a gem
5
+
6
+ driver = 'org.sqlite.JDBC'
7
+ begin
8
+ java.lang.Thread.currentThread.getContextClassLoader().loadClass(driver, true)
9
+ rescue
10
+ require 'jdbc/sqlite3' # the JDBC driver, packaged as a gem
11
+ end
12
+
13
+ # Another way of loading the JDBC Class. This seems to be more reliable
14
+ # than Class.forName() or
15
+ # Thread.currentThread.getContextClassLoader().loadClass() within the
16
+ # data_objects.Connection Java class, which is currently not working as
17
+ # expected.
18
+ java_import driver
16
19
  end
17
20
 
18
21
  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'))
22
+ require 'do_sqlite3/version'
23
+ require 'do_sqlite3/transaction'
21
24
 
22
25
  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
26
 
28
27
  module DataObjects
29
28
  module Sqlite3
30
29
  class Connection
31
30
  def self.pool_size
32
- 20
31
+ # sqlite3 can have only one write access at a time, with this
32
+ # concurrent write access will result in "Database locked" errors
33
+ 1
33
34
  end
34
35
  end
35
36
  end
@@ -5,28 +5,20 @@ module DataObjects
5
5
 
6
6
  class Transaction < DataObjects::Transaction
7
7
 
8
- def begin
9
- cmd = "BEGIN"
10
- connection.create_command(cmd).execute_non_query
8
+ def begin_prepared
9
+ raise NotImplementedError
11
10
  end
12
11
 
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
12
+ def commit_prepared
13
+ raise NotImplementedError
21
14
  end
22
15
 
23
16
  def rollback_prepared
24
- cmd = "ROLLBACK"
25
- connection.create_command(cmd).execute_non_query
17
+ raise NotImplementedError
26
18
  end
27
19
 
28
20
  def prepare
29
- # Eek, I don't know how to do this. Lets hope a commit arrives soon...
21
+ raise NotImplementedError
30
22
  end
31
23
 
32
24
  end
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Sqlite3
3
- VERSION = "0.9.12"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
Binary file
data/spec/result_spec.rb CHANGED
@@ -3,7 +3,17 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
4
  require 'data_objects/spec/result_spec'
5
5
 
6
+ # splitting the descibe into two separate declaration avoids
7
+ # concurrent execution of the "it_should_behave_like ....." calls
8
+ # which would lock the database
9
+
10
+ # TODO
11
+ # the locked database created a deadlock which is worth exploring since
12
+ # such situation could appear in the wild too
6
13
  describe DataObjects::Sqlite3::Result do
7
14
  it_should_behave_like 'a Result'
15
+ end
16
+
17
+ describe DataObjects::Sqlite3::Result do
8
18
  it_should_behave_like 'a Result which returns inserted keys'
9
19
  end
data/spec/spec_helper.rb CHANGED
@@ -11,21 +11,24 @@ require 'ostruct'
11
11
  require 'pathname'
12
12
  require 'fileutils'
13
13
 
14
+ dir = File.dirname(__FILE__)
15
+ lib_path = File.expand_path("#{dir}/../lib")
16
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
14
17
  # put data_objects from repository in the load path
15
18
  # 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 }
19
+ do_lib_path = File.expand_path("#{dir}/../../data_objects/lib")
20
+ $LOAD_PATH.unshift do_lib_path unless $LOAD_PATH.include?(do_lib_path)
21
21
 
22
22
  if JRUBY
23
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
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)
24
25
  require 'do_jdbc'
25
26
  end
26
27
 
27
- # put the pre-compiled extension in the path to be found
28
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
28
+ 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 }
29
32
  require 'do_sqlite3'
30
33
 
31
34
  log_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log', 'do.log'))
@@ -79,6 +82,8 @@ module DataObjectsSpecHelpers
79
82
  );
80
83
  EOF
81
84
 
85
+ local_offset = Rational(Time.local(2008, 2, 14).utc_offset, 86400)
86
+ t = DateTime.civil(2008, 2, 14, 00, 31, 12, local_offset)
82
87
  conn.create_command(<<-EOF).execute_non_query
83
88
  CREATE TABLE "widgets" (
84
89
  "id" INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -91,7 +96,7 @@ module DataObjectsSpecHelpers
91
96
  "ad_image" blob NULL,
92
97
  "whitepaper_text" text NULL,
93
98
  "cad_drawing" blob,
94
- "flags" char default 'f',
99
+ "flags" boolean default 'f',
95
100
  "number_in_stock" smallint default 500,
96
101
  "number_sold" integer default 0,
97
102
  "super_number" bigint default 9223372036854775807,
@@ -99,7 +104,7 @@ module DataObjectsSpecHelpers
99
104
  "cost1" double precision default 10.23,
100
105
  "cost2" decimal(8,2) default 50.23,
101
106
  "release_date" date default '2008-02-14',
102
- "release_datetime" timestamp default '2008-02-14T00:31:12+00:00',
107
+ "release_datetime" timestamp default '#{t.to_s}',
103
108
  "release_timestamp" timestamp with time zone default '2008-02-14 00:31:31'
104
109
  );
105
110
  EOF
@@ -118,6 +123,30 @@ module DataObjectsSpecHelpers
118
123
  update widgets set ad_description = NULL where id = 3
119
124
  EOF
120
125
 
126
+ conn.create_command(<<-EOF).execute_non_query
127
+ update widgets set flags = NULL where id = 4
128
+ EOF
129
+
130
+ conn.create_command(<<-EOF).execute_non_query
131
+ update widgets set cost1 = NULL where id = 5
132
+ EOF
133
+
134
+ conn.create_command(<<-EOF).execute_non_query
135
+ update widgets set cost2 = NULL where id = 6
136
+ EOF
137
+
138
+ conn.create_command(<<-EOF).execute_non_query
139
+ update widgets set release_date = NULL where id = 7
140
+ EOF
141
+
142
+ conn.create_command(<<-EOF).execute_non_query
143
+ update widgets set release_datetime = NULL where id = 8
144
+ EOF
145
+
146
+ conn.create_command(<<-EOF).execute_non_query
147
+ update widgets set release_timestamp = NULL where id = 9
148
+ EOF
149
+
121
150
  conn.close
122
151
  end
123
152
 
@@ -3,6 +3,9 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
4
  require 'data_objects/spec/typecast/bigdecimal_spec'
5
5
 
6
+ # Sqlite3 doesn't support decimals natively, so autocasting is not available:
7
+ # http://www.sqlite.org/datatype3.html
8
+
6
9
  describe 'DataObjects::Sqlite3 with BigDecimal' do
7
10
  it_should_behave_like 'supporting BigDecimal'
8
11
  end
@@ -3,6 +3,9 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
4
  require 'data_objects/spec/typecast/boolean_spec'
5
5
 
6
+ # Sqlite3 doesn't support booleans natively, so autocasting is not available:
7
+ # http://www.sqlite.org/datatype3.html
8
+
6
9
  describe 'DataObjects::Sqlite3 with Boolean' do
7
10
  it_should_behave_like 'supporting Boolean'
8
11
  end
@@ -3,6 +3,9 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
4
  require 'data_objects/spec/typecast/date_spec'
5
5
 
6
+ # Sqlite3 doesn't support dates natively, so autocasting is not available:
7
+ # http://www.sqlite.org/datatype3.html
8
+
6
9
  describe 'DataObjects::Sqlite3 with Date' do
7
10
  it_should_behave_like 'supporting Date'
8
11
  end
@@ -3,6 +3,9 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
4
  require 'data_objects/spec/typecast/datetime_spec'
5
5
 
6
+ # Sqlite3 doesn't support datetimes natively, so autocasting is not available:
7
+ # http://www.sqlite.org/datatype3.html
8
+
6
9
  describe 'DataObjects::Sqlite3 with DateTime' do
7
10
  it_should_behave_like 'supporting DateTime'
8
11
  end
@@ -6,3 +6,7 @@ require 'data_objects/spec/typecast/float_spec'
6
6
  describe 'DataObjects::Sqlite3 with Float' do
7
7
  it_should_behave_like 'supporting Float'
8
8
  end
9
+
10
+ describe 'DataObjects::Sqlite3 with Float' do
11
+ it_should_behave_like 'supporting Float autocasting'
12
+ end
@@ -3,8 +3,18 @@
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
4
  require 'data_objects/spec/typecast/nil_spec'
5
5
 
6
+ # splitting the descibe into two separate declaration avoids
7
+ # concurrent execution of the "it_should_behave_like ....." calls
8
+ # which would lock the database
9
+
6
10
  describe 'DataObjects::Sqlite3 with Nil' do
7
11
  it_should_behave_like 'supporting Nil'
8
- # it_should_behave_like 'supporting writing an Nil'
12
+ end
13
+
14
+ describe 'DataObjects::Sqlite3 with Nil' do
15
+ it_should_behave_like 'supporting writing an Nil'
16
+ end
17
+
18
+ describe 'DataObjects::Sqlite3 with Nil' do
9
19
  it_should_behave_like 'supporting Nil autocasting'
10
20
  end
data/tasks/gem.rake CHANGED
@@ -1,61 +1,8 @@
1
1
  require 'rubygems/package_task'
2
2
 
3
- GEM_SPEC = Gem::Specification.new do |s|
4
- # basic information
5
- s.name = "do_sqlite3"
6
- s.version = DataObjects::Sqlite3::VERSION
7
-
8
- # description and details
9
- s.summary = 'DataObjects Sqlite3 Driver'
10
- s.description = "Implements the DataObjects API for Sqlite3"
11
-
12
- # dependencies
13
- s.add_dependency "addressable", "~>2.0.0"
14
- s.add_dependency "extlib", "~>0.9.12"
15
- s.add_dependency "data_objects", DataObjects::Sqlite3::VERSION
16
-
17
- if JRUBY
18
- s.add_dependency "jdbc-sqlite3", ">=3.5.8"
19
- s.add_dependency "do_jdbc", DataObjects::Sqlite3::VERSION
20
- s.platform = "java"
21
- # components, files and paths
22
- s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
23
- "LICENSE", "Rakefile", "*.{rdoc,txt,yml}", "lib/*.jar"]
24
- else
25
- s.platform = Gem::Platform::RUBY
26
- s.extensions << 'ext/do_sqlite3_ext/extconf.rb'
27
- # components, files and paths
28
- s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake", "ext/**/*.{rb,c}",
29
- "LICENSE", "Rakefile", "*.{rdoc,txt,yml}"]
30
- end
31
-
32
- # development dependencies
33
- s.add_development_dependency 'rspec', '~>1.2.0'
34
-
35
-
36
- s.require_path = 'lib'
37
-
38
- # documentation
39
- s.has_rdoc = false
40
-
41
- # project information
42
- s.homepage = 'http://github.com/datamapper/do'
43
- s.rubyforge_project = 'dorb'
44
-
45
- # author and contributors
46
- s.author = 'Dirkjan Bussink'
47
- s.email = 'd.bussink@gmail.com'
48
- end
3
+ GEM_SPEC = eval(File.read('do_sqlite3.gemspec'))
49
4
 
50
5
  gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
51
6
  pkg.need_tar = false
52
7
  pkg.need_zip = false
53
8
  end
54
-
55
- file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
56
- puts "Generating #{t.name}"
57
- File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
58
- end
59
-
60
- desc "Generate or update the standalone gemspec file for the project"
61
- task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
data/tasks/release.rake CHANGED
@@ -8,7 +8,7 @@ end
8
8
  if defined?(RubyForge) then
9
9
  if defined?(GEM_SPEC) then
10
10
  desc 'Package and upload to RubyForge'
11
- task :release => [:package] do |t|
11
+ task :release do |t|
12
12
  ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
13
13
 
14
14
  # compare versions to avoid mistakes
@@ -26,19 +26,19 @@ if defined?(RubyForge) then
26
26
 
27
27
  # read project info and overview
28
28
  notes = begin
29
- r = File.read("README.rdoc")
30
- r.split(/^(=+ .*)/)[1..4].join.strip
29
+ r = File.read("README.markdown")
30
+ r.split(/^(.*\n\-+)/)[1..4].join.strip
31
31
  rescue
32
- warn "Missing README.rdoc"
32
+ warn "Missing README.markdown"
33
33
  ''
34
34
  end
35
35
 
36
36
  # read changes
37
37
  changes = begin
38
- h = File.read("History.txt")
39
- h.split(/^(==+ .*)/)[1..2].join.strip
38
+ h = File.read("HISTORY.markdown")
39
+ h.split(/^(##+ .*)/)[1..2].join.strip
40
40
  rescue
41
- warn "Missing History.txt"
41
+ warn "Missing HISTORY.markdown"
42
42
  ''
43
43
  end
44
44
 
data/tasks/retrieve.rake CHANGED
@@ -36,7 +36,7 @@ begin
36
36
  url = "http://www.sqlite.org/#{File.basename(t.name)}"
37
37
  when_writing "downloading #{t.name}" do
38
38
  cd File.dirname(t.name) do
39
- system "wget -c #{url} || curl -C - -O #{url}"
39
+ system "wget -c #{url} || curl -L -C - -O #{url}"
40
40
  end
41
41
  end
42
42
  end
@@ -46,7 +46,7 @@ begin
46
46
  url = "http://www.sqlite.org/#{File.basename(t.name)}"
47
47
  when_writing "downloading #{t.name}" do
48
48
  cd File.dirname(t.name) do
49
- system "wget -c #{url} || curl -C - -O #{url}"
49
+ system "wget -c #{url} || curl -L -C - -O #{url}"
50
50
  end
51
51
  end
52
52
  end
data/tasks/spec.rake CHANGED
@@ -5,6 +5,7 @@ desc 'Run specifications'
5
5
  Spec::Rake::SpecTask.new(:spec => [ :clean, :compile ]) do |t|
6
6
  t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
7
7
  t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
8
+ t.libs << 'lib'
8
9
 
9
10
  begin
10
11
  # RCov is run by default, except on the JRuby platform
metadata CHANGED
@@ -57,9 +57,9 @@ files:
57
57
  - tasks/spec.rake
58
58
  - LICENSE
59
59
  - Rakefile
60
- - History.txt
60
+ - HISTORY.markdown
61
+ - README.markdown
61
62
  - Manifest.txt
62
- - README.txt
63
63
  - lib/do_sqlite3_ext.jar
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -69,17 +69,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version:
70
70
  extensions: []
71
71
 
72
- rubygems_version: 1.3.2
72
+ rubygems_version: 1.3.3
73
73
  requirements: []
74
74
 
75
75
  authors:
76
76
  - Dirkjan Bussink
77
- date: 2009-05-16 22:00:00 +00:00
77
+ date: 2009-09-19 22:00:00 +00:00
78
78
  platform: java
79
79
  test_files: []
80
80
 
81
81
  version: !ruby/object:Gem::Version
82
- version: 0.9.12
82
+ version: 0.10.0
83
83
  require_paths:
84
84
  - lib
85
85
  dependencies:
@@ -88,7 +88,7 @@ dependencies:
88
88
  requirements:
89
89
  - - ~>
90
90
  - !ruby/object:Gem::Version
91
- version: 2.0.0
91
+ version: "2.0"
92
92
  version:
93
93
  type: :runtime
94
94
  version_requirement:
@@ -108,7 +108,7 @@ dependencies:
108
108
  requirements:
109
109
  - - "="
110
110
  - !ruby/object:Gem::Version
111
- version: 0.9.12
111
+ version: 0.10.0
112
112
  version:
113
113
  type: :runtime
114
114
  version_requirement:
@@ -128,7 +128,7 @@ dependencies:
128
128
  requirements:
129
129
  - - "="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.9.12
131
+ version: 0.10.0
132
132
  version:
133
133
  type: :runtime
134
134
  version_requirement:
@@ -144,4 +144,4 @@ dependencies:
144
144
  version_requirement:
145
145
  name: rspec
146
146
  bindir: bin
147
- has_rdoc: false
147
+ has_rdoc: true