fireruby 0.3.1-powerpc-darwin → 0.3.2-powerpc-darwin

Sign up to get free protection for your applications and to get access to all the features.
data/doc/CVS/Entries CHANGED
@@ -1,3 +1,3 @@
1
- /README/1.5/Mon May 9 09:16:38 2005//
1
+ /README/1.6/Fri Jun 10 12:17:53 2005//
2
2
  /license.txt/1.1/Tue Mar 15 13:40:26 2005//
3
3
  D
data/doc/README CHANGED
@@ -1,69 +1,42 @@
1
- == FireRuby Version 0.3.0
1
+ == FireRuby Version 0.3.2
2
2
  FireRuby is an extension to the Ruby language that provides access to the C API
3
3
  functionality of the Firebird relational database management system.
4
4
 
5
- This release extends the functionality of the Row object to allow it to be used
6
- as a read only Hash object and adds new funcionality relating to the Firebird
7
- RDBMS service manager.
5
+ This release expands upon the functionality provided by the Database and
6
+ Connection classes to provide extended support for connection options and, in
7
+ particular, database character sets.
8
8
 
9
9
  Once again I would like to thank Ken Kunz for his support and input to the
10
10
  FireRuby project. Ken performs the unit testing and creates the gem file for the
11
- Linux version of the FireRuby library.
11
+ Linux version of the FireRuby library. Thanks also to Art Fedorov for input on
12
+ handling and testing character sets.
12
13
 
13
14
  == Enhancements & Alterations
14
15
 
15
- The Row class has been extended to include equivalents for all Hash methods that
16
- do would not alter the contents of the Hash. This effectively allows an instance
17
- of the Row class to be used as a Hash anywhere that a Hash object can be used
18
- without the need to change it's contents.
19
-
20
- A ServiceManager class and a collection of task related classes have been added
21
- for this release. The ServiceManager class represents a connection to a Firebird
22
- service manager instance. Task classes have been provided that allow for the
23
- backing up and restoration of databases as well as the addition or removal of
24
- database users.
25
-
26
- The Statement and ResultSet classes under went a major rewrite. This was done
27
- to eliminate a dependency between these two classes (the Statement class was
28
- using the ResultSet class to execute SQL regardless of whether the statement
29
- being executed was a query). This was an illogical and ill-consider set up and
30
- has now been eliminated. An effort was made to minimize changes to the interface
31
- but there have been some (primarily the constructor for the ResultSet class).
32
- The ResultSet class has now been restricted for use with queries only and will
33
- generate and exception if a non-query statement is specified. Queries can still
34
- be run through the Statement class but, if you know you're executing a query
35
- statement, it is more efficient to go straight to a ResultSet object.
16
+ The Database class has been expanded to incorporate the concept of character
17
+ sets. The Connection class has been extended to allow for the specification of
18
+ a set of connection options. Both of these classes have also been altered to
19
+ support the accessing of databases using the system user details (on POSIX
20
+ systems).
36
21
 
37
22
  == Bug Fixes
38
23
 
39
- The only currently outstanding bug relates to accessing methods on the ResultSet
40
- class objects that have been created with a non-query SQL statement. This class
41
- has been fundamentally re-written and no longer allows the use of non-query SQL
42
- statements. This bug is therefore closed.
24
+ There are no outstanding project bugs.
43
25
 
44
26
  == Issues
45
27
 
46
28
  Nothing is perfect so this section outlines those issues that are known to
47
29
  exist as of this release.
48
30
 
49
- - The big new issue for this release (0.3.0) relates to the fact the service
50
- manager functionality does not appear to work on the Mac OS X platform. I
51
- don't believe that this is a problem in the FireRuby code as I have tested the
52
- Firebird gbak utility with the -service option and it gives the same result.
53
- If anyone knows this to be untrue or of a work around let me know.
31
+ - The service manager functionality does not appear to work on the Mac OS X
32
+ platform. I don't believe that this is a problem in the FireRuby code as I
33
+ have tested the Firebird gbak utility with the -service option and it gives
34
+ the same result. If anyone knows this to be untrue or of a work around let me
35
+ know.
54
36
 
55
37
  - The library currently does not support array columns. This may be implemented
56
38
  for a later release depending on demand.
57
39
 
58
- - There is an issue with the use of anonymous transactions inside of a block
59
- for the Database#connect method. An attempt is made to close the connection
60
- when the block exits. If, within the block, there is a call to the
61
- Connection#execute_immediate method that generates a result set and,
62
- subsequently, an exception is raised the anonymous transaction used in the
63
- execute_immediate will be unavailable for closure. This will, in turn,
64
- make it impossible to close the connection, resulting in an exception. As
65
- a work around, don't use anonymous transactions for queries.
66
-
67
40
  == Installation & Usage
68
41
 
69
42
  The library is provided as a gem and built for use with Ruby 1.8+. Testing
data/lib/CVS/Entries CHANGED
@@ -1,4 +1,4 @@
1
+ /fireruby.bundle/1.3/Fri Jun 10 12:20:22 2005//
1
2
  /mkdoc/1.2/Mon Mar 21 08:53:22 2005//
2
- /fireruby.bundle/1.2/Tue Jun 7 08:47:06 2005//
3
- /src.rb/1.4/Tue Jun 7 08:51:16 2005//
3
+ /src.rb/1.5/Fri Jun 10 12:20:22 2005//
4
4
  D
data/lib/fireruby.bundle CHANGED
Binary file
data/lib/src.rb CHANGED
@@ -55,7 +55,8 @@ module FireRuby
55
55
 
56
56
 
57
57
  #
58
- # This class represents an existing database that can be connected to.
58
+ # This class represents an existing database that can be connected to. It
59
+ # also provides functionality to allow for the creation of new databases.
59
60
  #
60
61
  class Database
61
62
  #
@@ -64,8 +65,10 @@ module FireRuby
64
65
  # ==== Parameters
65
66
  # file:: A string containing the database file specifier. This can
66
67
  # include details for a remote server if needed.
68
+ # set:: A string containing the name of the character set to be
69
+ # used with the database. Defaults to nil.
67
70
  #
68
- def initialize(file)
71
+ def initialize(file, set=nil)
69
72
  end
70
73
 
71
74
 
@@ -84,14 +87,21 @@ module FireRuby
84
87
  # as a parameter to the block.
85
88
  #
86
89
  # ==== Parameters
87
- # user:: The user name to be used in making the connection.
88
- # password:: The password to be used in making the connection.
90
+ # user:: The user name to be used in making the connection. This
91
+ # defaults to nil.
92
+ # password:: The password to be used in making the connection. This
93
+ # defaults to nil.
94
+ # options:: A Hash of connection options. This should be made up of
95
+ # key/setting pairs where the keys are from the list that
96
+ # is defined within the Connection class. The settings are
97
+ # particular to the key, see the documentation for the
98
+ # Connection class for more details.
89
99
  #
90
100
  # ==== Exceptions
91
101
  # Exception:: Thrown whenever a problem occurs connecting with the
92
102
  # database.
93
103
  #
94
- def connect(user, password)
104
+ def connect(user=nil, password=nil, options=nil)
95
105
  yield(connection)
96
106
  end
97
107
 
@@ -126,7 +136,9 @@ module FireRuby
126
136
  # size:: The page size setting to be used with the new database file.
127
137
  # This should be 1024, 2048, 4096 or 8192. Defaults to 1024.
128
138
  # set:: The name of the default character set to be assigned to the
129
- # new database file. Defaults to nil.
139
+ # new database file. If this parameter is specifed then the
140
+ # Database object created by the call will use it to whenever
141
+ # a connection request is made. Defaults to nil.
130
142
  #
131
143
  # ==== Exceptions
132
144
  # Exception:: Generated whenever an invalid parameter is specified or a
@@ -134,6 +146,29 @@ module FireRuby
134
146
  #
135
147
  def Database.create(file, user, password, size=1024, set=nil)
136
148
  end
149
+
150
+
151
+ #
152
+ # This method fetches the name of the character set currently assigned
153
+ # to a Database object. This can return nil to indicate that a explicit
154
+ # character set has not been assigned.
155
+ #
156
+ def character_set
157
+ end
158
+
159
+
160
+ #
161
+ # This method allows the specification of a database character set that
162
+ # will be used when creating connections to a database. The value set by
163
+ # this method can be overridden by providing an alternative in the connect
164
+ # call. To remove a character set specification from a Database object
165
+ # pass nil to this method.
166
+ #
167
+ # ==== Parameters
168
+ # set:: A string containing the name of the database character set.
169
+ #
170
+ def character_set=(set)
171
+ end
137
172
  end
138
173
 
139
174
 
@@ -141,22 +176,72 @@ module FireRuby
141
176
  # This class represents a connection with a Firebird database.
142
177
  #
143
178
  class Connection
179
+ # A definition for a connection option. This option should be given a
180
+ # setting of either true or false.
181
+ MARK_DATABASE_DAMAGED = 17
182
+
183
+
184
+ # A definition for a connection option. This option should be given a
185
+ # setting of Connection::WRITE_ASYNCHRONOUS or
186
+ # Connection::WRITE_SYNCHRONOUS
187
+ WRITE_POLICY = 24
188
+
189
+
190
+ # A definition for a connection option. This option should be given a
191
+ # string setting which should be the name of the character set to be
192
+ # used by the connection.
193
+ CHARACTER_SET = 48
194
+
195
+
196
+ # A definition for a connection option. This option should be given a
197
+ # string setting which should be the name of the message file to be used
198
+ # by the connection.
199
+ MESSAGE_FILE = 47
200
+
201
+
202
+ # A definition for a connection option. This option should be given a
203
+ # an integer setting. Values between 1 and 255 are valid, with 75 being
204
+ # the default.
205
+ NUMBER_OF_CACHE_BUFFERS = 5
206
+
207
+
208
+ # A definition for a connection option. This option should be given a
209
+ # string value which should be the database DBA user name.
210
+ DBA_USER_NAME = 19
211
+
212
+
213
+ # A definition for a possible setting to accompany the WRITE_POLICY
214
+ # connection setting.
215
+ WRITE_ASYNCHONOUS = 0
216
+
217
+
218
+ # A definition for a possible setting to accompany the WRITE_POLICY
219
+ # connection setting.
220
+ WRITE_SYNCHONOUS = 1
221
+
222
+
144
223
  #
145
224
  # This is the constructor for the Connection class.
146
225
  #
147
226
  # ==== Parameters
148
227
  # database:: A reference to the Database object to be connected to.
149
228
  # user:: A reference to the user name to be used in making the
150
- # database connection.
229
+ # database connection. Defaults to nil.
151
230
  # password:: A reference to the user password to be used in making the
152
- # connection.
231
+ # connection. Defaults to nil.
232
+ # options:: A Hash containing the options to be applied to the new
233
+ # connection. The hash will contain key/setting values, with
234
+ # the keys being based on the option constants defined within
235
+ # the Connection class. Individual options have differing
236
+ # value requirements. See the option documentation entries
237
+ # for further details. Defaults to nil.
153
238
  #
154
239
  # ==== Exceptions
155
240
  # Exception:: Generated whenever an invalid database is specified to
156
241
  # the method or an issue occurs establishing the database
157
242
  # connection.
158
243
  #
159
- def initialize(database, user, password)
244
+ def initialize(database, user, password, options)
160
245
  end
161
246
 
162
247
 
data/test/CVS/Entries CHANGED
@@ -1,5 +1,8 @@
1
1
  /AddRemoveUserTest.rb/1.1/Mon May 9 09:11:29 2005//
2
2
  /BackupRestoreTest.rb/1.1/Mon May 9 09:11:29 2005//
3
+ /CharacterSetTest.rb/1.1/Fri Jun 10 12:15:42 2005//
4
+ /ConnectionTest.rb/1.5/Tue Jun 7 13:20:24 2005//
5
+ /DDLTest.rb/1.5/Wed May 18 09:13:26 2005//
3
6
  /DatabaseTest.rb/1.3/Thu Mar 31 08:28:48 2005//
4
7
  /GeneratorTest.rb/1.3/Mon May 9 09:08:34 2005//
5
8
  /ResultSetTest.rb/1.3/Mon May 9 09:08:34 2005//
@@ -10,7 +13,5 @@
10
13
  /StatementTest.rb/1.4/Mon May 9 09:08:34 2005//
11
14
  /TestSetup.rb/1.1.1.1/Tue Mar 15 10:37:07 2005//
12
15
  /TransactionTest.rb/1.5/Wed May 18 09:07:52 2005//
13
- /UnitTest.rb/1.5/Wed May 18 09:07:52 2005//
14
- /DDLTest.rb/1.5/Wed May 18 09:20:15 2005//
15
- /ConnectionTest.rb/1.5/Tue Jun 7 13:24:43 2005//
16
+ /UnitTest.rb/1.6/Fri Jun 10 12:15:42 2005//
16
17
  D
@@ -0,0 +1,60 @@
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 CharacterSetTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}cxnarset_unit_test.fdb"
13
+ CHAR_SET = 'WIN1251'
14
+
15
+ def setup
16
+ if File::exist?(DB_FILE)
17
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
18
+ end
19
+
20
+ @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024,
21
+ CHAR_SET)
22
+ end
23
+
24
+ def teardown
25
+ if File::exist?(DB_FILE)
26
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
27
+ end
28
+ end
29
+
30
+ def test01
31
+ db = Database.new(DB_FILE, CHAR_SET)
32
+
33
+ assert(db.character_set = CHAR_SET)
34
+
35
+ db.character_set = 'ASCII'
36
+ assert(db.character_set == 'ASCII')
37
+ end
38
+
39
+ def test02
40
+ text = "�?����"
41
+ db = Database.new(DB_FILE, CHAR_SET)
42
+
43
+ begin
44
+ db.connect("SYSDBA", "masterkey") do |cxn|
45
+ cxn.start_transaction do |tr|
46
+ cxn.execute("CREATE TABLE SAMPLE_TABLE(SAMPLE_FIELD VARCHAR(100))",tr)
47
+ end
48
+ cxn.start_transaction do |tr|
49
+ cxn.execute("INSERT INTO SAMPLE_TABLE VALUES ('#{win1251_str}')",tr)
50
+ cxn.execute("SELECT * FROM SAMPLE_TABLE WHERE SAMPLE_FIELD = '#{win1251_str}'",tr) do |row|
51
+ # here we have an exception:
52
+ some_var = row['SAMPLE_FIELD']
53
+ end
54
+ end
55
+ end
56
+ rescue => error
57
+ assert("Character set unit test failure.", false)
58
+ end
59
+ end
60
+ end
data/test/UnitTest.rb CHANGED
@@ -11,6 +11,7 @@ require 'GeneratorTest'
11
11
  require 'DDLTest'
12
12
  require 'SQLTest'
13
13
  require 'ServiceManagerTest'
14
+ require 'CharacterSetTest'
14
15
  if PLATFORM.include?('powerpc-darwin') == false
15
16
  require 'BackupRestoreTest'
16
17
  require 'AddRemoveUserTest'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: fireruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.1
7
- date: 2005-06-08
6
+ version: 0.3.2
7
+ date: 2005-06-13
8
8
  summary: Ruby interface library for the Firebird database.
9
9
  require_paths:
10
10
  - lib
@@ -36,6 +36,7 @@ files:
36
36
  - lib/CVS/Root
37
37
  - test/AddRemoveUserTest.rb
38
38
  - test/BackupRestoreTest.rb
39
+ - test/CharacterSetTest.rb
39
40
  - test/ConnectionTest.rb
40
41
  - test/CVS
41
42
  - test/DatabaseTest.rb