dbd-sqlite 0.1

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.
@@ -0,0 +1,23 @@
1
+ create table names (name varchar(255), age integer);
2
+ ---
3
+ insert into names (name, age) values ("Bob", 21);
4
+ ---
5
+ insert into names (name, age) values ("Joe", 19);
6
+ ---
7
+ insert into names (name, age) values ("Jim", 30);
8
+ ---
9
+ create table precision_test (text_field varchar(20) primary key not null, integer_field decimal(2,1));
10
+ ---
11
+ create view view_names as select * from names;
12
+ ---
13
+ create table blob_test (name varchar(255));
14
+ ---
15
+ create table boolean_test (num integer, mybool boolean);
16
+ ---
17
+ create table time_test (mytime time);
18
+ ---
19
+ create table timestamp_test (mytimestamp timestamp);
20
+ ---
21
+ create table bit_test (mybit bit);
22
+ ---
23
+ create table field_types_test (foo integer not null primary key default 1);
data/test/ts_dbd.rb ADDED
@@ -0,0 +1,118 @@
1
+ # figure out what tests to run
2
+ require 'yaml'
3
+ require 'test/unit/testsuite'
4
+ require 'test/unit/ui/console/testrunner'
5
+
6
+ if File.basename(Dir.pwd) == "test"
7
+ $:.unshift('../lib')
8
+ else
9
+ $:.unshift('lib')
10
+ end
11
+
12
+ module Test::Unit::Assertions
13
+ def build_message(head, template=nil, *arguments)
14
+ template += "\n" + "DATABASE: " + dbtype
15
+ template &&= template.chomp
16
+ return AssertionMessage.new(head, template, arguments)
17
+ end
18
+ end
19
+
20
+ module DBDConfig
21
+ @testbase = { }
22
+ @current_dbtype = nil
23
+
24
+ def self.get_config
25
+ config = nil
26
+
27
+ begin
28
+ config = YAML.load_file(File.join(ENV["HOME"], ".ruby-dbi.test-config.yaml"))
29
+ rescue Exception => e
30
+ config = { }
31
+ config["dbtypes"] = [ ]
32
+ end
33
+
34
+ return config
35
+ end
36
+
37
+ def self.inject_sql(dbh, dbtype, file)
38
+ # splits by --- in the file, strips newlines and the semicolons.
39
+ # this way we can still manually import the file, but use it with our
40
+ # drivers for client-independent injection.
41
+ File.open(file).read.split(/\n*---\n*/, -1).collect { |x| x.gsub!(/\n/, ''); x.sub(/;\z/, '') }.each do |stmt|
42
+ tmp = STDERR.dup
43
+ STDERR.reopen('sql.log', 'a')
44
+ begin
45
+ dbh.commit rescue nil
46
+ dbh["AutoCommit"] = true rescue nil
47
+ dbh.do(stmt)
48
+ dbh.commit unless dbtype == 'sqlite3'
49
+ rescue Exception => e
50
+ tmp.puts "Error injecting '#{stmt}' for db #{dbtype}"
51
+ tmp.puts "Error: #{e.message}"
52
+ end
53
+ STDERR.reopen(tmp)
54
+ end
55
+ end
56
+
57
+ def self.current_dbtype
58
+ @current_dbtype
59
+ end
60
+
61
+ def self.current_dbtype=(setting)
62
+ @current_dbtype = setting
63
+ end
64
+
65
+ def self.testbase(klass_name)
66
+ return @testbase[klass_name]
67
+ end
68
+
69
+ def self.set_testbase(klass_name, klass)
70
+ @testbase[klass_name] = klass
71
+ end
72
+
73
+ def self.suite
74
+ @suite ||= []
75
+ end
76
+ end
77
+
78
+ if __FILE__ == $0
79
+ Dir.chdir("..") if File.basename(Dir.pwd) == "test"
80
+ $LOAD_PATH.unshift(File.join(Dir.pwd, "lib"))
81
+ Dir.chdir("test") rescue nil
82
+
83
+ begin
84
+ require 'dbi'
85
+ rescue LoadError => e
86
+ begin
87
+ require 'rubygems'
88
+ gem 'dbi'
89
+ require 'dbi'
90
+ rescue LoadError => e
91
+ abort "DBI must already be installed or must come with this package for tests to work."
92
+ end
93
+ end
94
+
95
+ Deprecate.set_action(proc { })
96
+
97
+ config = DBDConfig.get_config
98
+
99
+ config["dbtypes"] = ENV["DBTYPES"].split(/\s+/) if ENV["DBTYPES"]
100
+
101
+ if config and config["dbtypes"]
102
+ config["dbtypes"].each do |dbtype|
103
+ unless config[dbtype]
104
+ warn "#{dbtype} is selected for testing but not configured; see test/DBD_TESTS"
105
+ next
106
+ end
107
+
108
+ # base.rb is special, see DBD_TESTS
109
+ require "dbd/#{dbtype}/base.rb"
110
+ Dir["dbd/#{dbtype}/test*.rb"].each { |file| require file }
111
+ # run the general tests
112
+ DBDConfig.current_dbtype = dbtype.to_sym
113
+ Dir["dbd/general/test*.rb"].each { |file| load file; DBDConfig.suite << @class }
114
+ end
115
+ elsif !config["dbtypes"]
116
+ warn "Please see test/DBD_TESTS for information on configuring DBD tests."
117
+ end
118
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dbd-sqlite
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Erik Hollensbe
8
+ - Christopher Maujean
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-08-23 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: dbi
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.4.0
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: sqlite-ruby
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ version:
36
+ description: SQLite 2.x DBI DBD
37
+ email: ruby-dbi-users@rubyforge.org
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - README
44
+ - LICENSE
45
+ - ChangeLog
46
+ files:
47
+ - test/dbd/general/test_types.rb
48
+ - test/dbd/general/test_database.rb
49
+ - test/dbd/general/test_statement.rb
50
+ - test/dbd/sqlite/test_database.rb
51
+ - test/dbd/sqlite/test_driver.rb
52
+ - test/dbd/sqlite/up.sql
53
+ - test/dbd/sqlite/base.rb
54
+ - test/dbd/sqlite/test_statement.rb
55
+ - lib/dbd/SQLite.rb
56
+ - lib/dbd/sqlite/database.rb
57
+ - lib/dbd/sqlite/statement.rb
58
+ - test/DBD_TESTS
59
+ - README
60
+ - LICENSE
61
+ - ChangeLog
62
+ has_rdoc: true
63
+ homepage: http://www.rubyforge.org/projects/ruby-dbi
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.8.0
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: ruby-dbi
84
+ rubygems_version: 1.2.0
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: SQLite 2.x DBI DBD
88
+ test_files:
89
+ - test/ts_dbd.rb