sqlite3-ruby 1.2.1-mswin32 → 1.2.2-mswin32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sqlite3-ruby might be problematic. Click here for more details.

data/test/tc_errors.rb CHANGED
@@ -1,46 +1,13 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
4
- # All rights reserved.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions are met:
8
- #
9
- # * Redistributions of source code must retain the above copyright notice,
10
- # this list of conditions and the following disclaimer.
11
- #
12
- # * Redistributions in binary form must reproduce the above copyright
13
- # notice, this list of conditions and the following disclaimer in the
14
- # documentation and/or other materials provided with the distribution.
15
- #
16
- # * The names of its contributors may not be used to endorse or promote
17
- # products derived from this software without specific prior written
18
- # permission.
19
- #
20
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24
- # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- # =============================================================================
31
- #++
32
-
33
1
  $:.unshift "../lib"
34
2
 
35
3
  require 'sqlite3/errors'
36
4
  require 'test/unit'
37
- require 'flexmock'
5
+ require 'mocha'
38
6
 
39
7
  class TC_Errors < Test::Unit::TestCase
40
8
  (1..26).each do |code|
41
9
  define_method( "test_error_code_%02d" % code ) do
42
- db = FlexMock.new
43
- db.mock_handle( :errmsg ) { "message" }
10
+ db = stub('database', :errmsg => 'message')
44
11
  begin
45
12
  SQLite3::Error.check( code, db )
46
13
  rescue SQLite3::Exception => e
@@ -4,6 +4,7 @@ $:.unshift "#{File.dirname(__FILE__)}/../ext/sqlite3_api"
4
4
  require 'test/unit'
5
5
  require 'benchmark'
6
6
  require 'sqlite3/database'
7
+ require 'thread'
7
8
 
8
9
  class String
9
10
  def to_utf16(terminate=false)
@@ -27,8 +28,8 @@ module Integration
27
28
 
28
29
  # == TC_OpenClose =========================================================
29
30
 
30
- test_case = Class.new( Test::Unit::TestCase ) do
31
- define_method( "test_create_close" ) do
31
+ test_case = Class.new( Test::Unit::TestCase ) do
32
+ define_method( "test_create_close" ) do
32
33
  begin
33
34
  db = SQLite3::Database.new( "test-create.db",
34
35
  :driver => driver )
@@ -39,7 +40,7 @@ module Integration
39
40
  end
40
41
  end
41
42
 
42
- define_method( "test_open_close" ) do
43
+ define_method( "test_open_close" ) do
43
44
  begin
44
45
  File.open( "test-open.db", "w" ) { |f| }
45
46
  assert File.exist?( "test-open.db" )
@@ -51,7 +52,7 @@ module Integration
51
52
  end
52
53
  end
53
54
 
54
- define_method( "test_bad_open" ) do
55
+ define_method( "test_bad_open" ) do
55
56
  assert_raise( SQLite3::CantOpenException ) do
56
57
  SQLite3::Database.new( ".", :driver => driver )
57
58
  end
@@ -61,7 +62,7 @@ module Integration
61
62
 
62
63
  # == TC_Database ==========================================================
63
64
 
64
- test_case = Class.new( Test::Unit::TestCase ) do
65
+ test_case = Class.new( Test::Unit::TestCase ) do
65
66
  define_method( "setup" ) do
66
67
  @db = SQLite3::Database.new( "test.db", :driver=>driver )
67
68
  @db.transaction do
@@ -93,6 +94,17 @@ module Integration
93
94
  end
94
95
  end
95
96
 
97
+ define_method( "test_table_info_without_defaults_for_version_3_3_8_and_higher" ) do
98
+ @db.transaction do
99
+ @db.execute "create table no_defaults_test ( a integer default 1, b integer )"
100
+ data = @db.table_info( "no_defaults_test" )
101
+ assert_equal({"name" => "a", "type" => "integer", "dflt_value" => "1", "notnull" => "0", "cid" => "0", "pk" => "0"},
102
+ data[0])
103
+ assert_equal({"name" => "b", "type" => "integer", "dflt_value" => nil, "notnull" => "0", "cid" => "1", "pk" => "0"},
104
+ data[1])
105
+ end
106
+ end
107
+
96
108
  define_method( "test_complete_fail" ) do
97
109
  assert !@db.complete?( "select * from foo" )
98
110
  end
@@ -244,7 +256,7 @@ module Integration
244
256
  assert [ "a", "b" ], row unless called == 0
245
257
  called += 1
246
258
  end
247
- assert_equal 1, called
259
+ assert_equal 1, called
248
260
  end
249
261
 
250
262
  define_method( "test_execute2_no_block_with_bind_no_match" ) do
@@ -519,83 +531,93 @@ module Integration
519
531
  end
520
532
 
521
533
  define_method( "test_busy_handler_outwait" ) do
522
- begin
523
- db2 = SQLite3::Database.open( "test.db", :driver=>driver )
524
- handler_call_count = 0
525
- db2.busy_handler do |data,count|
526
- handler_call_count += 1
527
- sleep 0.5
528
- 1
529
- end
530
-
531
- t = Thread.new do
532
- @db.transaction( :exclusive ) do
533
- sleep 0.3
534
+ busy = Mutex.new
535
+ busy.lock
536
+ handler_call_count = 0
537
+
538
+ t = Thread.new do
539
+ begin
540
+ db2 = SQLite3::Database.open( "test.db", :driver=>driver )
541
+ db2.transaction( :exclusive ) do
542
+ busy.lock
534
543
  end
544
+ ensure
545
+ db2.close if db2
535
546
  end
547
+ end
536
548
 
537
- assert_nothing_raised do
538
- db2.execute "insert into foo (b) values ( 'from 2' )"
539
- end
540
-
541
- assert_equal 1, handler_call_count
549
+ @db.busy_handler do |data,count|
550
+ handler_call_count += 1
551
+ busy.unlock
552
+ true
553
+ end
542
554
 
543
- t.join
544
- ensure
545
- db2.close if db2
555
+ assert_nothing_raised do
556
+ @db.execute "insert into foo (b) values ( 'from 2' )"
546
557
  end
558
+
559
+ t.join
560
+
561
+ assert_equal 1, handler_call_count
547
562
  end
548
563
 
549
564
  define_method( "test_busy_handler_impatient" ) do
550
- begin
551
- db2 = SQLite3::Database.open( "test.db", :driver=>driver )
552
- handler_call_count = 0
553
- db2.busy_handler do |data,count|
554
- handler_call_count += 1
555
- sleep 0.1
556
- 0
557
- end
558
-
559
- t = Thread.new do
560
- @db.transaction( :exclusive ) do
561
- sleep 0.2
565
+ busy = Mutex.new
566
+ busy.lock
567
+ handler_call_count = 0
568
+
569
+ t = Thread.new do
570
+ begin
571
+ db2 = SQLite3::Database.open( "test.db", :driver=>driver )
572
+ db2.transaction( :exclusive ) do
573
+ busy.lock
562
574
  end
575
+ ensure
576
+ db2.close if db2
563
577
  end
578
+ end
564
579
 
565
- assert_raise( SQLite3::BusyException ) do
566
- db2.execute "insert into foo (b) values ( 'from 2' )"
567
- end
568
-
569
- assert_equal 1, handler_call_count
580
+ @db.busy_handler do |data, count|
581
+ handler_call_count += 1
582
+ false
583
+ end
570
584
 
571
- t.join
572
- ensure
573
- db2.close if db2
585
+ assert_raise( SQLite3::BusyException ) do
586
+ @db.execute "insert into foo (b) values ( 'from 2' )"
574
587
  end
588
+
589
+ busy.unlock
590
+ t.join
591
+
592
+ assert_equal 1, handler_call_count
575
593
  end
576
594
 
577
595
  define_method( "test_busy_timeout" ) do
578
- begin
579
- db2 = SQLite3::Database.open( "test.db", :driver=>driver )
580
- db2.busy_timeout 300
581
-
582
- t = Thread.new do
583
- @db.transaction( :exclusive ) do
584
- sleep 0.1
596
+ @db.busy_timeout 1000
597
+ busy = Mutex.new
598
+ busy.lock
599
+
600
+ t = Thread.new do
601
+ begin
602
+ db2 = SQLite3::Database.open( "test.db", :driver=>driver )
603
+ db2.transaction( :exclusive ) do
604
+ busy.lock
585
605
  end
606
+ ensure
607
+ db2.close if db2
586
608
  end
609
+ end
587
610
 
588
- time = Benchmark.measure do
589
- assert_raise( SQLite3::BusyException ) do
590
- db2.execute "insert into foo (b) values ( 'from 2' )"
591
- end
611
+ time = Benchmark.measure do
612
+ assert_raise( SQLite3::BusyException ) do
613
+ @db.execute "insert into foo (b) values ( 'from 2' )"
592
614
  end
593
- assert time.real*1000 >= 300
594
-
595
- t.join
596
- ensure
597
- db2.close if db2
598
615
  end
616
+
617
+ busy.unlock
618
+ t.join
619
+
620
+ assert time.real*1000 >= 1000
599
621
  end
600
622
 
601
623
  define_method( "test_create_function" ) do
@@ -679,7 +701,7 @@ module Integration
679
701
 
680
702
  # == TC_Statement =========================================================
681
703
 
682
- test_case = Class.new( Test::Unit::TestCase ) do
704
+ test_case = Class.new( Test::Unit::TestCase ) do
683
705
  define_method( "setup" ) do
684
706
  @db = SQLite3::Database.new( "test.db", :driver=>driver )
685
707
  @db.transaction do
@@ -876,7 +898,7 @@ module Integration
876
898
 
877
899
  # == TC_ResultSet =========================================================
878
900
 
879
- test_case = Class.new( Test::Unit::TestCase ) do
901
+ test_case = Class.new( Test::Unit::TestCase ) do
880
902
  define_method( "setup" ) do
881
903
  @db = SQLite3::Database.new( "test.db", :driver=>driver )
882
904
  @db.transaction do
@@ -948,6 +970,32 @@ module Integration
948
970
  end
949
971
  end
950
972
 
973
+ define_method( "test_type_translation_with_null_column" ) do
974
+ @db.type_translation = true
975
+ @db.execute "create table bar ( a integer, b time, c string )"
976
+ @db.execute "insert into bar (a, b, c) values (NULL, '1974-07-25 14:39:00', 'hello')"
977
+ @db.execute "insert into bar (a, b, c) values (1, NULL, 'hello')"
978
+ @db.execute "insert into bar (a, b, c) values (2, '1974-07-25 14:39:00', NULL)"
979
+ @db.query( "select * from bar" ) do |result|
980
+ assert_equal [nil, Time.local(1974, 7, 25, 14, 39, 0), 'hello'], result.next
981
+ assert_equal [1, nil, 'hello'], result.next
982
+ assert_equal [2, Time.local(1974, 7, 25, 14, 39, 0), nil], result.next
983
+ end
984
+ end
985
+
986
+ define_method( "test_date_and_time_translation" ) do
987
+ @db.type_translation = true
988
+ @db.execute "create table bar ( a date, b datetime, c time, d timestamp )"
989
+ @db.execute "insert into bar (a, b, c, d) values ('1999-01-08', '1997-12-17 07:37:16', '07:37:16', '2004-10-19 10:23:54')"
990
+ @db.query( "select * from bar" ) do |result|
991
+ result = result.next
992
+ assert result[0].is_a?(Date)
993
+ assert result[1].is_a?(DateTime)
994
+ assert result[2].is_a?(Time)
995
+ assert result[3].is_a?(Time)
996
+ end
997
+ end
998
+
951
999
  define_method( "test_next_results_as_hash" ) do
952
1000
  @db.results_as_hash = true
953
1001
  @result.reset( 1 )
data/test/tests.rb CHANGED
@@ -1,36 +1,6 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
4
- # All rights reserved.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions are met:
8
- #
9
- # * Redistributions of source code must retain the above copyright notice,
10
- # this list of conditions and the following disclaimer.
11
- #
12
- # * Redistributions in binary form must reproduce the above copyright
13
- # notice, this list of conditions and the following disclaimer in the
14
- # documentation and/or other materials provided with the distribution.
15
- #
16
- # * The names of its contributors may not be used to endorse or promote
17
- # products derived from this software without specific prior written
18
- # permission.
19
- #
20
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
- # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
- # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
- # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
- # POSSIBILITY OF SUCH DAMAGE.
31
- # =============================================================================
32
- #++
33
-
34
-
35
1
  Dir.chdir File.dirname( __FILE__ )
2
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
3
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../ext/sqlite3_api"
4
+ p $LOAD_PATH
5
+
36
6
  Dir["**/tc_*.rb"].each { |file| load file }
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: sqlite3-ruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.1
7
- date: 2007-02-03 00:00:00 -07:00
6
+ version: 1.2.2
7
+ date: 2008-05-31 00:00:00 -06:00
8
8
  summary: SQLite3/Ruby is a module to allow Ruby scripts to interface with a SQLite database.
9
9
  require_paths:
10
10
  - lib
@@ -12,7 +12,7 @@ email: jamis@37signals.com
12
12
  homepage: http://sqlite-ruby.rubyforge.org/sqlite3
13
13
  rubyforge_project:
14
14
  description:
15
- autorequire: sqlite3
15
+ autorequire:
16
16
  default_executable:
17
17
  bindir: bin
18
18
  has_rdoc: true
@@ -30,23 +30,28 @@ authors:
30
30
  - Jamis Buck
31
31
  files:
32
32
  - doc/faq
33
- - doc/faq/faq.html
34
33
  - doc/faq/faq.rb
35
34
  - doc/faq/faq.yml
36
35
  - ext/sqlite3_api
37
36
  - ext/sqlite3_api/extconf.rb
38
- - ext/sqlite3_api/Makefile
39
37
  - ext/sqlite3_api/MANIFEST
40
38
  - ext/sqlite3_api/sqlite3_api.i
41
39
  - ext/sqlite3_api/sqlite3_api_wrap.c
40
+ - ext/sqlite3_api/sqlite3_api_wrap.dll
41
+ - ext/sqlite3_api/sqlite3_api_wrap.exp
42
+ - ext/sqlite3_api/sqlite3_api_wrap.lib
43
+ - ext/sqlite3_api/sqlite3_api_wrap.obj
42
44
  - ext/sqlite3_api/win32
43
45
  - ext/sqlite3_api/win32/build.bat
44
46
  - lib/sqlite3
45
- - lib/sqlite3.rb
46
- - lib/sqlite3_api.so
47
47
  - lib/sqlite3/constants.rb
48
48
  - lib/sqlite3/database.rb
49
49
  - lib/sqlite3/driver
50
+ - lib/sqlite3/driver/dl
51
+ - lib/sqlite3/driver/dl/api.rb
52
+ - lib/sqlite3/driver/dl/driver.rb
53
+ - lib/sqlite3/driver/native
54
+ - lib/sqlite3/driver/native/driver.rb
50
55
  - lib/sqlite3/errors.rb
51
56
  - lib/sqlite3/pragmas.rb
52
57
  - lib/sqlite3/resultset.rb
@@ -54,29 +59,26 @@ files:
54
59
  - lib/sqlite3/translator.rb
55
60
  - lib/sqlite3/value.rb
56
61
  - lib/sqlite3/version.rb
57
- - lib/sqlite3/driver/dl
58
- - lib/sqlite3/driver/native
59
- - lib/sqlite3/driver/dl/api.rb
60
- - lib/sqlite3/driver/dl/driver.rb
61
- - lib/sqlite3/driver/native/driver.rb
62
+ - lib/sqlite3.rb
63
+ - lib/sqlite3_api.dll
62
64
  - test/bm.rb
63
65
  - test/driver
66
+ - test/driver/dl
67
+ - test/driver/dl/tc_driver.rb
64
68
  - test/mocks.rb
65
69
  - test/native-vs-dl.rb
66
70
  - test/tc_database.rb
67
71
  - test/tc_errors.rb
68
72
  - test/tc_integration.rb
69
73
  - test/tests.rb
70
- - test/driver/dl
71
- - test/driver/dl/tc_driver.rb
72
- - README
74
+ - README.rdoc
73
75
  test_files:
74
76
  - test/tests.rb
75
77
  rdoc_options:
76
78
  - --main
77
- - README
79
+ - README.rdoc
78
80
  extra_rdoc_files:
79
- - README
81
+ - README.rdoc
80
82
  executables: []
81
83
 
82
84
  extensions: []