KirbyBase 2.6 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/README +65 -67
  2. data/bin/kbserver.rb +18 -18
  3. data/changes.txt +144 -137
  4. data/examples/aaa_try_this_first/kbtest.rb +237 -237
  5. data/examples/add_column_test/add_column_test.rb +27 -27
  6. data/examples/calculated_field_test/calculated_field_test.rb +51 -51
  7. data/examples/change_column_type_test/change_column_type_test.rb +25 -25
  8. data/examples/column_required_test/column_required_test.rb +44 -44
  9. data/examples/crosstab_test/crosstab_test.rb +100 -100
  10. data/examples/csv_import_test/csv_import_test.rb +31 -31
  11. data/examples/csv_import_test/plane.csv +11 -11
  12. data/examples/default_value_test/default_value_test.rb +54 -54
  13. data/examples/drop_column_test/drop_column_test.rb +24 -24
  14. data/examples/indexes_test/add_index_test.rb +46 -46
  15. data/examples/indexes_test/drop_index_test.rb +65 -65
  16. data/examples/indexes_test/index_test.rb +94 -94
  17. data/examples/kbserver_as_win32_service/kbserver_daemon.rb +47 -47
  18. data/examples/kbserver_as_win32_service/kbserverctl.rb +75 -75
  19. data/examples/link_many_test/link_many_test.rb +70 -70
  20. data/examples/lookup_field_test/lookup_field_test.rb +55 -55
  21. data/examples/lookup_field_test/lookup_field_test_2.rb +62 -62
  22. data/examples/lookup_field_test/the_hal_fulton_feature_test.rb +69 -69
  23. data/examples/many_to_many_test/many_to_many_test.rb +65 -65
  24. data/examples/memo_test/memo_test.rb +74 -74
  25. data/examples/record_class_test/record_class_test.rb +77 -77
  26. data/examples/record_class_test/record_class_test2.rb +31 -31
  27. data/examples/rename_column_test/rename_column_test.rb +45 -45
  28. data/examples/rename_table_test/rename_table_test.rb +38 -38
  29. data/examples/yaml_field_test/yaml_field_test.rb +47 -47
  30. data/kirbybaserubymanual.html +2324 -2324
  31. data/lib/kirbybase.rb +3907 -3880
  32. data/test/tc_local_table.rb +108 -108
  33. metadata +56 -54
@@ -1,55 +1,55 @@
1
- # This script demonstrates how to link a field in the table to an entire
2
- # record from another table (i.e. a "one to one" relationship in database
3
- # lingo).
4
-
5
- # In the example below, we have a department table. For each department
6
- # record, the manager field is actually a reference to a record from the
7
- # person table. This allows us to reference the linked person record
8
- # through the manager field.
9
-
10
- require 'kirbybase'
11
-
12
- db = KirbyBase.new
13
-
14
- # To run as a client in a multi-user environment, uncomment next line.
15
- # Also, make sure kbserver.rb is running.
16
- #db = KirbyBase.new do |d|
17
- # d.connect_type = :client
18
- # d.host = 'localhost'
19
- # d.port = 44444
20
- #end
21
-
22
- # If tables exists, delete them.
23
- db.drop_table(:department) if db.table_exists?(:department)
24
- db.drop_table(:person) if db.table_exists?(:person)
25
-
26
- # Create a person table. Create lookup table first before the table that
27
- # uses the lookup table, so that KirbyBase can take advantage of any
28
- # indexes.
29
- person_tbl = db.create_table(:person,
30
- :person_id, :String,
31
- :name, :String,
32
- :phone, :String
33
- )
34
-
35
- # Insert some person records.
36
- person_tbl.insert('000-13-5031', 'John Smith', '512.555.1234')
37
- person_tbl.insert('010-10-9999', 'Jane Doe', '313.724.4230')
38
-
39
- # Create a table. We are telling KirbyBase that the manager field is
40
- # to be linked to the person table.
41
- department_tbl = db.create_table(:department,
42
- :dept_id, :Integer,
43
- :dept_name, :String,
44
- :manager, {:DataType=>:String, :Lookup=>[:person, :person_id]})
45
-
46
- # Insert some department records.
47
- department_tbl.insert(345, 'Payroll', '000-13-5031')
48
- department_tbl.insert(442, 'Accounting', '010-10-9999')
49
-
50
- # Print department info. Notice how we also print info from the linked
51
- # person record.
52
- department_tbl.select.each do |r|
53
- puts "\n%s %s %s %s %s" % [r.dept_id, r.dept_name,
54
- r.manager.person_id, r.manager.name, r.manager.phone]
55
- end
1
+ # This script demonstrates how to link a field in the table to an entire
2
+ # record from another table (i.e. a "one to one" relationship in database
3
+ # lingo).
4
+
5
+ # In the example below, we have a department table. For each department
6
+ # record, the manager field is actually a reference to a record from the
7
+ # person table. This allows us to reference the linked person record
8
+ # through the manager field.
9
+
10
+ require 'kirbybase'
11
+
12
+ db = KirbyBase.new
13
+
14
+ # To run as a client in a multi-user environment, uncomment next line.
15
+ # Also, make sure kbserver.rb is running.
16
+ #db = KirbyBase.new do |d|
17
+ # d.connect_type = :client
18
+ # d.host = 'localhost'
19
+ # d.port = 44444
20
+ #end
21
+
22
+ # If tables exists, delete them.
23
+ db.drop_table(:department) if db.table_exists?(:department)
24
+ db.drop_table(:person) if db.table_exists?(:person)
25
+
26
+ # Create a person table. Create lookup table first before the table that
27
+ # uses the lookup table, so that KirbyBase can take advantage of any
28
+ # indexes.
29
+ person_tbl = db.create_table(:person,
30
+ :person_id, :String,
31
+ :name, :String,
32
+ :phone, :String
33
+ )
34
+
35
+ # Insert some person records.
36
+ person_tbl.insert('000-13-5031', 'John Smith', '512.555.1234')
37
+ person_tbl.insert('010-10-9999', 'Jane Doe', '313.724.4230')
38
+
39
+ # Create a table. We are telling KirbyBase that the manager field is
40
+ # to be linked to the person table.
41
+ department_tbl = db.create_table(:department,
42
+ :dept_id, :Integer,
43
+ :dept_name, :String,
44
+ :manager, {:DataType=>:String, :Lookup=>[:person, :person_id]})
45
+
46
+ # Insert some department records.
47
+ department_tbl.insert(345, 'Payroll', '000-13-5031')
48
+ department_tbl.insert(442, 'Accounting', '010-10-9999')
49
+
50
+ # Print department info. Notice how we also print info from the linked
51
+ # person record.
52
+ department_tbl.select.each do |r|
53
+ puts "\n%s %s %s %s %s" % [r.dept_id, r.dept_name,
54
+ r.manager.person_id, r.manager.name, r.manager.phone]
55
+ end
@@ -1,62 +1,62 @@
1
- # This script demonstrates how to link a field in the table to an entire
2
- # record from another table (sometimes called a "lookup table"). This
3
- # script is different from 'lookup_field_test.rb' because it shows how to
4
- # use the "lookup_key" table attribute to make it easier to define a
5
- # Lookup field.
6
-
7
- # In the example below, we have a department table. For each department
8
- # record, the manager field is actually a reference to a record from the
9
- # person table. This allows us to reference the linked person record
10
- # through the manager field.
11
-
12
- require 'kirbybase'
13
-
14
- db = KirbyBase.new
15
-
16
- # To run as a client in a multi-user environment, uncomment next line.
17
- # Also, make sure kbserver.rb is running.
18
- #db = KirbyBase.new do |d|
19
- # d.connect_type = :client
20
- # d.host = 'localhost'
21
- # d.port = 44444
22
- #end
23
-
24
- # If tables exists, delete them.
25
- db.drop_table(:department) if db.table_exists?(:department)
26
- db.drop_table(:person) if db.table_exists?(:person)
27
-
28
- # Create a person table. Create lookup table first before the table that
29
- # uses the lookup table, so that KirbyBase can take advantage of any
30
- # indexes. Also, we want to create the lookup table first so that we can
31
- # define a lookup key. We do this by adding a :Key entry to the field type
32
- # has and assigning true to it's value.
33
- person_tbl = db.create_table(:person,
34
- :person_id, {:DataType=>:String, :Key=>true},
35
- :name, :String,
36
- :phone, :String
37
- )
38
-
39
- # Insert some person records.
40
- person_tbl.insert('000-13-5031', 'John Smith', '512.555.1234')
41
- person_tbl.insert('010-10-9999', 'Jane Doe', '313.724.4230')
42
-
43
- # Create a table. We are telling KirbyBase that the manager field is
44
- # to be linked to the person table. Notice that in this example, since we
45
- # want the manager field in this table to be linked to the person_id in the
46
- # person table, which is that table's lookup key field, all we have to
47
- # specify here is the name of the lookup table, :person.
48
- department_tbl = db.create_table(:department,
49
- :dept_id, :Integer,
50
- :dept_name, :String,
51
- :manager, {:DataType=>:String, :Lookup=>:person})
52
-
53
- # Insert some department records.
54
- department_tbl.insert(345, 'Payroll', '000-13-5031')
55
- department_tbl.insert(442, 'Accounting', '010-10-9999')
56
-
57
- # Print department info. Notice how we also print info from the linked
58
- # person record.
59
- department_tbl.select.each do |r|
60
- puts "\n%s %s %s %s %s" % [r.dept_id, r.dept_name,
61
- r.manager.person_id, r.manager.name, r.manager.phone]
62
- end
1
+ # This script demonstrates how to link a field in the table to an entire
2
+ # record from another table (sometimes called a "lookup table"). This
3
+ # script is different from 'lookup_field_test.rb' because it shows how to
4
+ # use the "lookup_key" table attribute to make it easier to define a
5
+ # Lookup field.
6
+
7
+ # In the example below, we have a department table. For each department
8
+ # record, the manager field is actually a reference to a record from the
9
+ # person table. This allows us to reference the linked person record
10
+ # through the manager field.
11
+
12
+ require 'kirbybase'
13
+
14
+ db = KirbyBase.new
15
+
16
+ # To run as a client in a multi-user environment, uncomment next line.
17
+ # Also, make sure kbserver.rb is running.
18
+ #db = KirbyBase.new do |d|
19
+ # d.connect_type = :client
20
+ # d.host = 'localhost'
21
+ # d.port = 44444
22
+ #end
23
+
24
+ # If tables exists, delete them.
25
+ db.drop_table(:department) if db.table_exists?(:department)
26
+ db.drop_table(:person) if db.table_exists?(:person)
27
+
28
+ # Create a person table. Create lookup table first before the table that
29
+ # uses the lookup table, so that KirbyBase can take advantage of any
30
+ # indexes. Also, we want to create the lookup table first so that we can
31
+ # define a lookup key. We do this by adding a :Key entry to the field type
32
+ # has and assigning true to it's value.
33
+ person_tbl = db.create_table(:person,
34
+ :person_id, {:DataType=>:String, :Key=>true},
35
+ :name, :String,
36
+ :phone, :String
37
+ )
38
+
39
+ # Insert some person records.
40
+ person_tbl.insert('000-13-5031', 'John Smith', '512.555.1234')
41
+ person_tbl.insert('010-10-9999', 'Jane Doe', '313.724.4230')
42
+
43
+ # Create a table. We are telling KirbyBase that the manager field is
44
+ # to be linked to the person table. Notice that in this example, since we
45
+ # want the manager field in this table to be linked to the person_id in the
46
+ # person table, which is that table's lookup key field, all we have to
47
+ # specify here is the name of the lookup table, :person.
48
+ department_tbl = db.create_table(:department,
49
+ :dept_id, :Integer,
50
+ :dept_name, :String,
51
+ :manager, {:DataType=>:String, :Lookup=>:person})
52
+
53
+ # Insert some department records.
54
+ department_tbl.insert(345, 'Payroll', '000-13-5031')
55
+ department_tbl.insert(442, 'Accounting', '010-10-9999')
56
+
57
+ # Print department info. Notice how we also print info from the linked
58
+ # person record.
59
+ department_tbl.select.each do |r|
60
+ puts "\n%s %s %s %s %s" % [r.dept_id, r.dept_name,
61
+ r.manager.person_id, r.manager.name, r.manager.phone]
62
+ end
@@ -1,69 +1,69 @@
1
- # This script demonstrates how to link a field in the table to an entire
2
- # record from another table (sometimes called a "lookup table"). This
3
- # script is different from 'lookup_field_test_2.rb' because it shows how to
4
- # define a Lookup field in an even easier way, by just specifying the
5
- # lookup table as the field type for the lookup field. KirbyBase will
6
- # determine the field type for the lookup field by looking at the field
7
- # type of the key field of the lookup table. This is a feature that Hal
8
- # Fulton has been asking for so I named it in honor of him. :)
9
-
10
- # In the example below, we have a department table. For each department
11
- # record, the manager field is actually a reference to a record from the
12
- # person table. This allows us to reference the linked person record
13
- # through the manager field.
14
-
15
- require 'kirbybase'
16
-
17
- db = KirbyBase.new
18
-
19
- # To run as a client in a multi-user environment, uncomment next line.
20
- # Also, make sure kbserver.rb is running.
21
- #db = KirbyBase.new do |d|
22
- # d.connect_type = :client
23
- # d.host = 'localhost'
24
- # d.port = 44444
25
- #end
26
-
27
- # If tables exists, delete them.
28
- db.drop_table(:department) if db.table_exists?(:department)
29
- db.drop_table(:person) if db.table_exists?(:person)
30
-
31
- # Create a person table. Create lookup table first before the table that
32
- # uses the lookup table, so that KirbyBase can take advantage of any
33
- # indexes. Also, we want to create the lookup table first so that we can
34
- # define a lookup key. We do this by adding a :Key entry to the field type
35
- # has and assigning true to it's value.
36
- person_tbl = db.create_table(:person,
37
- :person_id, {:DataType=>:String, :Key=>true},
38
- :name, :String,
39
- :phone, :String
40
- )
41
-
42
- # Insert some person records.
43
- person_tbl.insert('000-13-5031', 'John Smith', '512.555.1234')
44
- person_tbl.insert('010-10-9999', 'Jane Doe', '313.724.4230')
45
-
46
- # Create a table. We are telling KirbyBase that the manager field is
47
- # to be linked to the person table. Notice that in this example, since we
48
- # want the manager field in this table to be linked to the person_id in the
49
- # person table, which is that table's lookup key field, all we have to
50
- # specify here is the name of the lookup table, :person. We don't even
51
- # have to specify the field type for the :manager field, because
52
- # KirbyBase will look at the field type definition for :person.person_id
53
- # to automatically assign :manager the same field type (i.e. :String).
54
-
55
- department_tbl = db.create_table(:department,
56
- :dept_id, :Integer,
57
- :dept_name, :String,
58
- :manager, :person)
59
-
60
- # Insert some department records.
61
- department_tbl.insert(345, 'Payroll', '000-13-5031')
62
- department_tbl.insert(442, 'Accounting', '010-10-9999')
63
-
64
- # Print department info. Notice how we also print info from the linked
65
- # person record.
66
- department_tbl.select.each do |r|
67
- puts "\n%s %s %s %s %s" % [r.dept_id, r.dept_name,
68
- r.manager.person_id, r.manager.name, r.manager.phone]
69
- end
1
+ # This script demonstrates how to link a field in the table to an entire
2
+ # record from another table (sometimes called a "lookup table"). This
3
+ # script is different from 'lookup_field_test_2.rb' because it shows how to
4
+ # define a Lookup field in an even easier way, by just specifying the
5
+ # lookup table as the field type for the lookup field. KirbyBase will
6
+ # determine the field type for the lookup field by looking at the field
7
+ # type of the key field of the lookup table. This is a feature that Hal
8
+ # Fulton has been asking for so I named it in honor of him. :)
9
+
10
+ # In the example below, we have a department table. For each department
11
+ # record, the manager field is actually a reference to a record from the
12
+ # person table. This allows us to reference the linked person record
13
+ # through the manager field.
14
+
15
+ require 'kirbybase'
16
+
17
+ db = KirbyBase.new
18
+
19
+ # To run as a client in a multi-user environment, uncomment next line.
20
+ # Also, make sure kbserver.rb is running.
21
+ #db = KirbyBase.new do |d|
22
+ # d.connect_type = :client
23
+ # d.host = 'localhost'
24
+ # d.port = 44444
25
+ #end
26
+
27
+ # If tables exists, delete them.
28
+ db.drop_table(:department) if db.table_exists?(:department)
29
+ db.drop_table(:person) if db.table_exists?(:person)
30
+
31
+ # Create a person table. Create lookup table first before the table that
32
+ # uses the lookup table, so that KirbyBase can take advantage of any
33
+ # indexes. Also, we want to create the lookup table first so that we can
34
+ # define a lookup key. We do this by adding a :Key entry to the field type
35
+ # has and assigning true to it's value.
36
+ person_tbl = db.create_table(:person,
37
+ :person_id, {:DataType=>:String, :Key=>true},
38
+ :name, :String,
39
+ :phone, :String
40
+ )
41
+
42
+ # Insert some person records.
43
+ person_tbl.insert('000-13-5031', 'John Smith', '512.555.1234')
44
+ person_tbl.insert('010-10-9999', 'Jane Doe', '313.724.4230')
45
+
46
+ # Create a table. We are telling KirbyBase that the manager field is
47
+ # to be linked to the person table. Notice that in this example, since we
48
+ # want the manager field in this table to be linked to the person_id in the
49
+ # person table, which is that table's lookup key field, all we have to
50
+ # specify here is the name of the lookup table, :person. We don't even
51
+ # have to specify the field type for the :manager field, because
52
+ # KirbyBase will look at the field type definition for :person.person_id
53
+ # to automatically assign :manager the same field type (i.e. :String).
54
+
55
+ department_tbl = db.create_table(:department,
56
+ :dept_id, :Integer,
57
+ :dept_name, :String,
58
+ :manager, :person)
59
+
60
+ # Insert some department records.
61
+ department_tbl.insert(345, 'Payroll', '000-13-5031')
62
+ department_tbl.insert(442, 'Accounting', '010-10-9999')
63
+
64
+ # Print department info. Notice how we also print info from the linked
65
+ # person record.
66
+ department_tbl.select.each do |r|
67
+ puts "\n%s %s %s %s %s" % [r.dept_id, r.dept_name,
68
+ r.manager.person_id, r.manager.name, r.manager.phone]
69
+ end
@@ -1,65 +1,65 @@
1
- # This script demonstrates how you could do many-to-many relationships in
2
- # KirbyBase.
3
-
4
- require 'kirbybase'
5
-
6
- db = KirbyBase.new
7
-
8
- # Delete tables if they already exist.
9
- db.drop_table(:author) if db.table_exists?(:author)
10
- db.drop_table(:book) if db.table_exists?(:book)
11
- db.drop_table(:book_author) if db.table_exists?(:book_author)
12
-
13
- # Create author table. Notice how we are creating a one-to-many link to
14
- # the book_author table.
15
- author_tbl = db.create_table(:author,
16
- :author_id, :Integer, :name, :String,
17
- :books, {:DataType=>:ResultSet,
18
- :Link_many=>[:author_id, :book_author, :author_id]}
19
- )
20
-
21
- # Create book table. Notice how we are creating a one-to-many link to
22
- # the book_author table.
23
- book_tbl = db.create_table(:book,
24
- :book_id, :Integer, :title, :String,
25
- :authors, {:DataType=>:ResultSet,
26
- :Link_many=>[:book_id, :book_author, :book_id]}
27
- )
28
-
29
- # Create join table that will connect author table and book table.
30
- book_author_tbl = db.create_table(:book_author, :book_id, :Integer,
31
- :author_id, :Integer)
32
-
33
- # Insert some author records.
34
- author_tbl.insert(1, 'Jules Verne', nil)
35
- author_tbl.insert(2, 'Margaret Weis', nil)
36
- author_tbl.insert(3, 'Tracy Hickman', nil)
37
-
38
- # Insert some book records.
39
- book_tbl.insert(1, 'Voyage to the Bottom of the Sea', nil)
40
- book_tbl.insert(2, 'From the Earth to the Moon', nil)
41
- book_tbl.insert(3, 'Dragons of Winter Night', nil)
42
- book_tbl.insert(4, 'The Nightmare Lands', nil)
43
-
44
- # Insert some records into the book_author table that will link the book
45
- # table to the author table.
46
- book_author_tbl.insert(1, 1)
47
- book_author_tbl.insert(2, 1)
48
- book_author_tbl.insert(3, 2)
49
- book_author_tbl.insert(3, 3)
50
- book_author_tbl.insert(4, 2)
51
- book_author_tbl.insert(4, 3)
52
-
53
-
54
- # Show all book titles written by Jules Verne.
55
- author_tbl.select { |r| r.name == 'Jules Verne'
56
- }.first.books.each { |b|
57
- puts book_tbl.select { |r| r.book_id == b.book_id }.first.title
58
- }
59
- puts
60
-
61
- # Show the authors of "The Nightmare Lands".
62
- book_tbl.select { |r| r.title == 'The Nightmare Lands'
63
- }.first.authors.each { |a|
64
- puts author_tbl.select { |r| r.author_id == a.author_id }.first.name
65
- }
1
+ # This script demonstrates how you could do many-to-many relationships in
2
+ # KirbyBase.
3
+
4
+ require 'kirbybase'
5
+
6
+ db = KirbyBase.new
7
+
8
+ # Delete tables if they already exist.
9
+ db.drop_table(:author) if db.table_exists?(:author)
10
+ db.drop_table(:book) if db.table_exists?(:book)
11
+ db.drop_table(:book_author) if db.table_exists?(:book_author)
12
+
13
+ # Create author table. Notice how we are creating a one-to-many link to
14
+ # the book_author table.
15
+ author_tbl = db.create_table(:author,
16
+ :author_id, :Integer, :name, :String,
17
+ :books, {:DataType=>:ResultSet,
18
+ :Link_many=>[:author_id, :book_author, :author_id]}
19
+ )
20
+
21
+ # Create book table. Notice how we are creating a one-to-many link to
22
+ # the book_author table.
23
+ book_tbl = db.create_table(:book,
24
+ :book_id, :Integer, :title, :String,
25
+ :authors, {:DataType=>:ResultSet,
26
+ :Link_many=>[:book_id, :book_author, :book_id]}
27
+ )
28
+
29
+ # Create join table that will connect author table and book table.
30
+ book_author_tbl = db.create_table(:book_author, :book_id, :Integer,
31
+ :author_id, :Integer)
32
+
33
+ # Insert some author records.
34
+ author_tbl.insert(1, 'Jules Verne', nil)
35
+ author_tbl.insert(2, 'Margaret Weis', nil)
36
+ author_tbl.insert(3, 'Tracy Hickman', nil)
37
+
38
+ # Insert some book records.
39
+ book_tbl.insert(1, 'Voyage to the Bottom of the Sea', nil)
40
+ book_tbl.insert(2, 'From the Earth to the Moon', nil)
41
+ book_tbl.insert(3, 'Dragons of Winter Night', nil)
42
+ book_tbl.insert(4, 'The Nightmare Lands', nil)
43
+
44
+ # Insert some records into the book_author table that will link the book
45
+ # table to the author table.
46
+ book_author_tbl.insert(1, 1)
47
+ book_author_tbl.insert(2, 1)
48
+ book_author_tbl.insert(3, 2)
49
+ book_author_tbl.insert(3, 3)
50
+ book_author_tbl.insert(4, 2)
51
+ book_author_tbl.insert(4, 3)
52
+
53
+
54
+ # Show all book titles written by Jules Verne.
55
+ author_tbl.select { |r| r.name == 'Jules Verne'
56
+ }.first.books.each { |b|
57
+ puts book_tbl.select { |r| r.book_id == b.book_id }.first.title
58
+ }
59
+ puts
60
+
61
+ # Show the authors of "The Nightmare Lands".
62
+ book_tbl.select { |r| r.title == 'The Nightmare Lands'
63
+ }.first.authors.each { |a|
64
+ puts author_tbl.select { |r| r.author_id == a.author_id }.first.name
65
+ }