fireruby 0.3.2-i586-linux → 0.4.0-i586-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/doc/CVS/Entries +4 -0
  2. data/doc/CVS/Repository +1 -0
  3. data/doc/CVS/Root +1 -0
  4. data/doc/README +86 -34
  5. data/doc/classes/CVS/Entries +1 -0
  6. data/doc/classes/CVS/Repository +1 -0
  7. data/doc/classes/CVS/Root +1 -0
  8. data/doc/classes/FireRuby/CVS/Entries +7 -0
  9. data/doc/classes/FireRuby/CVS/Repository +1 -0
  10. data/doc/classes/FireRuby/CVS/Root +1 -0
  11. data/doc/classes/FireRuby/Connection.src/CVS/Entries +1 -0
  12. data/doc/classes/FireRuby/Connection.src/CVS/Repository +1 -0
  13. data/doc/classes/FireRuby/Connection.src/CVS/Root +1 -0
  14. data/doc/classes/FireRuby/Database.src/CVS/Entries +1 -0
  15. data/doc/classes/FireRuby/Database.src/CVS/Repository +1 -0
  16. data/doc/classes/FireRuby/Database.src/CVS/Root +1 -0
  17. data/doc/classes/FireRuby/FireRubyError.src/CVS/Entries +1 -0
  18. data/doc/classes/FireRuby/FireRubyError.src/CVS/Repository +1 -0
  19. data/doc/classes/FireRuby/FireRubyError.src/CVS/Root +1 -0
  20. data/doc/classes/FireRuby/Generator.src/CVS/Entries +1 -0
  21. data/doc/classes/FireRuby/Generator.src/CVS/Repository +1 -0
  22. data/doc/classes/FireRuby/Generator.src/CVS/Root +1 -0
  23. data/doc/classes/FireRuby/ResultSet.src/CVS/Entries +1 -0
  24. data/doc/classes/FireRuby/ResultSet.src/CVS/Repository +1 -0
  25. data/doc/classes/FireRuby/ResultSet.src/CVS/Root +1 -0
  26. data/doc/classes/FireRuby/Statement.src/CVS/Entries +1 -0
  27. data/doc/classes/FireRuby/Statement.src/CVS/Repository +1 -0
  28. data/doc/classes/FireRuby/Statement.src/CVS/Root +1 -0
  29. data/doc/classes/FireRuby/Transaction.src/CVS/Entries +1 -0
  30. data/doc/classes/FireRuby/Transaction.src/CVS/Repository +1 -0
  31. data/doc/classes/FireRuby/Transaction.src/CVS/Root +1 -0
  32. data/doc/files/CVS/Entries +1 -0
  33. data/doc/files/CVS/Repository +1 -0
  34. data/doc/files/CVS/Root +1 -0
  35. data/examples/CVS/Entries +2 -0
  36. data/examples/CVS/Repository +1 -0
  37. data/examples/CVS/Root +1 -0
  38. data/examples/example01.rb +9 -4
  39. data/lib/CVS/Entries +6 -0
  40. data/lib/CVS/Repository +1 -0
  41. data/lib/CVS/Root +1 -0
  42. data/lib/SQLType.rb +228 -0
  43. data/lib/fireruby.rb +22 -0
  44. data/lib/fr_lib.so +0 -0
  45. data/lib/src.rb +52 -6
  46. data/test/AddRemoveUserTest.rb +7 -2
  47. data/test/BackupRestoreTest.rb +3 -1
  48. data/test/CVS/Entries +20 -0
  49. data/test/CVS/Repository +1 -0
  50. data/test/CVS/Root +1 -0
  51. data/test/CharacterSetTest.rb +5 -2
  52. data/test/ConnectionTest.rb +3 -1
  53. data/test/DDLTest.rb +3 -1
  54. data/test/DatabaseTest.rb +3 -1
  55. data/test/GeneratorTest.rb +3 -1
  56. data/test/KeyTest.rb +140 -0
  57. data/test/ResultSetTest.rb +34 -3
  58. data/test/RowCountTest.rb +3 -1
  59. data/test/RowTest.rb +90 -24
  60. data/test/SQLTest.rb +4 -1
  61. data/test/SQLTypeTest.rb +101 -0
  62. data/test/ServiceManagerTest.rb +10 -2
  63. data/test/StatementTest.rb +18 -7
  64. data/test/TestSetup.rb +1 -0
  65. data/test/TransactionTest.rb +4 -1
  66. data/test/TypeTest.rb +92 -0
  67. data/test/UnitTest.rb +61 -15
  68. data/test/UnitTest.rb~ +64 -0
  69. metadata +84 -20
  70. data/lib/fireruby.so +0 -0
data/doc/CVS/Entries ADDED
@@ -0,0 +1,4 @@
1
+ /license.txt/1.1/Tue Mar 15 13:40:26 2005//
2
+ D/classes////
3
+ D/files////
4
+ /README/1.8/Thu Nov 10 13:20:44 2005//
@@ -0,0 +1 @@
1
+ fireruby/doc
data/doc/CVS/Root ADDED
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
data/doc/README CHANGED
@@ -1,27 +1,65 @@
1
- == FireRuby Version 0.3.2
2
- FireRuby is an extension to the Ruby language that provides access to the C API
3
- functionality of the Firebird relational database management system.
4
-
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
-
9
- Once again I would like to thank Ken Kunz for his support and input to the
10
- FireRuby project. Ken performs the unit testing and creates the gem file for the
11
- Linux version of the FireRuby library. Thanks also to Art Fedorov for input on
12
- handling and testing character sets.
1
+ == FireRuby Version 0.4.0
2
+ Its been a while but I'm glad to release version 0.4.0 of the FireRuby library.
3
+ FireRuby is an extension for the Ruby programming language that provides access
4
+ to the Firebird open source RDBMS. There aren't a great deal of changes for this
5
+ release but some of the alterations may have an impact on existing code, so
6
+ please read the enhancements and alterations section to see what has been done.
13
7
 
14
8
  == Enhancements & Alterations
15
9
 
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).
10
+ This release contains some changes that are part of a suite of suggestion put
11
+ forward by Ken Kunz to enhancement support for the Firebird ActiveRecord
12
+ adapter he developed. The first of these changes involved switching the keying
13
+ of Row objects away from using the column name to using the column alias. This
14
+ is a logical change as the alias is more likely to be unique. I realise that
15
+ change has the potential to break existing code so I've included a work around
16
+ that can be used to have the library behave as it used to. To use keying on
17
+ columns insert the following line into your code after you've loaded the
18
+ FireRuby library and before you've done any database work...
19
+
20
+ $FireRubySettings[:ALIAS_KEYS] = false
21
+
22
+ This will cause the library to use column names as keys on rows. A second change
23
+ I've made that could impact existing code is for the retrieval of data from
24
+ columns of SQL type DATE. These were being returned as a Time object but are now
25
+ being returned as a Date object, again a fairly logical change. If this causes
26
+ problems for your code then you can add the following line to get the library to
27
+ return Times by adding the following line...
28
+
29
+ $FireRubySettings[:DATE_AS_DATE] = false
30
+
31
+ The final change I've made for this release from Ken's wish list is that I have
32
+ incorporated Enumerable into the Row and ResultSet classes. Your code may
33
+ already do this and, unfortunately, I'm not providing any sort of work around
34
+ other than you remove this from your own code.
35
+
36
+ I've also added functionality to the library to aid in determining type
37
+ information in relation to database tables and query results. As far as I can
38
+ determine the Firebird data structures used to return data from the database
39
+ provide no means of determining exact type specifics (please correct me if I'm
40
+ wrong). This means that for queries all I can return are details of the
41
+ underlying type but not the specifics (so I can tell you that a result column is
42
+ NUMERIC but I can't give you the precision and scale for example).
43
+
44
+ I have provided a new class called SQLType. This defines constants for the basic
45
+ types supported by FireRuby. It also allows for querying of table types. In this
46
+ case, as I'm referring to the actual database, I can provide more specific
47
+ details (so I can tell you that a column is NUMERIC, has a precision of 5 and a
48
+ scale or 2 for example). See the API documentation for this class for more
49
+ information.
50
+
51
+ Finally I have added some new unit tests and updated existing ones to cover the
52
+ changes I have made.
21
53
 
22
54
  == Bug Fixes
23
55
 
24
- There are no outstanding project bugs.
56
+ I've made a few cosmetic and minor bug fixes that were unlikely to have had an
57
+ impact on anyone (but its nice that they're fixed anyway).
58
+
59
+ I received some feedback with regards to FireRuby not working with Firebird
60
+ database aliases but, as this has been successfully tested via the use of the
61
+ Rails adapter based on FireRuby, I have to assume that this was a user set up
62
+ problem.
25
63
 
26
64
  == Issues
27
65
 
@@ -35,7 +73,21 @@ exist as of this release.
35
73
  know.
36
74
 
37
75
  - The library currently does not support array columns. This may be implemented
38
- for a later release depending on demand.
76
+ for a later release depending on demand. No-one has asked for this so far so
77
+ I'm starting to think that people don't make much use of array columns.
78
+
79
+ - The library can be a bit touchy if you don't clean up after yourself. This
80
+ can result in a segmentation violation whenever your program stops if you've
81
+ left a ResultSet or Statement object unclosed. Check through your code to
82
+ insure that this isn't the case before contacting me about problems in this
83
+ line.
84
+
85
+ - The unit tests are currently set up on the assumption that the password for
86
+ your sysdba account is 'masterkey'. If this is not the case, or if you wish
87
+ to use an alternative user for testing, edit the TestSetup.rb file in the
88
+ unit test directory and update the entries there as appropriate. I should also
89
+ note that you may need to alter permissions on the test directory to run the
90
+ actual unit tests on Linux/Unix.
39
91
 
40
92
  == Installation & Usage
41
93
 
@@ -45,32 +97,32 @@ the Ruby Gems package to be installed. Assuming that these installation criteria
45
97
  have been met the library can be installed on Windows by executing a command
46
98
  such as the following...
47
99
 
48
- gem install fireruby-0.3.0-mswin32.gem
100
+ gem install fireruby-0.4.0-mswin32.gem
49
101
 
50
102
  On the Mac OS X platform you may require super user privilege if your Ruby is
51
103
  installed to the default location (i.e. /usr/local/lib). In this case you can
52
104
  use the sudo command to make the installation like this...
53
105
 
54
- sudo gem install fireruby-0.3.0-powerpc-darwin.gem
106
+ sudo gem install fireruby-0.4.0-powerpc-darwin.gem
55
107
 
56
108
  Once the gem installation is complete the FireRuby functionality can be accessed
57
109
  in code with the usual gem style requires...
58
110
 
59
111
  require 'rubygems'
60
- require_gem 'fireruby'
112
+ require 'fireruby'
61
113
 
62
114
  == Build Details
63
115
 
64
- The FireRuby library is an extension of the Ruby language written in C. For Mac
65
- OS X the library is built on version 10.3 of the OS and against Firebird
66
- installed as a framework, version 1.5.1, and with Ruby version 1.8.2. For the
67
- Windows platform the library is built on Windows XP and against a Ruby
68
- installation created using the one-click installer, version 1.8.2. The Windows
69
- build was created using the freely available Microsoft compilers and SDKs and
70
- built against a standard installation of Firebird, version 1.5.2. On Linux the
71
- library (I believe) has been linked against the Firebird shared object. This
72
- being the case then your LD_LIBRARY_PATH environment variable will have to be
73
- set to include the Firebird lib directory if you want to use it.
116
+ The FireRuby library is an extension of the Ruby language written in C. The Mac
117
+ OS X version was built by my brother John (thanks!) using Mac OS X 10.4.3
118
+ against Firebird installed as a framework, version 1.5.1, and with Ruby version
119
+ 1.8.2. For the Windows platform the library is built on Windows XP and against
120
+ a Ruby installation created using the one-click installer, version 1.8.2. The
121
+ Windows build was created using the freely available Microsoft compilers and
122
+ SDKs and built against a standard installation of Firebird, version 1.5.2. On
123
+ Linux the library is built using an Ubuntu system (Breezy Badger release) using
124
+ Firebird installed through the Synaptic package manager and version 1.8.2 of
125
+ Ruby installed using the same tool.
74
126
 
75
127
  == So How Do I Use It?
76
128
 
@@ -90,7 +142,7 @@ and connecting to database instances. For example, to obtain a connection to a
90
142
  database you would use something like the following...
91
143
 
92
144
  require 'rubygems'
93
- require_gem 'fireruby'
145
+ require 'fireruby'
94
146
 
95
147
  include FireRuby
96
148
 
@@ -322,7 +374,7 @@ database administrator you might do the following...
322
374
 
323
375
  Assuming that this succeeds you are now ready to execute tasks through your
324
376
  ServiceManager object. Within the FireRuby library individual task are broken
325
- out into separate classes. For this release (0.3.0) there are four task classes
377
+ out into separate classes. For this release (0.4.0) there are four task classes
326
378
  provided in the library - Backup, Restore, AddUser and RemoveUser. I think the
327
379
  class names are relatively self explanatory but if you want more information
328
380
  consult the API documentation for a class.
@@ -0,0 +1 @@
1
+ D/FireRuby////
@@ -0,0 +1 @@
1
+ fireruby/doc/classes
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1,7 @@
1
+ D/Connection.src////
2
+ D/Database.src////
3
+ D/FireRubyError.src////
4
+ D/Generator.src////
5
+ D/ResultSet.src////
6
+ D/Statement.src////
7
+ D/Transaction.src////
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/Connection.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/Database.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/FireRubyError.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/Generator.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/ResultSet.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/Statement.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ fireruby/doc/classes/FireRuby/Transaction.src
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1 @@
1
+ D
@@ -0,0 +1 @@
1
+ fireruby/doc/files
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -0,0 +1,2 @@
1
+ /example01.rb/1.2/Tue Jun 14 09:50:30 2005//
2
+ D
@@ -0,0 +1 @@
1
+ fireruby/examples
data/examples/CVS/Root ADDED
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
@@ -5,6 +5,11 @@ require_gem 'fireruby'
5
5
 
6
6
  include FireRuby
7
7
 
8
+ # Database details constants.
9
+ DB_FILE = "localhost:#{File.expand_path('.')}#{File::SEPARATOR}example.fdb"
10
+ DB_USER_NAME = "sysdba"
11
+ DB_PASSWORD = "masterkey"
12
+
8
13
  # SQL constants.
9
14
  CREATE_TABLE_SQL = 'CREATE TABLE TESTTABLE (TESTID INTEGER NOT NULL PRIMARY '\
10
15
  'KEY, TESTTEXT VARCHAR(100), TESTFLOAT NUMERIC(6,2), '\
@@ -16,16 +21,16 @@ SELECT_SQL = 'SELECT * FROM TESTTABLE'
16
21
  begin
17
22
  # Check if the database file exists.
18
23
  db = nil
19
- if File.exist?('./example.fdb') == false
24
+ if File.exist?(DB_FILE) == false
20
25
  # Create the database file.
21
- db = Database.create('./example.fdb', 'sysdba', 'masterkey', 1024, 'ASCII')
26
+ db = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024, 'ASCII')
22
27
  else
23
28
  # Create the databse object.
24
- db = Database.new('./example.fdb')
29
+ db = Database.new(DB_FILE)
25
30
  end
26
31
 
27
32
  # Obtain a connection to the database.
28
- db.connect('sysdba', 'masterkey') do |cxn|
33
+ db.connect(DB_USER_NAME, DB_PASSWORD) do |cxn|
29
34
  # Create the database table.
30
35
  cxn.execute_immediate(CREATE_TABLE_SQL)
31
36
 
data/lib/CVS/Entries ADDED
@@ -0,0 +1,6 @@
1
+ /mkdoc/1.2/Mon Mar 21 08:53:22 2005//
2
+ /SQLType.rb/1.1/Thu Oct 27 19:16:36 2005//
3
+ /fireruby.rb/1.1/Tue Oct 25 19:45:08 2005//
4
+ /fireruby.bundle/1.3/Fri Nov 11 21:18:30 2005//
5
+ /src.rb/1.6/Sat Oct 29 17:06:06 2005//
6
+ D
@@ -0,0 +1 @@
1
+ fireruby/lib
data/lib/CVS/Root ADDED
@@ -0,0 +1 @@
1
+ :ext:paw220470@rubyforge.org:/var/cvs/fireruby
data/lib/SQLType.rb ADDED
@@ -0,0 +1,228 @@
1
+ #-------------------------------------------------------------------------------
2
+ # SQLType.rb
3
+ #-------------------------------------------------------------------------------
4
+ # Copyright � Peter Wood, 2005
5
+ #
6
+ # The contents of this file are subject to the Mozilla Public License Version
7
+ # 1.1 (the "License"); you may not use this file except in compliance with the
8
+ # License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.mozilla.org/MPL/
11
+ #
12
+ # Software distributed under the License is distributed on an "AS IS" basis,
13
+ # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14
+ # the specificlanguage governing rights and limitations under the License.
15
+ #
16
+ # The Original Code is the FireRuby extension for the Ruby language.
17
+ #
18
+ # The Initial Developer of the Original Code is Peter Wood. All Rights
19
+ # Reserved.
20
+
21
+ module FireRuby
22
+ # This class is used to represent SQL table column tables.
23
+ class SQLType
24
+ # A definition for a base SQL type.
25
+ BIGINT = :BIGINT
26
+
27
+ # A definition for a base SQL type.
28
+ BLOB = :BLOB
29
+
30
+ # A definition for a base SQL type.
31
+ CHAR = :CHAR
32
+
33
+ # A definition for a base SQL type.
34
+ DATE = :DATE
35
+
36
+ # A definition for a base SQL type.
37
+ DECIMAL = :DECIMAL
38
+
39
+ # A definition for a base SQL type.
40
+ DOUBLE = :DOUBLE
41
+
42
+ # A definition for a base SQL type.
43
+ FLOAT = :FLOAT
44
+
45
+ # A definition for a base SQL type.
46
+ INTEGER = :INTEGER
47
+
48
+ # A definition for a base SQL type.
49
+ NUMERIC = :NUMERIC
50
+
51
+ # A definition for a base SQL type.
52
+ SMALLINT = :SMALLINT
53
+
54
+ # A definition for a base SQL type.
55
+ TIME = :TIME
56
+
57
+ # A definition for a base SQL type.
58
+ TIMESTAMP = :TIMESTAMP
59
+
60
+ # A definition for a base SQL type.
61
+ VARCHAR = :VARCHAR
62
+
63
+ # Attribute accessor.
64
+ attr_reader :type, :length, :precision, :scale, :subtype
65
+
66
+
67
+ # This is the constructor for the SQLType class.
68
+ #
69
+ # ==== Parameters
70
+ # type:: The base type for the SQLType object. Must be one of the
71
+ # base types defined within the class.
72
+ # length:: The length setting for the type. Defaults to nil.
73
+ # precision:: The precision setting for the type. Defaults to nil.
74
+ # scale:: The scale setting for the type. Defaults to nil.
75
+ # subtype:: The SQL sub-type setting. Defaults to nil.
76
+ def initialize(type, length=nil, precision=nil, scale=nil, subtype=nil)
77
+ @type = type
78
+ @length = length
79
+ @precision = precision
80
+ @scale = scale
81
+ @subtype = subtype
82
+ end
83
+
84
+
85
+ # This class method fetches the type details for a named table. The
86
+ # method returns a hash that links column names to SQLType objects.
87
+ #
88
+ # ==== Parameters
89
+ # table:: A string containing the name of the table.
90
+ # connection:: A reference to the connection to be used to determine
91
+ # the type information.
92
+ #
93
+ # ==== Exception
94
+ # FireRubyException:: Generated if an invalid table name is specified
95
+ # or an SQL error occurs.
96
+ def SQLType.for_table(table, connection)
97
+ # Check for naughty table names.
98
+ if /\s+/ =~ table
99
+ raise FireRubyException.new("'#{table}' is not a valid table name.")
100
+ end
101
+
102
+ types = {}
103
+ begin
104
+ sql = "SELECT RF.RDB$FIELD_NAME, F.RDB$FIELD_TYPE, "\
105
+ "F.RDB$FIELD_LENGTH, F.RDB$FIELD_PRECISION, "\
106
+ "F.RDB$FIELD_SCALE * -1, F.RDB$FIELD_SUB_TYPE "\
107
+ "FROM RDB$RELATION_FIELDS RF, RDB$FIELDS F "\
108
+ "WHERE RF.RDB$RELATION_NAME = UPPER('#{table}') "\
109
+ "AND RF.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME"
110
+
111
+ connection.start_transaction do |tx|
112
+ tx.execute(sql) do |row|
113
+ sql_type = SQLType.to_base_type(row[1], row[5])
114
+ type = nil
115
+ case sql_type
116
+ when BLOB
117
+ type = SQLType.new(sql_type, nil, nil, nil, row[5])
118
+
119
+ when CHAR, VARCHAR
120
+ type = SQLType.new(sql_type, row[2])
121
+
122
+ when DECIMAL, NUMERIC
123
+ type = SQLType.new(sql_type, nil, row[3], row[4])
124
+
125
+ else
126
+ type = SQLType.new(sql_type)
127
+ end
128
+ types[row[0].strip] = type
129
+ end
130
+
131
+ end
132
+ end
133
+ types
134
+ end
135
+
136
+
137
+ # This method overloads the equivalence test operator for the SQLType
138
+ # class.
139
+ #
140
+ # ==== Parameters
141
+ # object:: A reference to the object to be compared with.
142
+ def ==(object)
143
+ result = false
144
+ if object.instance_of?(SQLType)
145
+ result = (@type == object.type &&
146
+ @length == object.length &&
147
+ @precision == object.precision &&
148
+ @scale == object.scale &&
149
+ @subtype == object.subtype)
150
+ end
151
+ result
152
+ end
153
+
154
+
155
+ # This method generates a textual description for a SQLType object.
156
+ def to_s
157
+ if @type == SQLType::DECIMAL or @type == SQLType::NUMERIC
158
+ "#{@type.id2name}(#{@precision},#{@scale})"
159
+ elsif @type == SQLType::BLOB
160
+ "#{@type.id2name} SUB TYPE #{@subtype}"
161
+ elsif @type == SQLType::CHAR or @type == SQLType::VARCHAR
162
+ "#{@type.id2name}(#{@length})"
163
+ else
164
+ @type.id2name
165
+ end
166
+ end
167
+
168
+
169
+ # This class method converts a Firebird internal type to a SQLType base
170
+ # type.
171
+ #
172
+ # ==== Parameters
173
+ # type:: A reference to the Firebird field type value.
174
+ # subtype:: A reference to the Firebird field subtype value.
175
+ def SQLType.to_base_type(type, subtype)
176
+ case type
177
+ when 16 # BIGINT, DECIMAL, NUMERIC
178
+ if subtype
179
+ subtype == 1 ? SQLType::NUMERIC : SQLType::DECIMAL
180
+ else
181
+ SQLType::BIGINT
182
+ end
183
+
184
+ when 261 # BLOB
185
+ SQLType::BLOB
186
+
187
+ when 14 # CHAR
188
+ SQLType::CHAR
189
+
190
+ when 12 # DATE
191
+ SQLType::DATE
192
+
193
+ when 27 # DOUBLE, DECIMAL, NUMERIC
194
+ if subtype
195
+ subtype == 1 ? SQLType::NUMERIC : SQLType::DECIMAL
196
+ else
197
+ SQLType::DOUBLE
198
+ end
199
+
200
+ when 10 # FLOAT
201
+ SQLType::FLOAT
202
+
203
+ when 8 # INTEGER, DECIMAL, NUMERIC
204
+ if subtype
205
+ subtype == 1 ? SQLType::NUMERIC : SQLType::DECIMAL
206
+ else
207
+ SQLType::INTEGER
208
+ end
209
+
210
+ when 7 # SMALLINT, DECIMAL, NUMERIC
211
+ if subtype
212
+ subtype == 1 ? SQLType::NUMERIC : SQLType::DECIMAL
213
+ else
214
+ SQLType::SMALLINT
215
+ end
216
+
217
+ when 13 # TIME
218
+ SQLType::TIME
219
+
220
+ when 35 # TIMESTAMP
221
+ SQLType::TIMESTAMP
222
+
223
+ when 37 # VARCHAR
224
+ SQLType::VARCHAR
225
+ end
226
+ end
227
+ end # End of the SQLType class.
228
+ end # End of the FireRuby module.
data/lib/fireruby.rb ADDED
@@ -0,0 +1,22 @@
1
+ #-------------------------------------------------------------------------------
2
+ # fireruby.rb
3
+ #-------------------------------------------------------------------------------
4
+ # Copyright � Peter Wood, 2005
5
+ #
6
+ # The contents of this file are subject to the Mozilla Public License Version
7
+ # 1.1 (the "License"); you may not use this file except in compliance with the
8
+ # License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.mozilla.org/MPL/
11
+ #
12
+ # Software distributed under the License is distributed on an "AS IS" basis,
13
+ # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14
+ # the specificlanguage governing rights and limitations under the License.
15
+ #
16
+ # The Original Code is the FireRuby extension for the Ruby language.
17
+ #
18
+ # The Initial Developer of the Original Code is Peter Wood. All Rights
19
+ # Reserved.
20
+
21
+ require 'fr_lib'
22
+ require 'SQLType'
data/lib/fr_lib.so ADDED
Binary file