rubyfb 0.5.9 → 0.6

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.
@@ -3,10 +3,14 @@ module Arel
3
3
  class RubyFB < Arel::Visitors::ToSql
4
4
  Arel::Visitors::VISITORS['rubyfb'] = Arel::Visitors::RubyFB
5
5
  private
6
+ def visit_Arel_Nodes_Limit o
7
+ end
8
+
9
+ def visit_Arel_Nodes_Offset o
10
+ end
11
+
6
12
  def visit_Arel_Nodes_SelectStatement o
7
- limit = o.limit; o.limit = nil;
8
- offset = o.offset; o.offset = nil;
9
- limit || offset ? "SELECT #{fb_limit(limit)} #{fb_offset(offset)} * FROM (#{super})" : super
13
+ o.limit || o.offset ? "SELECT #{fb_limit(o.limit)} #{fb_offset(o.offset)} * FROM (#{super})" : super
10
14
  end
11
15
 
12
16
  def fb_limit limit
@@ -3,12 +3,16 @@ module Arel
3
3
  class RubyFB_15Compat < Arel::Visitors::ToSql
4
4
  Arel::Visitors::VISITORS['rubyfb'] = Arel::Visitors::RubyFB_15Compat
5
5
  private
6
+ def visit_Arel_Nodes_Limit o
7
+ end
8
+
9
+ def visit_Arel_Nodes_Offset o
10
+ end
11
+
6
12
  def visit_Arel_Nodes_SelectStatement o
7
- limit = o.limit; o.limit = nil;
8
- offset = o.offset; o.offset = nil;
9
13
  super.tap do |s|
10
- if limit || offset
11
- s.gsub!(/^\s*select/i, "SELECT #{fb_limit(limit)} #{fb_offset(offset)} ")
14
+ if o.limit || o.offset
15
+ s.gsub!(/^\s*select/i, "SELECT #{fb_limit(o.limit)} #{fb_offset(o.offset)} ")
12
16
  end
13
17
  end
14
18
  end
data/lib/rubyfb_lib.so CHANGED
Binary file
data/lib/src.rb CHANGED
@@ -360,6 +360,19 @@ module Rubyfb
360
360
  def execute_immediate(sql)
361
361
  yield(row)
362
362
  end
363
+
364
+ #
365
+ # This function creates a new statement object
366
+ #
367
+ # ==== Parameters
368
+ # sql:: The SQL for the statement.
369
+ #
370
+ # ==== Exceptions
371
+ # Exception:: Generated whenever a problem occurs creating the
372
+ # statement object.
373
+ #
374
+ def create_statement(sql)
375
+ end
363
376
  end
364
377
 
365
378
 
@@ -563,13 +576,9 @@ module Rubyfb
563
576
  # ==== Parameters
564
577
  # connection:: The Connection object that the SQL statement will be
565
578
  # executed through.
566
- # transaction:: The Transaction object that the SQL statement will be
567
- # executed under.
568
579
  # sql:: The SQL statement to be prepared for execution.
569
- # dialect:: The Firebird dialect to be used in preparing the SQL
570
- # statement.
571
580
  #
572
- def initialize(connection, transaction, sql, dialect)
581
+ def initialize(connection, sql)
573
582
  end
574
583
 
575
584
 
@@ -580,13 +589,6 @@ module Rubyfb
580
589
  end
581
590
 
582
591
 
583
- #
584
- # This is the accessor for the transaction attribute.
585
- #
586
- def transaction
587
- end
588
-
589
-
590
592
  #
591
593
  # This is the accessor for the SQL statement attribute.
592
594
  #
@@ -619,27 +621,28 @@ module Rubyfb
619
621
 
620
622
 
621
623
  #
622
- # This method executes the SQL statement within a Statement object. This
623
- # method returns a ResultSet object if the statement executed was a SQL
624
- # query. For non-query SQL statements (insert, update or delete) it
625
- # returns an Integer indicating the number of affected rows. For all other
626
- # statements the method returns nil. This method accepts a block taking a
627
- # single parameter. If this block is provided and the statement is a query
628
- # then the rows returned by the query will be passed, one at a time, to
629
- # the block.
624
+ # This method is used to determine whether a Statement object is prepared
625
+ #
626
+ def prepared?
627
+ end
628
+
629
+ #
630
+ # This method prepares the SQL statement
631
+ #
632
+ # ==== Parameters
633
+ # transaction:: A reference to the transaction object (optional).
634
+ # If this parameter is nil - the statement is prepared within
635
+ # its own (implicit) transaction.
630
636
  #
631
637
  # ==== Exception
632
- # Exception:: Generated if the Statement object actual requires some
633
- # parameters or a problem occurs executing the SQL statement.
638
+ # Exception:: Generated whenever a problem occurspreparing the SQL statement.
634
639
  #
635
- def execute
636
- yield row
640
+ def prepare(transaction=nil)
637
641
  end
638
-
639
-
642
+
640
643
  #
641
- # This method executes the SQL statement within a Statement object and
642
- # passes it a set of parameters. Parameterized statements use question
644
+ # This method executes the SQL statement within a Statement object optionaly
645
+ # passing it a set of parameters. Parameterized statements use question
643
646
  # marks as place holders for values that may change between calls to
644
647
  # execute the statement. This method returns a ResultSet object if the
645
648
  # statement executed was a SQL query. If the statement was a non-query SQL
@@ -650,21 +653,54 @@ module Rubyfb
650
653
  # returned by the query will be passed, one at a time, to the block.
651
654
  #
652
655
  # ==== Parameters
653
- # parameters:: An array of the parameters for the statement. An effort
656
+ # parameters:: An array of the parameters (optional) for the statement. An effort
654
657
  # will be made to convert the values passed in to the
655
658
  # appropriate types but no guarantees are made (especially
656
659
  # in the case of text fields, which will simply use to_s
657
660
  # if the object passed is not a String).
658
661
  #
662
+ # transaction:: A reference to the transaction object (optional).
663
+ # If this parameter is nil - the statement is execute within
664
+ # its own (implicit) transaction. For statements that return
665
+ # result set objects - the implicit transaction is resolved
666
+ # when the result set object is closed, for the other kind of statements
667
+ # the implicit transaction is resolved immediately after the execution
668
+ #
659
669
  # ==== Exception
660
670
  # Exception:: Generated whenever a problem occurs translating one of the
661
671
  # input parameters or executing the SQL statement.
662
672
  #
663
- def execute_for(parameters)
673
+ def exec(parameters=nil, transaction=nil)
664
674
  yield row
665
675
  end
666
676
 
667
-
677
+ #
678
+ # This method behaves exactly as the exec() method, except that the statement
679
+ # is also closed. If no result set is generated the statement is closed immediately,
680
+ # otherwise the statement close() call thakes place when the resul tset close() is called.
681
+ #
682
+ # ==== Parameters
683
+ # parameters:: An array of the parameters (optional) for the statement. An effort
684
+ # will be made to convert the values passed in to the
685
+ # appropriate types but no guarantees are made (especially
686
+ # in the case of text fields, which will simply use to_s
687
+ # if the object passed is not a String).
688
+ #
689
+ # transaction:: A reference to the transaction object (optional).
690
+ # If this parameter is nil - the statement is execute within
691
+ # its own (implicit) transaction. For statements that return
692
+ # result set objects - the implicit transaction is resolved
693
+ # when the result set object is closed, for the other kind of statements
694
+ # the implicit transaction is resolved immediately after the execution
695
+ #
696
+ # ==== Exception
697
+ # Exception:: Generated whenever a problem occurs translating one of the
698
+ # input parameters or executing the SQL statement.
699
+ #
700
+ def exec_and_close(parameters=nil, transaction=nil)
701
+ yield row
702
+ end
703
+
668
704
  #
669
705
  # This method releases the database resources associated with a Statement
670
706
  # object and should be explicitly called when a Statement object is of
@@ -693,14 +729,9 @@ module Rubyfb
693
729
  # This is the constructor for the ResultSet object.
694
730
  #
695
731
  # ==== Parameters
696
- # connection:: A reference to the Connection object that will be used
697
- # to execute the SQL query.
732
+ # statement:: A reference to the Statement object.
698
733
  # transaction:: A reference to the Transaction object that will be used
699
734
  # in executing the SQL query.
700
- # sql:: A reference to a String containing the SQL query that
701
- # will be executed.
702
- # dialect:: A reference to an integer containing the Firebird dialect
703
- # to be used in executing the SQL statement.
704
735
  #
705
736
  # ==== Exceptions
706
737
  # FireRubyException:: Generated whenever a non-query SQL statement is
@@ -708,7 +739,7 @@ module Rubyfb
708
739
  # provided or a problem occurs executing the SQL
709
740
  # against the database.
710
741
  #
711
- def initialize(connection, transaction, sql, dialect)
742
+ def initialize(statement, transaction)
712
743
  end
713
744
 
714
745
 
@@ -725,6 +756,11 @@ module Rubyfb
725
756
  def transaction
726
757
  end
727
758
 
759
+ #
760
+ # This is the accessor for the statement attribute.
761
+ #
762
+ def statement
763
+ end
728
764
 
729
765
  #
730
766
  # This is the accessor for the sql attribute.
@@ -908,6 +944,7 @@ module Rubyfb
908
944
  #
909
945
  def column_count
910
946
  end
947
+
911
948
 
912
949
 
913
950
  #
@@ -1151,7 +1188,7 @@ module Rubyfb
1151
1188
 
1152
1189
  #
1153
1190
  # This method loads the segments of a blob one after another. The blob
1154
- # segments are passed as strings to the block passed to the method.
1191
+ # segments are passed as BINARY strings to the block passed to the method.
1155
1192
  #
1156
1193
  def each
1157
1194
  yield segment
data/rubyfb.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rubyfb}
5
- s.version = "0.5.9"
5
+ s.version = "0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{George Georgiev}]
9
- s.date = %q{2011-06-06}
9
+ s.date = %q{2011-08-22}
10
10
  s.description = %q{Firebird SQL access library}
11
11
  s.email = %q{georgiev@heatbs.com}
12
12
  s.extensions = [%q{ext/extconf.rb}]
13
13
  s.extra_rdoc_files = [%q{CHANGELOG}, %q{LICENSE}, %q{README}, %q{examples/example01.rb}, %q{ext/extconf.rb}, %q{lib/Connection.rb}, %q{lib/ProcedureCall.rb}, %q{lib/SQLType.rb}, %q{lib/rubyfb.rb}, %q{lib/rubyfb_options.rb}, %q{lib/src.rb}]
14
- s.files = [%q{CHANGELOG}, %q{LICENSE}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{examples/example01.rb}, %q{ext/AddUser.c}, %q{ext/AddUser.h}, %q{ext/Backup.c}, %q{ext/Backup.h}, %q{ext/Blob.c}, %q{ext/Blob.h}, %q{ext/Common.c}, %q{ext/Common.h}, %q{ext/Connection.c}, %q{ext/Connection.h}, %q{ext/DataArea.c}, %q{ext/DataArea.h}, %q{ext/Database.c}, %q{ext/Database.h}, %q{ext/FireRuby.c}, %q{ext/FireRuby.h}, %q{ext/FireRubyException.c}, %q{ext/FireRubyException.h}, %q{ext/Generator.c}, %q{ext/Generator.h}, %q{ext/RemoveUser.c}, %q{ext/RemoveUser.h}, %q{ext/Restore.c}, %q{ext/Restore.h}, %q{ext/ResultSet.c}, %q{ext/ResultSet.h}, %q{ext/Row.c}, %q{ext/Row.h}, %q{ext/ServiceManager.c}, %q{ext/ServiceManager.h}, %q{ext/Services.c}, %q{ext/Services.h}, %q{ext/Statement.c}, %q{ext/Statement.h}, %q{ext/Transaction.c}, %q{ext/Transaction.h}, %q{ext/TypeMap.c}, %q{ext/TypeMap.h}, %q{ext/extconf.rb}, %q{ext/rfbint.h}, %q{ext/rfbsleep.h}, %q{ext/rfbstr.c}, %q{ext/rfbstr.h}, %q{ext/uncrustify.cfg}, %q{lib/Connection.rb}, %q{lib/ProcedureCall.rb}, %q{lib/SQLType.rb}, %q{lib/active_record/connection_adapters/rubyfb_adapter.rb}, %q{lib/arel/visitors/rubyfb.rb}, %q{lib/arel/visitors/rubyfb_15compat.rb}, %q{lib/mkdoc}, %q{lib/rubyfb.rb}, %q{lib/rubyfb_lib.so}, %q{lib/rubyfb_options.rb}, %q{lib/src.rb}, %q{mswin32fb/fbclient_mingw.def}, %q{mswin32fb/fbclient_mingw.lib}, %q{mswin32fb/fbclient_ms.lib}, %q{mswin32fb/ibase.h}, %q{mswin32fb/iberror.h}, %q{test/AddRemoveUserTest.rb}, %q{test/BackupRestoreTest.rb}, %q{test/BlobTest.rb}, %q{test/CharacterSetTest.rb}, %q{test/ConnectionTest.rb}, %q{test/DDLTest.rb}, %q{test/DatabaseTest.rb}, %q{test/FieldCharacterSetTest.rb}, %q{test/GeneratorTest.rb}, %q{test/KeyTest.rb}, %q{test/ResultSetTest.rb}, %q{test/RoleTest.rb}, %q{test/RowCountTest.rb}, %q{test/RowTest.rb}, %q{test/SQLTest.rb}, %q{test/SQLTypeTest.rb}, %q{test/ServiceManagerTest.rb}, %q{test/StatementTest.rb}, %q{test/TestSetup.rb}, %q{test/TransactionTest.rb}, %q{test/TypeTest.rb}, %q{rubyfb.gemspec}]
14
+ s.files = [%q{CHANGELOG}, %q{LICENSE}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{examples/example01.rb}, %q{ext/AddUser.c}, %q{ext/AddUser.h}, %q{ext/Backup.c}, %q{ext/Backup.h}, %q{ext/Blob.c}, %q{ext/Blob.h}, %q{ext/Common.c}, %q{ext/Common.h}, %q{ext/Connection.c}, %q{ext/Connection.h}, %q{ext/DataArea.c}, %q{ext/DataArea.h}, %q{ext/Database.c}, %q{ext/Database.h}, %q{ext/FireRuby.c}, %q{ext/FireRuby.h}, %q{ext/FireRubyException.c}, %q{ext/FireRubyException.h}, %q{ext/Generator.c}, %q{ext/Generator.h}, %q{ext/RemoveUser.c}, %q{ext/RemoveUser.h}, %q{ext/Restore.c}, %q{ext/Restore.h}, %q{ext/ResultSet.c}, %q{ext/ResultSet.h}, %q{ext/Row.c}, %q{ext/Row.h}, %q{ext/ServiceManager.c}, %q{ext/ServiceManager.h}, %q{ext/Services.c}, %q{ext/Services.h}, %q{ext/Statement.c}, %q{ext/Statement.h}, %q{ext/Transaction.c}, %q{ext/Transaction.h}, %q{ext/TypeMap.c}, %q{ext/TypeMap.h}, %q{ext/extconf.rb}, %q{ext/rfbint.h}, %q{ext/rfbsleep.h}, %q{ext/rfbstr.c}, %q{ext/rfbstr.h}, %q{ext/uncrustify.cfg}, %q{lib/Connection.rb}, %q{lib/ProcedureCall.rb}, %q{lib/SQLType.rb}, %q{lib/active_record/connection_adapters/rubyfb_adapter.rb}, %q{lib/arel/visitors/rubyfb.rb}, %q{lib/arel/visitors/rubyfb_15compat.rb}, %q{lib/mkdoc}, %q{lib/rubyfb.rb}, %q{lib/rubyfb_lib.so}, %q{lib/rubyfb_options.rb}, %q{lib/src.rb}, %q{mswin32fb/fbclient_mingw.def}, %q{mswin32fb/fbclient_mingw.lib}, %q{mswin32fb/fbclient_ms.lib}, %q{mswin32fb/ibase.h}, %q{mswin32fb/iberror.h}, %q{test/AddRemoveUserTest.rb}, %q{test/BackupRestoreTest.rb}, %q{test/BlobTest.rb}, %q{test/CharacterSetTest.rb}, %q{test/ConnectionTest.rb}, %q{test/DDLTest.rb}, %q{test/DatabaseTest.rb}, %q{test/FieldCharacterSetTest.rb}, %q{test/GeneratorTest.rb}, %q{test/KeyTest.rb}, %q{test/ResultSetTest.rb}, %q{test/RoleTest.rb}, %q{test/RowCountTest.rb}, %q{test/RowTest.rb}, %q{test/SQLTest.rb}, %q{test/SQLTypeTest.rb}, %q{test/ServiceManagerTest.rb}, %q{test/StatementTest.rb}, %q{test/StoredProcedureTest.rb}, %q{test/TestSetup.rb}, %q{test/TransactionTest.rb}, %q{test/TypeTest.rb}, %q{rubyfb.gemspec}]
15
15
  s.homepage = %q{http://rubyforge.org/projects/rubyfb}
16
16
  s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Rubyfb}, %q{--main}, %q{README}]
17
17
  s.require_paths = [%q{lib}, %q{ext}]
@@ -32,6 +32,13 @@ class AddRemoveUserTest < Test::Unit::TestCase
32
32
  sm = ServiceManager.new('localhost')
33
33
  sm.connect(DB_USER_NAME, DB_PASSWORD)
34
34
 
35
+ begin
36
+ ru = RemoveUser.new('newuser')
37
+ ru.execute(sm)
38
+ sleep(3)
39
+ rescue
40
+ end
41
+
35
42
  au = AddUser.new('newuser', 'password', 'first', 'middle', 'last')
36
43
  au.execute(sm)
37
44
  sleep(3)
@@ -69,7 +69,7 @@ class BackupRestoreTest < Test::Unit::TestCase
69
69
  assert([1000, 2000, 3000, 4000, nil].include?(row[0]))
70
70
  total += 1
71
71
  end
72
- assert(total == 5)
72
+ assert_equal(5, total)
73
73
  end
74
74
  end
75
75
 
data/test/BlobTest.rb CHANGED
@@ -39,8 +39,8 @@ class BlobTest < Test::Unit::TestCase
39
39
  cxn.execute_immediate('create table blob_test (data blob sub_type 0)')
40
40
  cxn.start_transaction do |tx|
41
41
 
42
- s = Statement.new(cxn, tx, 'INSERT INTO BLOB_TEST VALUES(?)', 3)
43
- s.execute_for([DATA])
42
+ s = cxn.create_statement('INSERT INTO BLOB_TEST VALUES(?)')
43
+ s.exec([DATA], tx)
44
44
 
45
45
  # Perform a select of the value inserted.
46
46
  r = cxn.execute('SELECT * FROM BLOB_TEST', tx)
@@ -62,14 +62,14 @@ class BlobTest < Test::Unit::TestCase
62
62
  cxn.execute_immediate('create table blob_test (data blob sub_type 1 segment size 10 CHARACTER SET UTF8)')
63
63
  cxn.start_transaction do |tx|
64
64
 
65
- s = Statement.new(cxn, tx, 'INSERT INTO BLOB_TEST VALUES(?)', 3)
66
- s.execute_for([UTF_DATA])
65
+ s = cxn.create_statement('INSERT INTO BLOB_TEST VALUES(?)')
66
+ s.exec([UTF_DATA], tx)
67
67
 
68
68
  # Perform a select of the value inserted.
69
69
  r = cxn.execute('SELECT * FROM BLOB_TEST', tx)
70
70
  d = r.fetch
71
71
 
72
- assert_equal(d[0].to_s, UTF_DATA)
72
+ assert_equal(UTF_DATA, d[0].to_s)
73
73
 
74
74
  # Clean up.
75
75
  s.close
@@ -33,17 +33,17 @@ class GeneratorTest < Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  def test01
36
- assert(Generator::exists?('TEST_GEN', @connections[0]) == false)
36
+ assert(!Generator::exists?('TEST_GEN', @connections[0]))
37
37
  g = Generator::create('TEST_GEN', @connections[0])
38
38
  assert(Generator::exists?('TEST_GEN', @connections[0]))
39
- assert(g.last == 0)
40
- assert(g.next(1) == 1)
41
- assert(g.last == 1)
42
- assert(g.next(10) == 11)
43
- assert(g.connection == @connections[0])
44
- assert(g.name == 'TEST_GEN')
39
+ assert_equal(0, g.last)
40
+ assert_equal(1, g.next(1))
41
+ assert_equal(1, g.last)
42
+ assert_equal(11, g.next(10))
43
+ assert_equal(@connections[0], g.connection)
44
+ assert_equal('TEST_GEN', g.name)
45
45
 
46
46
  g.drop
47
- assert(Generator::exists?('TEST_GEN', @connections[0]) == false)
47
+ assert(!Generator::exists?('TEST_GEN', @connections[0]))
48
48
  end
49
49
  end
data/test/KeyTest.rb CHANGED
@@ -22,8 +22,7 @@ class KeyTest < Test::Unit::TestCase
22
22
  database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
23
23
  @connection = database.connect(DB_USER_NAME, DB_PASSWORD)
24
24
  @transaction = @connection.start_transaction
25
- @results = ResultSet.new(@connection, @transaction,
26
- 'SELECT * FROM RDB$FIELDS', 3, nil)
25
+ @results = @connection.execute('SELECT * FROM RDB$FIELDS', @transaction)
27
26
  @empty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
28
27
  0, 0, 0, 0, 0, 0, 0, 0, 0]
29
28
 
@@ -64,8 +64,8 @@ class ResultSetTest < Test::Unit::TestCase
64
64
  end
65
65
 
66
66
  def test01
67
- r = ResultSet.new(@connections[0], @transactions[0],
68
- "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3, nil)
67
+ r = @connections[0].execute("SELECT * FROM TEST_TABLE ORDER BY TESTID", @transactions[0])
68
+ assert_equal(Rubyfb::ResultSet, r.class)
69
69
 
70
70
  assert(r.connection == @connections[0])
71
71
  assert(r.transaction == @transactions[0])
@@ -80,8 +80,8 @@ class ResultSetTest < Test::Unit::TestCase
80
80
  assert(r.fetch == nil)
81
81
  r.close
82
82
 
83
- r = ResultSet.new(@connections[0], @transactions[0],
84
- "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3, nil)
83
+ r = @connections[0].execute("SELECT * FROM TEST_TABLE ORDER BY TESTID", @transactions[0])
84
+ assert_equal(Rubyfb::ResultSet, r.class)
85
85
  assert(r.column_count == 2)
86
86
  assert(r.column_name(0) == 'TESTID')
87
87
  assert(r.column_name(1) == 'TESTINFO')
@@ -97,8 +97,9 @@ class ResultSetTest < Test::Unit::TestCase
97
97
  assert(r.column_alias(-1) == nil)
98
98
  r.close
99
99
 
100
- r = ResultSet.new(@connections[0], @transactions[0],
101
- "SELECT * FROM TEST_TABLE ORDER BY TESTID", 3, nil)
100
+ r = @connections[0].execute("SELECT * FROM TEST_TABLE ORDER BY TESTID", @transactions[0])
101
+ assert_equal(Rubyfb::ResultSet, r.class)
102
+
102
103
  total = 0
103
104
  r.each do |row|
104
105
  total += 1
@@ -108,9 +109,9 @@ class ResultSetTest < Test::Unit::TestCase
108
109
  end
109
110
 
110
111
  def test02
111
- r = ResultSet.new(@connections[0], @transactions[0],
112
- 'select * from test_table where testid between ? and ?',
113
- 3, [20, 40])
112
+ r = @connections[0].execute_for('select * from test_table where testid between ? and ?',
113
+ [20, 40], @transactions[0])
114
+ assert_equal(Rubyfb::ResultSet, r.class)
114
115
  assert(r.exhausted? == false)
115
116
  total = 0
116
117
  r.each {|row| total += 1}
@@ -120,17 +121,14 @@ class ResultSetTest < Test::Unit::TestCase
120
121
 
121
122
  def test03
122
123
  begin
123
- ResultSet.new(@connections[0], @transactions[0],
124
- "insert into test_table values(?, ?)", 3,
125
- [100, 'Should fail.'])
126
- assert(false, "Created result set with non-query SQL statement.")
124
+ r = @connections[0].execute_for("insert into test_table values(?, ?)",
125
+ [100, 'Should fail.'], @transactions[0])
126
+ assert_not_equal(Rubyfb::ResultSet, r.class, "Created result set with non-query SQL statement.")
127
127
  rescue FireRubyException
128
128
  end
129
129
 
130
130
  begin
131
- ResultSet.new(@connections[0], @transactions[0],
132
- "select * from test_table where testid = ?", 3,
133
- [])
131
+ r = @connections[0].execute_for("select * from test_table where testid = ?", [], @transactions[0])
134
132
  assert(false, 'Created result set with insufficient parameters.')
135
133
  rescue FireRubyException
136
134
  end
data/test/RoleTest.rb CHANGED
@@ -52,7 +52,7 @@ class RoleTest < Test::Unit::TestCase
52
52
  cxn = @database.connect('user1', 'password')
53
53
  assert_raise FireRubyException do
54
54
  t1 = cxn.start_transaction
55
- r = ResultSet.new(cxn, t1, "select * from test", 3, nil)
55
+ r = cxn.execute("select * from test", t1)
56
56
  r.fetch
57
57
  r.close
58
58
  t1.commit
@@ -62,7 +62,7 @@ class RoleTest < Test::Unit::TestCase
62
62
  cxn = @database.connect('user1', 'password', {Connection::SQL_ROLE_NAME => "myrole"})
63
63
  assert_nothing_raised do
64
64
  t1 = cxn.start_transaction
65
- r = ResultSet.new(cxn, t1, "select * from test", 3, nil)
65
+ r = cxn.execute("select * from test", t1)
66
66
  r.fetch
67
67
  r.close
68
68
  t1.commit
data/test/RowCountTest.rb CHANGED
@@ -35,29 +35,29 @@ class RowCountTest < Test::Unit::TestCase
35
35
  def test01
36
36
  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
37
37
  cxn.start_transaction do |tx|
38
- assert(cxn.execute_immediate('insert into test values (1000)') == 1)
39
- assert(cxn.execute_immediate('insert into test values (1000)') == 1)
40
- assert(cxn.execute('insert into test values (2000)', tx) == 1)
41
- assert(cxn.execute('insert into test values (2000)', tx) == 1)
42
- assert(tx.execute('insert into test values (3000)') == 1)
43
- assert(tx.execute('insert into test values (3000)') == 1)
44
- assert(tx.execute('insert into test values (4000)') == 1)
45
- assert(tx.execute('insert into test values (4000)') == 1)
38
+ assert_equal(1, cxn.execute_immediate('insert into test values (1000)'))
39
+ assert_equal(1, cxn.execute_immediate('insert into test values (1000)'))
40
+ assert_equal(1, cxn.execute('insert into test values (2000)', tx))
41
+ assert_equal(1, cxn.execute('insert into test values (2000)', tx))
42
+ assert_equal(1, tx.execute('insert into test values (3000)'))
43
+ assert_equal(1, tx.execute('insert into test values (3000)'))
44
+ assert_equal(1, tx.execute('insert into test values (4000)'))
45
+ assert_equal(1, tx.execute('insert into test values (4000)'))
46
46
 
47
- assert(cxn.execute_immediate('update test set id = 10000 where '\
48
- 'id = 1000') == 2)
49
- assert(cxn.execute('update test set id = 20000 where id = 2000',
50
- tx) == 2)
51
- assert(tx.execute('update test set id = 30000 where id = 3000') == 2)
47
+ assert_equal(2, cxn.execute_immediate('update test set id = 10000 where '\
48
+ 'id = 1000'))
49
+ assert_equal(2, cxn.execute('update test set id = 20000 where id = 2000',
50
+ tx))
51
+ assert_equal(2, tx.execute('update test set id = 30000 where id = 3000'))
52
52
 
53
- s = Statement.new(cxn, tx, 'update test set id = 40000 where id = ?',
54
- 3)
55
- assert(s.execute_for([4000]) == 2)
53
+ s = cxn.create_statement('update test set id = 40000 where id = ?')
54
+
55
+ assert_equal(2, s.exec([4000], tx))
56
56
 
57
57
 
58
- assert(cxn.execute_immediate('delete from test where id = 10000') == 2)
59
- assert(cxn.execute('delete from test where id = 20000', tx) == 2)
60
- assert(tx.execute('delete from test where id = 30000') == 2)
58
+ assert_equal(2, cxn.execute_immediate('delete from test where id = 10000'))
59
+ assert_equal(2, cxn.execute('delete from test where id = 20000', tx))
60
+ assert_equal(2, tx.execute('delete from test where id = 30000'))
61
61
  end
62
62
  end
63
63
  end
data/test/RowTest.rb CHANGED
@@ -19,8 +19,7 @@ class RowTest < Test::Unit::TestCase
19
19
  database = Database::create(DB_FILE, DB_USER_NAME, DB_PASSWORD)
20
20
  @connection = database.connect(DB_USER_NAME, DB_PASSWORD)
21
21
  @transaction = @connection.start_transaction
22
- @results = ResultSet.new(@connection, @transaction,
23
- 'SELECT * FROM RDB$FIELDS', 3, nil)
22
+ @results = @connection.execute('SELECT * FROM RDB$FIELDS', @transaction)
24
23
  @empty = [[0, SQLType::INTEGER], [0, SQLType::INTEGER],
25
24
  [0, SQLType::INTEGER], [0, SQLType::INTEGER],
26
25
  [0, SQLType::INTEGER], [0, SQLType::INTEGER],
@@ -48,14 +47,14 @@ class RowTest < Test::Unit::TestCase
48
47
  @connection.start_transaction do |tx|
49
48
  tx.execute("insert into rowtest values (1, 'Two', 3)")
50
49
 
51
- stmt = Statement.new(@connection, tx,
50
+ stmt = @connection.create_statement(
52
51
  "insert into all_types values(?, ?, ?, ?, ?, ?, "\
53
- "?, ?, ?, ?, ?, ?, ?)",
54
- 3)
55
- #stmt.execute_for([nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil])
56
- stmt.execute_for([100000, nil, 'La la la', Date.new(2005, 10, 29),
52
+ "?, ?, ?, ?, ?, ?, ?)"
53
+ )
54
+ #stmt.exec([nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil])
55
+ stmt.exec([100000, nil, 'La la la', Date.new(2005, 10, 29),
57
56
  10.23, 100.751, 56.25, 12345, 19863.21, 123,
58
- Time.new, Time.new, 'The End!'])
57
+ Time.new, Time.new, 'The End!'], tx)
59
58
  end
60
59
  end
61
60
 
data/test/SQLTest.rb CHANGED
@@ -48,14 +48,14 @@ class SQLTest < Test::Unit::TestCase
48
48
  def test01
49
49
  @database.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
50
50
  cxn.start_transaction do |tx|
51
- s = Statement.new(cxn, tx, INSERT_SQL, 3)
51
+ s = cxn.create_statement(INSERT_SQL)
52
52
  f = 0.0
53
53
  t = Time.new
54
54
 
55
55
  1.upto(ITERATIONS) do |i|
56
56
  f += 0.321
57
57
  t = Time.at(t.to_i + 5)
58
- s.execute_for([i, i.to_s, f, t, nil, t])
58
+ s.exec([i, i.to_s, f, t, nil, t], tx)
59
59
  end
60
60
 
61
61
  s.close
@@ -129,9 +129,8 @@ class SQLTest < Test::Unit::TestCase
129
129
  @transactions[0].commit
130
130
 
131
131
  @connections[0].start_transaction do |tx|
132
- s = Statement.new(@connections[0], tx,
133
- "UPDATE TEST_TABLE SET TESTSTAMP = NULL", 3)
134
- s.execute()
132
+ s = @connections[0].create_statement("UPDATE TEST_TABLE SET TESTSTAMP = NULL")
133
+ s.exec(nil, tx)
135
134
  s.close
136
135
 
137
136
  r = tx.execute("SELECT TESTSTAMP FROM TEST_TABLE")
@@ -148,11 +147,11 @@ class SQLTest < Test::Unit::TestCase
148
147
  t = nil
149
148
  @connections[0].start_transaction do |tx|
150
149
  # Perform an insert via a parameterized statement.
151
- s = Statement.new(@connections[0], tx,
150
+ s = @connections[0].create_statement(
152
151
  "INSERT INTO TEST_TABLE (TESTID, TESTTEXT, "\
153
- "TESTFLOAT, TESTSTAMP) VALUES(?, ?, ?, ?)", 3)
152
+ "TESTFLOAT, TESTSTAMP) VALUES(?, ?, ?, ?)")
154
153
  t = Time.new
155
- s.execute_for([25000, 'La la la', 3.14, t])
154
+ s.exec([25000, 'La la la', 3.14, t], tx)
156
155
  s.close
157
156
 
158
157
  # Fetch the record and check the data.