do_sqlite3 0.9.10.1 → 0.9.11

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.
@@ -1,3 +1,9 @@
1
+ == 0.9.11 2009-01-19
2
+ * Improvements
3
+ * Ruby 1.9 support
4
+ * Fixes
5
+ * Fix Windows gem
6
+
1
7
  == 0.9.9 2008-11-27
2
8
  * Improvements
3
9
  * Added cross compile rake tasks for Windows gems [Jonathan Stott, Luis Lavena]
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007 Yehuda Katz
1
+ Copyright (c) 2007, 2008, 2009 Yehuda Katz, Dirkjan Bussink
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -4,7 +4,6 @@ LICENSE
4
4
  Manifest.txt
5
5
  README.txt
6
6
  Rakefile
7
- TODO
8
7
  buildfile
9
8
  ext-java/src/main/java/DoSqlite3ExtService.java
10
9
  ext-java/src/main/java/do_sqlite3/Sqlite3DriverDefinition.java
data/Rakefile CHANGED
@@ -10,8 +10,8 @@ JRUBY = RUBY_PLATFORM =~ /java/
10
10
  WINDOWS = Gem.win_platform?
11
11
  SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
12
12
 
13
- AUTHOR = "Bernerd Schaefer"
14
- EMAIL = "bj.schaefer@gmail.com"
13
+ AUTHOR = "Dirkjan Bussink"
14
+ EMAIL = "d.bussink@gmail.com"
15
15
  GEM_NAME = "do_sqlite3"
16
16
  GEM_VERSION = DataObjects::Sqlite3::VERSION
17
17
  GEM_DEPENDENCIES = if JRUBY
@@ -21,27 +21,39 @@ else
21
21
  end
22
22
 
23
23
  # TODO: remove duplicates from here that are already listed in .gitignore
24
- clean = %w(o bundle log a gem dSYM obj pdb lib def exp DS_Store)
25
-
26
- if WINDOWS
27
- GEM_EXTRAS = { :has_rdoc => false }
24
+ clean = %w(o bundle jar log a gem dSYM obj pdb lib def exp DS_Store)
25
+
26
+ GEM_EXTRAS = if WINDOWS
27
+ {
28
+ :has_rdoc => false
29
+ }
30
+ elsif JRUBY
31
+ {
32
+ :has_rdoc => false,
33
+ :platform => 'java'
34
+ }
28
35
  else
29
- GEM_EXTRAS = { :extensions => 'ext/do_sqlite3_ext/extconf.rb', :has_rdoc => false }
36
+ {
37
+ :has_rdoc => false,
38
+ :extensions => 'ext/do_sqlite3_ext/extconf.rb'
39
+ }
30
40
  end
31
41
 
32
- GEM_CLEAN = ["**/*.{#{clean.join(",")}}", 'ext/Makefile']
42
+ GEM_CLEAN = ['**/test.db',"**/*.{#{clean.join(",")}}", 'ext/Makefile', 'ext-java/target']
33
43
 
34
44
  PROJECT_NAME = "dorb"
35
45
  PROJECT_URL = "http://rubyforge.org/projects/dorb"
36
46
  PROJECT_DESCRIPTION = PROJECT_SUMMARY = "A DataObject.rb driver for Sqlite3"
37
47
 
38
- JAVA_DRIVER = true
39
48
 
40
49
  # RCov is run by default, except on the JRuby platform, or if NO_RCOV env is true
41
50
  RUN_RCOV = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
42
51
 
43
52
  if (tasks_dir = ROOT.parent + 'tasks').directory?
44
53
  require tasks_dir + 'hoe'
54
+ require tasks_dir + 'ext_helper_java'
55
+
56
+ setup_java_extension "#{GEM_NAME}_ext", HOE.spec
45
57
 
46
58
  # use .gitignore to identify files to clean up
47
59
  File.read(ROOT.parent + '.gitignore').split(/\s+/).each do |pattern|
@@ -50,10 +62,21 @@ if (tasks_dir = ROOT.parent + 'tasks').directory?
50
62
  end
51
63
  end
52
64
 
65
+ if JRUBY
66
+ HOE.spec.files += ['lib/do_sqlite3_ext.jar']
67
+ HOE.spec.require_paths = Dir['lib']
68
+ end
69
+
53
70
  def sudo_gem(cmd)
54
71
  sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
55
72
  end
56
73
 
74
+ # compile the extension
75
+ if JRUBY
76
+ Rake::Task['compile:jruby'].invoke
77
+ else
78
+ end
79
+
57
80
  # Installation
58
81
 
59
82
  desc "Install #{GEM_NAME} #{GEM_VERSION}"
@@ -70,7 +93,7 @@ desc 'Run specifications'
70
93
  Spec::Rake::SpecTask.new(:spec) do |t|
71
94
  t.spec_opts << '--format' << 'specdoc' << '--colour'
72
95
  t.spec_opts << '--loadby' << 'random'
73
- t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb')
96
+ t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
74
97
 
75
98
  begin
76
99
  t.rcov = RUN_RCOV
@@ -120,6 +143,8 @@ CCROOT = ROOT.parent
120
143
 
121
144
  SQLITE_VERSION = '3_6_6_2'
122
145
 
146
+ MINGW_PATH = ENV['MINGW_PATH'] || '/usr/i586-mingw32msvc'
147
+
123
148
  if (tasks_dir = ROOT.parent + 'tasks').directory?
124
149
  require tasks_dir + 'win32'
125
150
 
@@ -179,14 +204,13 @@ begin
179
204
  require 'rake/extensiontask'
180
205
  Rake::ExtensionTask.new('do_sqlite3_ext', HOE.spec) do |ext|
181
206
  ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
182
- ext.cross_platform = 'i386-mswin32'
207
+ ext.cross_platform = 'x86-mswin32-60'
183
208
  ext.cross_config_options << "--with-sqlite3-dir=#{SQLITE_DIR}"
184
209
  end
185
210
  rescue LoadError
186
211
  warn "To cross-compile, install rake-compiler (gem install rake-compiler)"
187
212
  if tasks_dir.directory?
188
213
  require tasks_dir + 'ext_helper'
189
- setup_extension('do_sqlite3_ext', HOE.spec)
214
+ setup_c_extension('do_sqlite3_ext', HOE.spec)
190
215
  end
191
216
  end
192
-
data/buildfile CHANGED
@@ -1,26 +1,27 @@
1
- # Apache Buildr buildfile for do_derby
1
+ # Apache Buildr buildfile for do_sqlite3
2
2
  # see http://incubator.apache.org/buildr/ for more information on Apache Buildr
3
3
  require 'buildr'
4
4
  require 'pathname'
5
5
 
6
6
  VERSION_NUMBER = '1.0'
7
7
  JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0']
8
+ TARGET_DIR = 'pkg/classes'
8
9
  repositories.remote << 'http://www.ibiblio.org/maven2/'
9
10
 
10
11
  define 'do_sqlite3' do
11
12
  project.version = VERSION_NUMBER
12
13
  project.group = 'data_objects.rb'
13
14
 
14
- manifest['Copyright'] = 'Alex Coles (C) 2008'
15
+ manifest['Copyright'] = 'Alex Coles (C) 2008-2009'
15
16
 
16
17
  compile.using :target => '1.5', :lint => 'all', :deprecation => 'true'
17
18
 
18
19
  define 'ext-java' do
19
- package :jar
20
+ package(:jar).clean.include(TARGET_DIR)
20
21
 
21
22
  jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar')
22
23
  jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar)
23
24
 
24
- compile.with JDBC_SUPPORT
25
+ compile.into(TARGET_DIR).with(JDBC_SUPPORT)
25
26
  end
26
27
  end
@@ -5,6 +5,11 @@ import data_objects.drivers.AbstractDriverDefinition;
5
5
  public class Sqlite3DriverDefinition extends AbstractDriverDefinition {
6
6
 
7
7
  public boolean supportsJdbcGeneratedKeys()
8
+ {
9
+ return true;
10
+ }
11
+
12
+ public boolean supportsConnectionPrepareStatementMethodWithGKFlag()
8
13
  {
9
14
  return false;
10
15
  }
@@ -41,6 +41,7 @@
41
41
 
42
42
  // To store rb_intern values
43
43
  static ID ID_NEW_DATE;
44
+ static ID ID_RATIONAL;
44
45
  static ID ID_LOGGER;
45
46
  static ID ID_DEBUG;
46
47
  static ID ID_LEVEL;
@@ -54,11 +55,6 @@ static VALUE cDO_Reader;
54
55
 
55
56
  static VALUE rb_cDate;
56
57
  static VALUE rb_cDateTime;
57
-
58
- #ifndef RUBY_19_COMPATIBILITY
59
- static VALUE rb_cRational;
60
- #endif
61
-
62
58
  static VALUE rb_cBigDecimal;
63
59
 
64
60
  static VALUE mSqlite3;
@@ -133,7 +129,7 @@ static VALUE parse_date(char *date) {
133
129
 
134
130
  // Math from Date.jd_to_ajd
135
131
  ajd = jd * 2 - 1;
136
- rational = rb_funcall(rb_cRational, rb_intern("new!"), 2, INT2NUM(ajd), INT2NUM(2));
132
+ rational = rb_funcall(rb_mKernel, ID_RATIONAL, 2, INT2NUM(ajd), INT2NUM(2));
137
133
  return rb_funcall(rb_cDate, ID_NEW_DATE, 3, rational, INT2NUM(0), INT2NUM(2299161));
138
134
  }
139
135
 
@@ -141,7 +137,7 @@ static VALUE parse_date(char *date) {
141
137
  static VALUE seconds_to_offset(do_int64 num) {
142
138
  do_int64 den = 86400;
143
139
  reduce(&num, &den);
144
- return rb_funcall(rb_cRational, rb_intern("new!"), 2, rb_ll2inum(num), rb_ll2inum(den));
140
+ return rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ll2inum(num), rb_ll2inum(den));
145
141
  }
146
142
 
147
143
  static VALUE timezone_to_offset(int hour_offset, int minute_offset) {
@@ -239,7 +235,7 @@ static VALUE parse_date_time(char *date) {
239
235
 
240
236
  reduce(&num, &den);
241
237
 
242
- ajd = rb_funcall(rb_cRational, rb_intern("new!"), 2, rb_ull2inum(num), rb_ull2inum(den));
238
+ ajd = rb_funcall(rb_mKernel, ID_RATIONAL, 2, rb_ull2inum(num), rb_ull2inum(den));
243
239
  offset = timezone_to_offset(hour_offset, minute_offset);
244
240
 
245
241
  return rb_funcall(rb_cDateTime, ID_NEW_DATE, 3, ajd, offset, INT2NUM(2299161));
@@ -263,7 +259,7 @@ static VALUE parse_time(char *date) {
263
259
  }
264
260
 
265
261
  static VALUE typecast(sqlite3_stmt *stmt, int i, VALUE ruby_class) {
266
- char *ruby_type;
262
+ const char *ruby_type;
267
263
  VALUE ruby_value = Qnil;
268
264
  int original_type = sqlite3_column_type(stmt, i);
269
265
  int length = sqlite3_column_bytes(stmt, i);
@@ -295,7 +291,7 @@ static VALUE typecast(sqlite3_stmt *stmt, int i, VALUE ruby_class) {
295
291
  }
296
292
 
297
293
  if ( strcmp(ruby_type, "Class") == 0) {
298
- return rb_funcall(mDO, rb_intern("find_const"), 1, TAINTED_STRING((char*)sqlite3_column_text(stmt, i), length));
294
+ return rb_funcall(rb_cObject, rb_intern("full_const_get"), 1, TAINTED_STRING((char*)sqlite3_column_text(stmt, i), length));
299
295
  } else if ( strcmp(ruby_type, "Object") == 0 ) {
300
296
  return rb_marshal_load(rb_str_new2((char*)sqlite3_column_text(stmt, i)));
301
297
  } else if ( strcmp(ruby_type, "TrueClass") == 0 ) {
@@ -526,6 +522,14 @@ static VALUE cReader_fields(VALUE self) {
526
522
  return rb_iv_get(self, "@fields");
527
523
  }
528
524
 
525
+ static VALUE cReader_field_count(VALUE self) {
526
+ return rb_iv_get(self, "@field_count");
527
+ }
528
+
529
+ static VALUE cReader_row_count(VALUE self) {
530
+ return rb_iv_get(self, "@row_count");
531
+ }
532
+
529
533
  void Init_do_sqlite3_ext() {
530
534
  rb_require("bigdecimal");
531
535
  rb_require("date");
@@ -534,7 +538,6 @@ void Init_do_sqlite3_ext() {
534
538
  rb_cDate = CONST_GET(rb_mKernel, "Date");
535
539
  rb_cDateTime = CONST_GET(rb_mKernel, "DateTime");
536
540
  rb_cTime = CONST_GET(rb_mKernel, "Time");
537
- rb_cRational = CONST_GET(rb_mKernel, "Rational");
538
541
  rb_cBigDecimal = CONST_GET(rb_mKernel, "BigDecimal");
539
542
 
540
543
  rb_funcall(rb_mKernel, rb_intern("require"), 1, rb_str_new2("data_objects"));
@@ -544,6 +547,7 @@ void Init_do_sqlite3_ext() {
544
547
  #else
545
548
  ID_NEW_DATE = rb_intern("new!");
546
549
  #endif
550
+ ID_RATIONAL = rb_intern("Rational");
547
551
  ID_LOGGER = rb_intern("logger");
548
552
  ID_DEBUG = rb_intern("debug");
549
553
  ID_LEVEL = rb_intern("level");
@@ -580,5 +584,7 @@ void Init_do_sqlite3_ext() {
580
584
  rb_define_method(cReader, "next!", cReader_next, 0);
581
585
  rb_define_method(cReader, "values", cReader_values, 0);
582
586
  rb_define_method(cReader, "fields", cReader_fields, 0);
587
+ rb_define_method(cReader, "field_count", cReader_field_count, 0);
588
+ rb_define_method(cReader, "row_count", cReader_row_count, 0);
583
589
 
584
590
  }
@@ -30,8 +30,6 @@ $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
@@ -15,7 +15,7 @@ if RUBY_PLATFORM =~ /java/
15
15
  require 'jdbc/sqlite3' # the JDBC driver, packaged as a gem
16
16
  end
17
17
 
18
- require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3_ext'))
18
+ require 'do_sqlite3_ext'
19
19
  require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3', 'version'))
20
20
  require File.expand_path(File.join(File.dirname(__FILE__), 'do_sqlite3', 'transaction'))
21
21
 
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Sqlite3
3
- VERSION = "0.9.10.1"
3
+ VERSION = "0.9.11"
4
4
  end
5
5
  end
@@ -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
@@ -15,17 +25,21 @@ describe "DataObjects::Sqlite3::Result" do
15
25
  include Sqlite3SpecHelpers
16
26
 
17
27
  before(:all) do
18
- if JRUBY # note the sqlite not sqlite3!
19
- @connection = DataObjects::Connection.new("jdbc:sqlite:test.db")
20
- else
21
- @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
22
- end
28
+ @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
29
+ end
30
+
31
+ before do
32
+ class ::Person; end
23
33
  end
24
34
 
25
35
  after :all do
26
36
  @connection.close
27
37
  end
28
38
 
39
+ after do
40
+ Object.send(:remove_const, :Person)
41
+ end
42
+
29
43
  it "should raise an error for a bad query" do
30
44
  command = @connection.create_command("INSER INTO table_which_doesnt_exist (id) VALUES (1)")
31
45
  lambda { command.execute_non_query }.should raise_error(Sqlite3Error, /near "INSER": syntax error/)
@@ -64,7 +78,7 @@ describe "DataObjects::Sqlite3::Result" do
64
78
  reader.close
65
79
  end
66
80
 
67
- it "should do a paramaterized reader query" do
81
+ it "should do a parameterized reader query" do
68
82
  command = @connection.create_command("SELECT * FROM users WHERE id = ?")
69
83
  reader = command.execute_reader(1)
70
84
  reader.next!
@@ -111,8 +125,6 @@ describe "DataObjects::Sqlite3::Result" do
111
125
  end
112
126
 
113
127
  it "should do a custom typecast reader with Class" do
114
- class Person; end
115
-
116
128
  id = insert("INSERT INTO users (name, age, type) VALUES (?, ?, ?)", 'Sam', 30, Person)
117
129
 
118
130
  select("SELECT name, age, type FROM users WHERE id = ?", [String, Integer, Class], id) do |reader|
@@ -178,8 +190,10 @@ describe "DataObjects::Sqlite3::Result" do
178
190
  end
179
191
 
180
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
181
194
  balance = BigDecimal.new('10000000000.00')
182
195
 
196
+ #looks like inserting BigDecimals is not implemented in SQLITE's jdbc driver http://zentus.com/sqlitejdbc/src/src/org/sqlite/Unused.java
183
197
  id = insert("INSERT INTO users (name, age, type, created_at, balance) VALUES (?, ?, ?, ?, ?)", 'Scott', 27, Person, DateTime.now, balance)
184
198
 
185
199
  select("SELECT balance FROM users WHERE id = ?", [BigDecimal], id) do |reader|
@@ -187,74 +201,78 @@ describe "DataObjects::Sqlite3::Result" do
187
201
  end
188
202
  end
189
203
 
190
- describe "quoting" do
204
+ unless JRUBY
191
205
 
192
- before do
193
- @connection.create_command("DROP TABLE IF EXISTS sail_boats").execute_non_query
194
- @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
195
- command = @connection.create_command("INSERT INTO sail_boats (id, name, port, name, vintage) VALUES (?, ?, ?, ?, ?)")
196
- command.execute_non_query(1, "A", "C", "Fortune Pig!", false)
197
- command.execute_non_query(2, "B", "B", "Happy Cow!", true)
198
- command.execute_non_query(3, "C", "A", "Spoon", true)
199
- end
206
+ describe "quoting" do
200
207
 
201
- after do
202
- @connection.create_command("DROP TABLE sail_boats").execute_non_query
203
- 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
204
216
 
205
- it "should quote a String" do
206
- command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
207
- result = command.execute_non_query("John Doe")
208
- result.to_i.should == 1
209
- end
217
+ after do
218
+ @connection.create_command("DROP TABLE sail_boats").execute_non_query
219
+ end
210
220
 
211
- it "should quote multiple values" do
212
- command = @connection.create_command("INSERT INTO users (name, age) VALUES (?, ?)")
213
- result = command.execute_non_query("Sam Smoot", 1)
214
- result.to_i.should == 1
215
- 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
216
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
217
232
 
218
- it "should handle boolean columns gracefully" do
219
- command = @connection.create_command("INSERT INTO sail_boats (id, name, port, name, vintage) VALUES (?, ?, ?, ?, ?)")
220
- result = command.execute_non_query(4, "Scooner", "Port au Prince", "This is one gangster boat!", true)
221
- result.to_i.should == 1
222
- end
223
233
 
224
- it "should quote an Array" do
225
- command = @connection.create_command("SELECT id, notes FROM sail_boats WHERE (id IN ?)")
226
- 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])
227
243
 
228
- i = 1
229
- while(reader.next!)
230
- reader.values[0].should == i
231
- i += 1
244
+ i = 1
245
+ while(reader.next!)
246
+ reader.values[0].should == i
247
+ i += 1
248
+ end
232
249
  end
233
- end
234
250
 
235
- it "should quote an Array with NULL values returned" do
236
- command = @connection.create_command("SELECT id, NULL AS notes FROM sail_boats WHERE (id IN ?)")
237
- 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])
238
254
 
239
- i = 1
240
- while(reader.next!)
241
- reader.values[0].should == i
242
- i += 1
255
+ i = 1
256
+ while(reader.next!)
257
+ reader.values[0].should == i
258
+ i += 1
259
+ end
243
260
  end
244
- end
245
261
 
246
- it "should quote an Array with NULL values returned AND set_types called" do
247
- command = @connection.create_command("SELECT id, NULL AS notes FROM sail_boats WHERE (id IN ?)")
248
- 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 ]
249
265
 
250
- reader = command.execute_reader([1, 2, 3])
266
+ reader = command.execute_reader([1, 2, 3])
251
267
 
252
- i = 1
253
- while(reader.next!)
254
- reader.values[0].should == i
255
- i += 1
268
+ i = 1
269
+ while(reader.next!)
270
+ reader.values[0].should == i
271
+ i += 1
272
+ end
256
273
  end
257
- end
258
274
 
259
- end # describe "quoting"
275
+ end # describe "quoting"
276
+
277
+ end
260
278
  end
@@ -4,11 +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
- if JRUBY # note the sqlite not sqlite3!
8
- @connection = DataObjects::Connection.new("jdbc:sqlite:test.db")
9
- else
10
7
  @connection = DataObjects::Connection.new("sqlite3://#{File.expand_path(File.dirname(__FILE__))}/test.db")
11
- end
12
8
  end
13
9
 
14
10
  after(:each) do
@@ -18,11 +14,12 @@ describe DataObjects::Sqlite3::Command do
18
14
  describe "Executing a Reader" do
19
15
 
20
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
21
18
  command = @connection.create_command("SELECT * FROM users")
22
19
  @mock_logger = mock('MockLogger', :level => 0)
23
20
  DataObjects::Sqlite3.should_receive(:logger).and_return(@mock_logger)
24
21
  @mock_logger.should_receive(:debug).with(/\([\d.]+\) SELECT \* FROM users/)
25
- command.execute_reader
22
+ command.execute_reader.close
26
23
  end
27
24
 
28
25
  it "shouldn't log reader queries when the level isn't Debug (0)" do
@@ -30,12 +27,13 @@ describe DataObjects::Sqlite3::Command do
30
27
  @mock_logger = mock('MockLogger', :level => 1)
31
28
  DataObjects::Sqlite3.should_receive(:logger).and_return(@mock_logger)
32
29
  @mock_logger.should_not_receive(:debug)
33
- command.execute_reader
30
+ command.execute_reader.close
34
31
  end
35
32
  end
36
33
 
37
34
  describe "Executing a Non-Query" do
38
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
39
37
  command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
40
38
  @mock_logger = mock('MockLogger', :level => 0)
41
39
  DataObjects::Sqlite3.should_receive(:logger).and_return(@mock_logger)
@@ -1,23 +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
- if JRUBY # NOTE the sqlite not sqlite3
8
- @connection = DataObjects::Connection.new("jdbc:sqlite:test.db")
9
- else
6
+ describe DataObjects::Sqlite3::Command do
7
+
8
+ before(:each) do
10
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'"
11
19
  end
12
- @command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
13
- end
14
20
 
15
- it "should properly quote a string" do
16
- @command.quote_string("O'Hare").should == "'O''Hare'"
17
- @command.quote_string("Willy O'Hare & Johnny O'Toole").should == "'Willy O''Hare & Johnny O''Toole'"
18
- @command.quote_string("Billy\\Bob").should == "'Billy\\Bob'"
19
- @command.quote_string("The\\Backslasher\\Rises\\Again").should == "'The\\Backslasher\\Rises\\Again'"
20
- @command.quote_string("Scott \"The Rage\" Bauer").should == "'Scott \"The Rage\" Bauer'"
21
21
  end
22
22
 
23
23
  end
@@ -23,7 +23,7 @@ require 'do_sqlite3'
23
23
  log_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log', 'do.log'))
24
24
  FileUtils.mkdir_p(File.dirname(log_path))
25
25
 
26
- DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, 0)
26
+ DataObjects::Sqlite3.logger = DataObjects::Logger.new(log_path, :debug)
27
27
 
28
28
  at_exit { DataObjects.logger.flush }
29
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.10.1
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
- - Bernerd Schaefer
7
+ - Dirkjan Bussink
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-05 00:00:00 +01: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.10.1
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,7 +50,6 @@ files:
50
50
  - Manifest.txt
51
51
  - README.txt
52
52
  - Rakefile
53
- - TODO
54
53
  - buildfile
55
54
  - ext-java/src/main/java/DoSqlite3ExtService.java
56
55
  - ext-java/src/main/java/do_sqlite3/Sqlite3DriverDefinition.java
data/TODO DELETED
@@ -1,4 +0,0 @@
1
- TODO
2
- ====
3
-
4
- * Add JDBC-based version of this driver.