ibruby 0.5.4-mswin32 → 0.5.5-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  #-------------------------------------------------------------------------------
2
2
  # ibmeta.rb
3
3
  #-------------------------------------------------------------------------------
4
- # Copyright � Peter Wood, 2005; Richard Vowles, 2006
4
+ # Copyright � Peter Wood, 2005; Richard Vowles, 2006
5
5
  #
6
6
  # The contents of this file are subject to the Mozilla Public License Version
7
7
  # 1.1 (the "License"); you may not use this file except in compliance with the
@@ -287,7 +287,7 @@ module IBRuby
287
287
 
288
288
  def self.quote( value, column_meta_data )
289
289
  if column_meta_data.expects_quoting
290
- '#{value}'
290
+ "\'#{value}\'"
291
291
  elsif ((column_meta_data.type == InterBaseColumn::BLOB) && (column_meta_data.sub_type != 1 ) )
292
292
  raise IBRubyException.new("'#{value}' is not a valid default for this column #{column_meta_data.name}.")
293
293
  else
@@ -504,7 +504,7 @@ module IBRuby
504
504
  # allow these to be overriden
505
505
  @@default_precision = 10
506
506
  @@default_scale = 2
507
- @@default_length = 255
507
+ @@default_length = 252 #so string indexes work by default
508
508
 
509
509
  # A definition for a base SQL type.
510
510
  BOOLEAN = :BOOLEAN
@@ -3,7 +3,7 @@
3
3
  require 'TestSetup'
4
4
  require 'test/unit'
5
5
  #require 'rubygems'
6
- require 'ibruby'
6
+ require 'ib_lib'
7
7
 
8
8
  include IBRuby
9
9
 
@@ -36,7 +36,7 @@ class GeneratorTest < Test::Unit::TestCase
36
36
  def test01
37
37
  assert(Generator::exists?('TEST_GEN', @connections[0]) == false)
38
38
  g = Generator::create('TEST_GEN', @connections[0])
39
- assert(Generator::exists?('TEST_GEN', @connections[0]))
39
+ 10.times() { assert(Generator::exists?('TEST_GEN', @connections[0])) }
40
40
  assert(g.last == 0)
41
41
  assert(g.next(1) == 1)
42
42
  assert(g.last == 1)
@@ -46,5 +46,14 @@ class GeneratorTest < Test::Unit::TestCase
46
46
 
47
47
  g.drop
48
48
  assert(Generator::exists?('TEST_GEN', @connections[0]) == false)
49
- end
49
+ end
50
+
51
+ def test02
52
+ 4.times() do
53
+ assert(Generator::exists?('SAMPLE_GEN', @connections[0]) == false)
54
+ g = Generator::create('SAMPLE_GEN', @connections[0])
55
+ g.drop
56
+ trans.commit
57
+ end
58
+ end
50
59
  end
@@ -9,7 +9,7 @@ include IBRuby
9
9
 
10
10
  class KeyTest < Test::Unit::TestCase
11
11
  CURDIR = "#{Dir.getwd}"
12
- DB_FILE = "#{CURDIR}#{File::SEPARATOR}key_unit_test.fdb"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}key_unit_test.ib"
13
13
 
14
14
  def setup
15
15
  puts "#{self.class.name} started." if TEST_LOGGING
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'TestSetup'
4
+ require 'test/unit'
5
+ #require 'rubygems'
6
+ require 'ibruby'
7
+
8
+ include IBRuby
9
+
10
+ class MetaTest < Test::Unit::TestCase
11
+ CURDIR = "#{Dir.getwd}"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}meta_unit_test.ib"
13
+
14
+ def setup
15
+ puts "#{self.class.name} started." if TEST_LOGGING
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)
21
+ @connection = @database.connect(DB_USER_NAME, DB_PASSWORD)
22
+
23
+ @creation_sql = "create table mtest (id integer not null, "\
24
+ "bool1 boolean default false, bool2 boolean, bool3 boolean default true, bool4 boolean default true not null,"\
25
+ " blob1 blob sub_type 1 not null, blob2 blob sub_type 1, blob3 blob sub_type 0,"\
26
+ " char1 char(10) default 'fred', char2 char(10) default 'fred' not null, char3 char(10), char4 char(20) default 'wil''ma',"\
27
+ " date1 date default current_date, date2 date not null, date3 date default current_date not null,"\
28
+ " decimal1 decimal(18,5) default 1.345, decimal2 decimal(15,5) default 20.22 not null, decimal3 decimal(12,6) not null"\
29
+ ")"
30
+ #puts sql
31
+ @connection.execute_immediate( @creation_sql );
32
+ @connection.execute_immediate( "create table pk_table(id integer not null primary key)" )
33
+ @connection.execute_immediate( "create table fk_table(id integer not null primary key, "\
34
+ "fk_id integer references pk_table(id))" )
35
+ @pk_sql = "alter table mtest "
36
+
37
+ end
38
+
39
+
40
+ def teardown
41
+ @connection.close
42
+
43
+ if File::exist?(DB_FILE)
44
+ Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
45
+ end
46
+ puts "#{self.class.name} finished." if TEST_LOGGING
47
+ end
48
+
49
+ def test01
50
+ table = InterBaseTable.new('mtest')
51
+ assert_nothing_thrown( "failed to load table mtest" ) { table.load(@connection) }
52
+ sql = []
53
+ assert_nothing_thrown( "unable to build sql!" ) { sql = table.to_sql }
54
+ assert_not_nil sql, "sql returned nil for create table"
55
+ assert_equal sql.size > 0, true, "sql returned has nothing in it for table creation!"
56
+ #assert_equal @creation_sql.upcase, sql[0].upcase
57
+ #they ARE the same, but shows false and don't know why
58
+ puts sql
59
+ end
60
+
61
+ def test02
62
+ col = InterBaseMetaFunctions.table_fields( @connection, "mtest", true, "decimal2" )
63
+ new_col = col.dup
64
+ new_col.precision = 16
65
+ new_col.scale = 2
66
+ col.change_column(@connection,new_col)
67
+ new_col = InterBaseMetaFunctions.table_fields( @connection, "mtest", true, "decimal2" )
68
+
69
+ assert_equal false, new_col == col, "column decimal2 not changed"
70
+ assert_equal new_col.precision, 16, "column decimal2 precision not 16!"
71
+ assert_equal new_col.scale, 2, "column scale should be 2!"
72
+ end
73
+
74
+ def test03
75
+ col = InterBaseMetaFunctions.table_fields( @connection, "mtest", true, "decimal2" )
76
+ col.rename_column( @connection, "decimal_rename" )
77
+ ren_col = InterBaseMetaFunctions.table_fields( @connection, "mtest", true, "decimal2" )
78
+ assert_equal nil, ren_col, "column not renamed!"
79
+ new_col = InterBaseMetaFunctions.table_fields( @connection, "mtest", true, "decimal_rename" )
80
+ assert_equal new_col, col, "column types not identical after rename"
81
+ new_col.rename_column( @connection, "decimal2" )
82
+ end
83
+
84
+ def test04
85
+ table = InterBaseTable.new('fk_table')
86
+ table.load(@connection)
87
+ assert_nothing_thrown( "unable build sql for table fk_table! " ) do
88
+ table.to_sql.each() {|sql| puts "table creation sql: #{sql}" }
89
+ end
90
+ assert_nothing_thrown( "unable to rename table" ) do
91
+ table.rename_table( @connection, 'new_fk_table' )
92
+ end
93
+ table = InterBaseTable.new('new_fk_table')
94
+ table.load(@connection)
95
+ assert_nothing_thrown( "unable build sql for table fk_table! " ) do
96
+ table.to_sql.each() {|sql| puts "table creation sql: #{sql}" }
97
+ end
98
+ end
99
+ end
@@ -71,10 +71,10 @@ class DatabaseTest < Test::Unit::TestCase
71
71
  dropRole
72
72
  dropUser
73
73
 
74
- #~ if File::exist?(DB_FILE)
75
- #~ db = Database.new(DB_FILE)
76
- #~ db.drop(DB_USER_NAME, DB_PASSWORD)
77
- #~ end
74
+ if File::exist?(DB_FILE)
75
+ db = Database.new(DB_FILE)
76
+ db.drop(DB_USER_NAME, DB_PASSWORD)
77
+ end
78
78
  puts "#{self.class.name} finished." if TEST_LOGGING
79
79
  end
80
80
 
@@ -9,7 +9,7 @@ include IBRuby
9
9
 
10
10
  class SQLTypeTest < Test::Unit::TestCase
11
11
  CURDIR = "#{Dir.getwd}"
12
- DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_type_test.fdb"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_type_test.ib"
13
13
 
14
14
  def setup
15
15
  puts "#{self.class.name} started." if TEST_LOGGING
@@ -9,7 +9,7 @@ include IBRuby
9
9
 
10
10
  class StatementTest < Test::Unit::TestCase
11
11
  CURDIR = "#{Dir.getwd}"
12
- DB_FILE = "#{CURDIR}#{File::SEPARATOR}stmt_unit_test.fdb"
12
+ DB_FILE = "#{CURDIR}#{File::SEPARATOR}stmt_unit_test.ib"
13
13
 
14
14
  def setup
15
15
  puts "#{self.class.name} started." if TEST_LOGGING
@@ -53,8 +53,8 @@ class TypeTest < Test::Unit::TestCase
53
53
  row = rows.fetch
54
54
  assert(row[0].kind_of?(Integer))
55
55
  assert(row[1].instance_of?(Float))
56
- assert(row[2].instance_of?(Float))
57
- assert(row[3].instance_of?(Float))
56
+ assert(row[2].kind_of?(Numeric))
57
+ assert(row[3].kind_of?(Numeric))
58
58
  assert(row[4].instance_of?(Date))
59
59
  assert(row[5].instance_of?(Time))
60
60
  assert(row[6].instance_of?(String))
@@ -75,8 +75,8 @@ class TypeTest < Test::Unit::TestCase
75
75
  row = rows.fetch
76
76
  assert(row[0].kind_of?(Integer))
77
77
  assert(row[1].instance_of?(Float))
78
- assert(row[2].instance_of?(Float))
79
- assert(row[3].instance_of?(Float))
78
+ assert(row[2].kind_of?(Numeric))
79
+ assert(row[3].kind_of?(Numeric))
80
80
  assert(row[4].instance_of?(Time))
81
81
  assert(row[5].instance_of?(Time))
82
82
  assert(row[6].instance_of?(String))
@@ -32,8 +32,8 @@
32
32
  #require 'TypeTest'
33
33
  #require 'SQLTypeTest'
34
34
  #if PLATFORM.include?('powerpc-darwin') == false
35
- # require 'BackupRestoreTest'
36
- # require 'AddRemoveUserTest'
35
+ #require 'BackupRestoreTest'
36
+ #require 'AddRemoveUserTest'
37
37
  #end
38
38
  #-------------------------------------------------------------------------------
39
39
  SPECIALS = ['AddRemoveUserTest',
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ibruby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.4
7
- date: 2007-01-12 00:00:00 +13:00
6
+ version: 0.5.5
7
+ date: 2007-09-08 00:00:00 +12:00
8
8
  summary: Ruby interface library for the InterBase database.
9
9
  require_paths:
10
10
  - lib
@@ -43,6 +43,7 @@ files:
43
43
  - test/DDLTest.rb
44
44
  - test/GeneratorTest.rb
45
45
  - test/KeyTest.rb
46
+ - test/MetaTest.rb
46
47
  - test/ResultSetTest.rb
47
48
  - test/RoleTest.rb
48
49
  - test/RowCountTest.rb