do_sqlite3 0.9.9-x86-mswin32-60 → 0.9.11-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,12 +30,11 @@ $CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/
30
30
 
31
31
  if RUBY_VERSION < '1.8.6'
32
32
  $CFLAGS << ' -DRUBY_LESS_THAN_186'
33
- elsif RUBY_VERSION >= '1.9.0'
34
- $CFLAGS << ' -DRUBY_19_COMPATIBILITY'
35
33
  end
36
34
 
37
35
  # Do the work
38
36
  # create_makefile(extension_name)
39
37
  if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" )
38
+ have_func("sqlite3_prepare_v2")
40
39
  create_makefile(extension_name)
41
40
  end
@@ -1,4 +1,3 @@
1
-
2
1
  # HACK: If running on Windows, then add the current directory to the PATH
3
2
  # for the current process so it can find the bundled dlls before the require
4
3
  # of the actual extension file.
@@ -9,5 +8,31 @@ end
9
8
 
10
9
  require 'rubygems'
11
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
+
12
18
  require 'do_sqlite3_ext'
13
- require 'do_sqlite3/transaction'
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
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Sqlite3
3
- VERSION = "0.9.9"
3
+ VERSION = "0.9.11"
4
4
  end
5
5
  end
Binary file
@@ -5,8 +5,18 @@ describe "DataObjects::Sqlite3" do
5
5
  include Sqlite3SpecHelpers
6
6
 
7
7
  it "should raise error on bad connection string" do
8
+ pending
8
9
  # lambda { DataObjects::Connection.new("sqlite3:///ac0d9iopalmsdcasd/asdc9pomasd/test.db") }.should raise_error("unable to open database file")
9
10
  end
11
+
12
+ if JRUBY
13
+ it "should accept either DO or JDBC style URLs on JRuby" do
14
+ pending
15
+ @connection = DataObjects::Connection.new("jdbc:sqlite:test.db") # note the sqlite not sqlite3!
16
+ @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
17
+ end
18
+ end
19
+
10
20
  end
11
21
 
12
22
  NOW = DateTime.now
@@ -18,19 +28,27 @@ describe "DataObjects::Sqlite3::Result" do
18
28
  @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
19
29
  end
20
30
 
31
+ before do
32
+ class ::Person; end
33
+ end
34
+
21
35
  after :all do
22
36
  @connection.close
23
37
  end
24
38
 
39
+ after do
40
+ Object.send(:remove_const, :Person)
41
+ end
42
+
25
43
  it "should raise an error for a bad query" do
26
44
  command = @connection.create_command("INSER INTO table_which_doesnt_exist (id) VALUES (1)")
27
- lambda { command.execute_non_query }.should raise_error('near "INSER": syntax error')
45
+ lambda { command.execute_non_query }.should raise_error(Sqlite3Error, /near "INSER": syntax error/)
28
46
 
29
47
  command = @connection.create_command("INSERT INTO table_which_doesnt_exist (id) VALUES (1)")
30
- lambda { command.execute_non_query }.should raise_error("no such table: table_which_doesnt_exist")
48
+ lambda { command.execute_non_query }.should raise_error(Sqlite3Error, /no such table: table_which_doesnt_exist/)
31
49
 
32
50
  command = @connection.create_command("SELECT * FROM table_which_doesnt_exist")
33
- lambda { command.execute_reader }.should raise_error("no such table: table_which_doesnt_exist")
51
+ lambda { command.execute_reader }.should raise_error(Sqlite3Error, /no such table: table_which_doesnt_exist/)
34
52
  end
35
53
 
36
54
  it "should return the affected rows and insert_id" do
@@ -48,19 +66,19 @@ describe "DataObjects::Sqlite3::Result" do
48
66
  command = @connection.create_command("SELECT * FROM users")
49
67
  reader = command.execute_reader
50
68
 
51
- lambda { reader.values }.should raise_error
69
+ lambda { reader.values }.should raise_error(Sqlite3Error, /Reader is not initialized/)
52
70
 
53
71
  while ( reader.next! )
54
72
  lambda { reader.values }.should_not raise_error
55
73
  reader.values.should be_a_kind_of(Array)
56
74
  end
57
75
 
58
- lambda { reader.values }.should raise_error
76
+ lambda { reader.values }.should raise_error(Sqlite3Error, /Reader is not initialized/)
59
77
 
60
78
  reader.close
61
79
  end
62
80
 
63
- it "should do a paramaterized reader query" do
81
+ it "should do a parameterized reader query" do
64
82
  command = @connection.create_command("SELECT * FROM users WHERE id = ?")
65
83
  reader = command.execute_reader(1)
66
84
  reader.next!
@@ -69,7 +87,7 @@ describe "DataObjects::Sqlite3::Result" do
69
87
 
70
88
  reader.next!
71
89
 
72
- lambda { reader.values }.should raise_error
90
+ lambda { reader.values }.should raise_error(Sqlite3Error, /Reader is not initialized/)
73
91
 
74
92
  reader.close
75
93
  end
@@ -103,12 +121,10 @@ describe "DataObjects::Sqlite3::Result" do
103
121
  end
104
122
 
105
123
  it "should raise an error when you pass too many or too few types for the expected result set" do
106
- lambda { select("SELECT name, id FROM users", [String, Integer, String]) }.should raise_error(Sqlite3Error)
124
+ lambda { select("SELECT name, id FROM users", [String, Integer, String]) }.should raise_error(Sqlite3Error, /Field-count mismatch. Expected 3 fields, but the query yielded 2/)
107
125
  end
108
126
 
109
127
  it "should do a custom typecast reader with Class" do
110
- class Person; end
111
-
112
128
  id = insert("INSERT INTO users (name, age, type) VALUES (?, ?, ?)", 'Sam', 30, Person)
113
129
 
114
130
  select("SELECT name, age, type FROM users WHERE id = ?", [String, Integer, Class], id) do |reader|
@@ -174,8 +190,10 @@ describe "DataObjects::Sqlite3::Result" do
174
190
  end
175
191
 
176
192
  it "should return a BigDecimal" do
193
+ pending "We need to introduce something like Proxy for typeasting where each SQL type will have _rules_ of casting" if JRUBY
177
194
  balance = BigDecimal.new('10000000000.00')
178
195
 
196
+ #looks like inserting BigDecimals is not implemented in SQLITE's jdbc driver http://zentus.com/sqlitejdbc/src/src/org/sqlite/Unused.java
179
197
  id = insert("INSERT INTO users (name, age, type, created_at, balance) VALUES (?, ?, ?, ?, ?)", 'Scott', 27, Person, DateTime.now, balance)
180
198
 
181
199
  select("SELECT balance FROM users WHERE id = ?", [BigDecimal], id) do |reader|
@@ -183,74 +201,78 @@ describe "DataObjects::Sqlite3::Result" do
183
201
  end
184
202
  end
185
203
 
186
- describe "quoting" do
204
+ unless JRUBY
187
205
 
188
- before do
189
- @connection.create_command("DROP TABLE IF EXISTS sail_boats").execute_non_query
190
- @connection.create_command("CREATE TABLE sail_boats ( id INTEGER PRIMARY KEY, name VARCHAR(50), port VARCHAR(50), notes VARCHAR(50), vintage BOOLEAN )").execute_non_query
191
- command = @connection.create_command("INSERT INTO sail_boats (id, name, port, name, vintage) VALUES (?, ?, ?, ?, ?)")
192
- command.execute_non_query(1, "A", "C", "Fortune Pig!", false)
193
- command.execute_non_query(2, "B", "B", "Happy Cow!", true)
194
- command.execute_non_query(3, "C", "A", "Spoon", true)
195
- end
206
+ describe "quoting" do
196
207
 
197
- after do
198
- @connection.create_command("DROP TABLE sail_boats").execute_non_query
199
- end
208
+ before do
209
+ @connection.create_command("DROP TABLE IF EXISTS sail_boats").execute_non_query
210
+ @connection.create_command("CREATE TABLE sail_boats ( id INTEGER PRIMARY KEY, name VARCHAR(50), port VARCHAR(50), notes VARCHAR(50), vintage BOOLEAN )").execute_non_query
211
+ command = @connection.create_command("INSERT INTO sail_boats (id, name, port, name, vintage) VALUES (?, ?, ?, ?, ?)")
212
+ command.execute_non_query(1, "A", "C", "Fortune Pig!", false)
213
+ command.execute_non_query(2, "B", "B", "Happy Cow!", true)
214
+ command.execute_non_query(3, "C", "A", "Spoon", true)
215
+ end
200
216
 
201
- it "should quote a String" do
202
- command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
203
- result = command.execute_non_query("John Doe")
204
- result.to_i.should == 1
205
- end
217
+ after do
218
+ @connection.create_command("DROP TABLE sail_boats").execute_non_query
219
+ end
206
220
 
207
- it "should quote multiple values" do
208
- command = @connection.create_command("INSERT INTO users (name, age) VALUES (?, ?)")
209
- result = command.execute_non_query("Sam Smoot", 1)
210
- result.to_i.should == 1
211
- end
221
+ it "should quote a String" do
222
+ command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
223
+ result = command.execute_non_query("John Doe")
224
+ result.to_i.should == 1
225
+ end
212
226
 
227
+ it "should quote multiple values" do
228
+ command = @connection.create_command("INSERT INTO users (name, age) VALUES (?, ?)")
229
+ result = command.execute_non_query("Sam Smoot", 1)
230
+ result.to_i.should == 1
231
+ end
213
232
 
214
- it "should handle boolean columns gracefully" do
215
- command = @connection.create_command("INSERT INTO sail_boats (id, name, port, name, vintage) VALUES (?, ?, ?, ?, ?)")
216
- result = command.execute_non_query(4, "Scooner", "Port au Prince", "This is one gangster boat!", true)
217
- result.to_i.should == 1
218
- end
219
233
 
220
- it "should quote an Array" do
221
- command = @connection.create_command("SELECT id, notes FROM sail_boats WHERE (id IN ?)")
222
- reader = command.execute_reader([1, 2, 3])
234
+ it "should handle boolean columns gracefully" do
235
+ command = @connection.create_command("INSERT INTO sail_boats (id, name, port, name, vintage) VALUES (?, ?, ?, ?, ?)")
236
+ result = command.execute_non_query(4, "Scooner", "Port au Prince", "This is one gangster boat!", true)
237
+ result.to_i.should == 1
238
+ end
239
+
240
+ it "should quote an Array" do
241
+ command = @connection.create_command("SELECT id, notes FROM sail_boats WHERE (id IN ?)")
242
+ reader = command.execute_reader([1, 2, 3])
223
243
 
224
- i = 1
225
- while(reader.next!)
226
- reader.values[0].should == i
227
- i += 1
244
+ i = 1
245
+ while(reader.next!)
246
+ reader.values[0].should == i
247
+ i += 1
248
+ end
228
249
  end
229
- end
230
250
 
231
- it "should quote an Array with NULL values returned" do
232
- command = @connection.create_command("SELECT id, NULL AS notes FROM sail_boats WHERE (id IN ?)")
233
- reader = command.execute_reader([1, 2, 3])
251
+ it "should quote an Array with NULL values returned" do
252
+ command = @connection.create_command("SELECT id, NULL AS notes FROM sail_boats WHERE (id IN ?)")
253
+ reader = command.execute_reader([1, 2, 3])
234
254
 
235
- i = 1
236
- while(reader.next!)
237
- reader.values[0].should == i
238
- i += 1
255
+ i = 1
256
+ while(reader.next!)
257
+ reader.values[0].should == i
258
+ i += 1
259
+ end
239
260
  end
240
- end
241
261
 
242
- it "should quote an Array with NULL values returned AND set_types called" do
243
- command = @connection.create_command("SELECT id, NULL AS notes FROM sail_boats WHERE (id IN ?)")
244
- command.set_types [ Integer, String ]
262
+ it "should quote an Array with NULL values returned AND set_types called" do
263
+ command = @connection.create_command("SELECT id, NULL AS notes FROM sail_boats WHERE (id IN ?)")
264
+ command.set_types [ Integer, String ]
245
265
 
246
- reader = command.execute_reader([1, 2, 3])
266
+ reader = command.execute_reader([1, 2, 3])
247
267
 
248
- i = 1
249
- while(reader.next!)
250
- reader.values[0].should == i
251
- i += 1
268
+ i = 1
269
+ while(reader.next!)
270
+ reader.values[0].should == i
271
+ i += 1
272
+ end
252
273
  end
253
- end
254
274
 
255
- end # describe "quoting"
275
+ end # describe "quoting"
276
+
277
+ end
256
278
  end
@@ -4,7 +4,7 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
4
4
  describe DataObjects::Sqlite3::Command do
5
5
 
6
6
  before(:each) do
7
- @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
7
+ @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
8
8
  end
9
9
 
10
10
  after(:each) do
@@ -14,11 +14,12 @@ describe DataObjects::Sqlite3::Command do
14
14
  describe "Executing a Reader" do
15
15
 
16
16
  it "should log reader queries when the level is Debug (0)" do
17
+ pending "SQLiteJDBC does not implement java.sql.Statement#toString" if JRUBY
17
18
  command = @connection.create_command("SELECT * FROM users")
18
19
  @mock_logger = mock('MockLogger', :level => 0)
19
20
  DataObjects::Sqlite3.should_receive(:logger).and_return(@mock_logger)
20
- @mock_logger.should_receive(:debug).with("SELECT * FROM users")
21
- command.execute_reader
21
+ @mock_logger.should_receive(:debug).with(/\([\d.]+\) SELECT \* FROM users/)
22
+ command.execute_reader.close
22
23
  end
23
24
 
24
25
  it "shouldn't log reader queries when the level isn't Debug (0)" do
@@ -26,16 +27,17 @@ describe DataObjects::Sqlite3::Command do
26
27
  @mock_logger = mock('MockLogger', :level => 1)
27
28
  DataObjects::Sqlite3.should_receive(:logger).and_return(@mock_logger)
28
29
  @mock_logger.should_not_receive(:debug)
29
- command.execute_reader
30
+ command.execute_reader.close
30
31
  end
31
32
  end
32
33
 
33
34
  describe "Executing a Non-Query" do
34
35
  it "should log non-query statements when the level is Debug (0)" do
36
+ pending "SQLiteJDBC does not implement java.sql.Statement#toString" if JRUBY
35
37
  command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
36
38
  @mock_logger = mock('MockLogger', :level => 0)
37
39
  DataObjects::Sqlite3.should_receive(:logger).and_return(@mock_logger)
38
- @mock_logger.should_receive(:debug).with("INSERT INTO users (name) VALUES ('Blah')")
40
+ @mock_logger.should_receive(:debug).with(/\([\d.]+\) INSERT INTO users \(name\) VALUES \('Blah'\)/)
39
41
  command.execute_non_query('Blah')
40
42
  end
41
43
 
@@ -1,19 +1,23 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
3
3
 
4
- describe DataObjects::Sqlite3::Command do
4
+ unless JRUBY
5
5
 
6
- before(:each) do
7
- @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
8
- @command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
9
- end
6
+ describe DataObjects::Sqlite3::Command do
7
+
8
+ before(:each) do
9
+ @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
10
+ @command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
11
+ end
12
+
13
+ it "should properly quote a string" do
14
+ @command.quote_string("O'Hare").should == "'O''Hare'"
15
+ @command.quote_string("Willy O'Hare & Johnny O'Toole").should == "'Willy O''Hare & Johnny O''Toole'"
16
+ @command.quote_string("Billy\\Bob").should == "'Billy\\Bob'"
17
+ @command.quote_string("The\\Backslasher\\Rises\\Again").should == "'The\\Backslasher\\Rises\\Again'"
18
+ @command.quote_string("Scott \"The Rage\" Bauer").should == "'Scott \"The Rage\" Bauer'"
19
+ end
10
20
 
11
- it "should properly quote a string" do
12
- @command.quote_string("O'Hare").should == "'O''Hare'"
13
- @command.quote_string("Willy O'Hare & Johnny O'Toole").should == "'Willy O''Hare & Johnny O''Toole'"
14
- @command.quote_string("Billy\\Bob").should == "'Billy\\Bob'"
15
- @command.quote_string("The\\Backslasher\\Rises\\Again").should == "'The\\Backslasher\\Rises\\Again'"
16
- @command.quote_string("Scott \"The Rage\" Bauer").should == "'Scott \"The Rage\" Bauer'"
17
21
  end
18
22
 
19
23
  end
@@ -1,4 +1,5 @@
1
1
  $TESTING=true
2
+ JRUBY = RUBY_PLATFORM =~ /java/
2
3
 
3
4
  require 'rubygems'
4
5
  require 'spec'
@@ -10,6 +11,11 @@ require 'pathname'
10
11
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data_objects', 'lib'))
11
12
  require 'data_objects'
12
13
 
14
+ if JRUBY
15
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
16
+ require 'do_jdbc'
17
+ end
18
+
13
19
  # put the pre-compiled extension in the path to be found
14
20
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
15
21
  require 'do_sqlite3'
@@ -17,7 +23,7 @@ require 'do_sqlite3'
17
23
  log_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log', 'do.log'))
18
24
  FileUtils.mkdir_p(File.dirname(log_path))
19
25
 
20
- DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, 0)
26
+ DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, :debug)
21
27
 
22
28
  at_exit { DataObjects.logger.flush }
23
29
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.11
5
5
  platform: x86-mswin32-60
6
6
  authors:
7
- - Bernerd Schaefer
7
+ - Dirkjan Bussink
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-27 00:00:00 -08:00
12
+ date: 2009-01-19 00:00:00 +01: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.9
23
+ version: 0.9.11
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
@@ -34,7 +34,7 @@ dependencies:
34
34
  version:
35
35
  description: A DataObject.rb driver for Sqlite3
36
36
  email:
37
- - bj.schaefer@gmail.com
37
+ - d.bussink@gmail.com
38
38
  executables: []
39
39
 
40
40
  extensions: []
@@ -50,9 +50,11 @@ files:
50
50
  - Manifest.txt
51
51
  - README.txt
52
52
  - Rakefile
53
- - TODO
54
- - ext/do_sqlite3_ext.c
55
- - ext/extconf.rb
53
+ - buildfile
54
+ - ext-java/src/main/java/DoSqlite3ExtService.java
55
+ - ext-java/src/main/java/do_sqlite3/Sqlite3DriverDefinition.java
56
+ - ext/do_sqlite3_ext/do_sqlite3_ext.c
57
+ - ext/do_sqlite3_ext/extconf.rb
56
58
  - lib/do_sqlite3.rb
57
59
  - lib/do_sqlite3/transaction.rb
58
60
  - lib/do_sqlite3/version.rb
@@ -65,10 +67,7 @@ files:
65
67
  - lib/do_sqlite3_ext.so
66
68
  has_rdoc: false
67
69
  homepage: http://rubyforge.org/projects/dorb
68
- post_install_message: |
69
- Now download http://www.sqlite.org/sqlitedll-3_6_6_2.zip
70
- And place the dll somewhere in your PATH, for example C:\ruby\bin
71
-
70
+ post_install_message:
72
71
  rdoc_options:
73
72
  - --main
74
73
  - README.txt