fireruby 0.2.2-i586-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +289 -0
- data/doc/license.txt +411 -0
- data/examples/example01.rb +60 -0
- data/lib/fireruby.bundle +0 -0
- data/lib/fireruby.so +0 -0
- data/lib/mkdoc +1 -0
- data/lib/src.rb +879 -0
- data/test/ConnectionTest.rb +92 -0
- data/test/DDLTest.rb +50 -0
- data/test/DatabaseTest.rb +81 -0
- data/test/GeneratorTest.rb +48 -0
- data/test/ResultSetTest.rb +97 -0
- data/test/RowTest.rb +49 -0
- data/test/SQLTest.rb +171 -0
- data/test/StatementTest.rb +124 -0
- data/test/TestSetup.rb +10 -0
- data/test/TransactionTest.rb +108 -0
- data/test/UnitTest.rb +11 -0
- metadata +58 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'TestSetup'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
7
|
+
|
8
|
+
include FireRuby
|
9
|
+
|
10
|
+
class StatementTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}stmt_unit_test.fdb"
|
13
|
+
|
14
|
+
def setup
|
15
|
+
if File::exist?(DB_FILE)
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
|
+
end
|
18
|
+
@database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
19
|
+
@connections = []
|
20
|
+
@transactions = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
@transactions.each do |tx|
|
25
|
+
tx.rollback if tx.active?
|
26
|
+
end
|
27
|
+
@transactions.clear
|
28
|
+
@connections.each do |cxn|
|
29
|
+
cxn.close if cxn.open?
|
30
|
+
end
|
31
|
+
@connections.clear
|
32
|
+
if File::exist?(DB_FILE)
|
33
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test01
|
38
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
39
|
+
@transactions.push(@connections.last.start_transaction)
|
40
|
+
|
41
|
+
s1 = Statement.new(@connections[0],
|
42
|
+
@transactions[0],
|
43
|
+
"SELECT RDB$FIELD_NAME FROM RDB$FIELDS", 3)
|
44
|
+
assert(s1 != nil)
|
45
|
+
assert(s1.sql == "SELECT RDB$FIELD_NAME FROM RDB$FIELDS")
|
46
|
+
assert(s1.connection == @connections[0])
|
47
|
+
assert(s1.transaction == @transactions[0])
|
48
|
+
assert(s1.dialect == 3)
|
49
|
+
assert(s1.is_query? == true)
|
50
|
+
|
51
|
+
s2 = Statement.new(@connections[0],
|
52
|
+
@transactions[0],
|
53
|
+
"DELETE FROM RDB$EXCEPTIONS", 1)
|
54
|
+
assert(s2 != nil)
|
55
|
+
assert(s2.sql == "DELETE FROM RDB$EXCEPTIONS")
|
56
|
+
assert(s2.connection == @connections[0])
|
57
|
+
assert(s2.transaction == @transactions[0])
|
58
|
+
assert(s2.dialect == 1)
|
59
|
+
assert(s2.is_query? == false)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test02
|
63
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
64
|
+
@transactions.push(@connections[0].start_transaction)
|
65
|
+
|
66
|
+
s = Statement.new(@connections[0], @transactions[0],
|
67
|
+
"SELECT RDB$FIELD_NAME FROM RDB$FIELDS "\
|
68
|
+
"WHERE RDB$FIELD_NAME LIKE ?", 3)
|
69
|
+
|
70
|
+
begin
|
71
|
+
s.execute
|
72
|
+
assert(false,
|
73
|
+
"Executed statement that required parameter without the "\
|
74
|
+
"parameter being specified.")
|
75
|
+
rescue Exception => error
|
76
|
+
end
|
77
|
+
|
78
|
+
begin
|
79
|
+
s.execute_for([])
|
80
|
+
assert(false,
|
81
|
+
"Executed statement that required a parameter with an empty "\
|
82
|
+
"parameter set.")
|
83
|
+
rescue Exception => error
|
84
|
+
end
|
85
|
+
|
86
|
+
begin
|
87
|
+
s.execute_for(['LALALA', 25])
|
88
|
+
assert(false,
|
89
|
+
"Executed statement that required a parameter with too many "\
|
90
|
+
"parameters.")
|
91
|
+
rescue Exception => error
|
92
|
+
end
|
93
|
+
|
94
|
+
assert(s.execute_for(['LALALA']) != nil)
|
95
|
+
assert(s.execute_for(['LALALA']).class == ResultSet)
|
96
|
+
total = 0
|
97
|
+
s.execute_for(["%"]) do |row|
|
98
|
+
total = total + 1
|
99
|
+
end
|
100
|
+
assert(total = 88)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test03
|
104
|
+
d = nil
|
105
|
+
@database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
|
106
|
+
cxn.execute_immediate('CREATE TABLE STRING_TEST(TEXT VARCHAR(10))')
|
107
|
+
cxn.start_transaction do |tx|
|
108
|
+
# Perform an trancated insert.
|
109
|
+
s = Statement.new(cxn, tx, 'INSERT INTO STRING_TEST VALUES(?)', 3)
|
110
|
+
s.execute_for(['012345678901234'])
|
111
|
+
|
112
|
+
# Perform a select of the value inserted.
|
113
|
+
r = cxn.execute('SELECT * FROM STRING_TEST', tx)
|
114
|
+
d = r.fetch
|
115
|
+
|
116
|
+
# Clean up.
|
117
|
+
s.close
|
118
|
+
r.close
|
119
|
+
end
|
120
|
+
assert(d[0] == '0123456789')
|
121
|
+
cxn.execute_immediate('DROP TABLE STRING_TEST')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/test/TestSetup.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'TestSetup'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'
|
6
|
+
require_gem 'fireruby'
|
7
|
+
|
8
|
+
include FireRuby
|
9
|
+
|
10
|
+
class TransactionTest < Test::Unit::TestCase
|
11
|
+
CURDIR = "#{Dir.getwd}"
|
12
|
+
DB_FILE = "#{CURDIR}#{File::SEPARATOR}tx_unit_test.fdb"
|
13
|
+
|
14
|
+
def setup
|
15
|
+
if File::exist?(DB_FILE)
|
16
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
17
|
+
end
|
18
|
+
|
19
|
+
@database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, nil)
|
20
|
+
@connections = []
|
21
|
+
@transactions = []
|
22
|
+
|
23
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
24
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
25
|
+
@connections.push(@database.connect(DB_USER_NAME, DB_PASSWORD))
|
26
|
+
end
|
27
|
+
|
28
|
+
def teardown
|
29
|
+
@transactions.each do |tx|
|
30
|
+
tx.rollback if tx.active?
|
31
|
+
end
|
32
|
+
@transactions.clear
|
33
|
+
@connections.each do |cxn|
|
34
|
+
cxn.close if cxn.open?
|
35
|
+
end
|
36
|
+
if File::exist?(DB_FILE)
|
37
|
+
Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test01
|
42
|
+
@transactions.push(@connections[0].start_transaction)
|
43
|
+
assert(@transactions[0].active?)
|
44
|
+
|
45
|
+
@transactions.push(Transaction.new(@connections[1]))
|
46
|
+
assert(@transactions[1].active?)
|
47
|
+
|
48
|
+
assert(@transactions[0].connections == [@connections[0]])
|
49
|
+
assert(@transactions[1].connections == [@connections[1]])
|
50
|
+
|
51
|
+
assert(@transactions[0].for_connection?(@connections[1]) == false)
|
52
|
+
assert(@transactions[1].for_connection?(@connections[0]) == false)
|
53
|
+
assert(@transactions[0].for_connection?(@connections[0]))
|
54
|
+
assert(@transactions[1].for_connection?(@connections[1]))
|
55
|
+
|
56
|
+
@transactions[0].commit
|
57
|
+
assert(@transactions[0].active? == false)
|
58
|
+
assert(@transactions[0].connections == [])
|
59
|
+
assert(@transactions[0].for_connection?(@connections[0]) == false)
|
60
|
+
assert(@transactions[0].for_connection?(@connections[1]) == false)
|
61
|
+
|
62
|
+
@transactions[1].rollback
|
63
|
+
assert(@transactions[1].active? == false)
|
64
|
+
assert(@transactions[1].connections == [])
|
65
|
+
assert(@transactions[1].for_connection?(@connections[0]) == false)
|
66
|
+
assert(@transactions[1].for_connection?(@connections[1]) == false)
|
67
|
+
|
68
|
+
@transactions[0] = Transaction.new([@connections[0], @connections[1]])
|
69
|
+
assert(@transactions[0].active? == true)
|
70
|
+
assert(@transactions[0].for_connection?(@connections[0]))
|
71
|
+
assert(@transactions[0].for_connection?(@connections[1]))
|
72
|
+
assert(@transactions[0].for_connection?(@connections[2]) == false)
|
73
|
+
|
74
|
+
@transactions[0].commit
|
75
|
+
assert(@transactions[0].active? == false)
|
76
|
+
assert(@transactions[0].connections == [])
|
77
|
+
assert(@transactions[0].for_connection?(@connections[0]) == false)
|
78
|
+
assert(@transactions[0].for_connection?(@connections[1]) == false)
|
79
|
+
assert(@transactions[0].for_connection?(@connections[2]) == false)
|
80
|
+
|
81
|
+
@transactions[0] = Transaction.new([@connections[0], @connections[2]])
|
82
|
+
assert(@transactions[0].active?)
|
83
|
+
@transactions[0].rollback
|
84
|
+
assert(@transactions[0].active? == false)
|
85
|
+
assert(@transactions[0].connections == [])
|
86
|
+
assert(@transactions[0].for_connection?(@connections[0]) == false)
|
87
|
+
assert(@transactions[0].for_connection?(@connections[1]) == false)
|
88
|
+
assert(@transactions[0].for_connection?(@connections[2]) == false)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test02
|
92
|
+
sql = []
|
93
|
+
sql.push("UPDATE RDB$EXCEPTIONS SET RDB$MESSAGE = 'WoooHooo'"\
|
94
|
+
"WHERE RDB$EXCEPTION_NAME = 'Lalala'")
|
95
|
+
sql.push("SELECT RDB$FIELD_NAME FROM RDB$FIELDS")
|
96
|
+
@transactions.push(Transaction.new(@connections[0]))
|
97
|
+
|
98
|
+
assert(@transactions[0].execute(sql[0]) == nil)
|
99
|
+
assert(@transactions[0].execute(sql[1]) != nil)
|
100
|
+
assert(@transactions[0].execute(sql[1]).class == ResultSet)
|
101
|
+
|
102
|
+
total = 0
|
103
|
+
@transactions[0].execute(sql[1]) do |row|
|
104
|
+
total += 1
|
105
|
+
end
|
106
|
+
assert(total = 88)
|
107
|
+
end
|
108
|
+
end
|
data/test/UnitTest.rb
ADDED
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.10
|
3
|
+
specification_version: 1
|
4
|
+
name: fireruby
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2005-04-12
|
8
|
+
summary: Ruby interface library for the Firebird database.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: paw220470@yahoo.ie
|
12
|
+
homepage: http://rubyforge.org/projects/fireruby/
|
13
|
+
rubyforge_project:
|
14
|
+
description: FireRuby is an extension to the Ruby programming language that provides access to the Firebird open source RDBMS. FireRuby is based in the Firebird C API and has no additional dependencies. The FireRuby library wraps the API calls in a Ruby OO interface.
|
15
|
+
autorequire: fireruby
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
-
|
22
|
+
- ">"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.0
|
25
|
+
version:
|
26
|
+
platform: i586-linux
|
27
|
+
authors:
|
28
|
+
- Peter Wood
|
29
|
+
files:
|
30
|
+
- lib/mkdoc
|
31
|
+
- lib/fireruby.bundle
|
32
|
+
- lib/fireruby.so
|
33
|
+
- lib/src.rb
|
34
|
+
- test/SQLTest.rb
|
35
|
+
- test/DatabaseTest.rb
|
36
|
+
- test/StatementTest.rb
|
37
|
+
- test/ConnectionTest.rb
|
38
|
+
- test/TransactionTest.rb
|
39
|
+
- test/TestSetup.rb
|
40
|
+
- test/UnitTest.rb
|
41
|
+
- test/DDLTest.rb
|
42
|
+
- test/ResultSetTest.rb
|
43
|
+
- test/RowTest.rb
|
44
|
+
- test/GeneratorTest.rb
|
45
|
+
- doc/README
|
46
|
+
- doc/license.txt
|
47
|
+
- examples/example01.rb
|
48
|
+
test_files:
|
49
|
+
- test/UnitTest.rb
|
50
|
+
rdoc_options:
|
51
|
+
- "--main"
|
52
|
+
- doc/README
|
53
|
+
extra_rdoc_files:
|
54
|
+
- doc/README
|
55
|
+
executables: []
|
56
|
+
extensions: []
|
57
|
+
requirements: []
|
58
|
+
dependencies: []
|