og 0.20.0 → 0.21.0

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.
Files changed (53) hide show
  1. data/CHANGELOG +796 -664
  2. data/INSTALL +24 -24
  3. data/README +39 -32
  4. data/Rakefile +41 -42
  5. data/benchmark/bench.rb +36 -36
  6. data/doc/AUTHORS +15 -12
  7. data/doc/LICENSE +3 -3
  8. data/doc/RELEASES +311 -243
  9. data/doc/config.txt +1 -1
  10. data/examples/mysql_to_psql.rb +15 -15
  11. data/examples/run.rb +92 -92
  12. data/install.rb +7 -17
  13. data/lib/og.rb +76 -75
  14. data/lib/og/collection.rb +203 -160
  15. data/lib/og/entity.rb +168 -169
  16. data/lib/og/errors.rb +5 -5
  17. data/lib/og/manager.rb +179 -178
  18. data/lib/og/mixin/hierarchical.rb +107 -107
  19. data/lib/og/mixin/optimistic_locking.rb +36 -36
  20. data/lib/og/mixin/orderable.rb +148 -148
  21. data/lib/og/mixin/timestamped.rb +8 -8
  22. data/lib/og/mixin/tree.rb +124 -124
  23. data/lib/og/relation.rb +237 -213
  24. data/lib/og/relation/belongs_to.rb +5 -5
  25. data/lib/og/relation/has_many.rb +60 -58
  26. data/lib/og/relation/joins_many.rb +93 -47
  27. data/lib/og/relation/refers_to.rb +25 -21
  28. data/lib/og/store.rb +210 -207
  29. data/lib/og/store/filesys.rb +79 -79
  30. data/lib/og/store/kirby.rb +263 -258
  31. data/lib/og/store/memory.rb +261 -261
  32. data/lib/og/store/mysql.rb +288 -284
  33. data/lib/og/store/psql.rb +261 -244
  34. data/lib/og/store/sql.rb +873 -720
  35. data/lib/og/store/sqlite.rb +177 -175
  36. data/lib/og/store/sqlserver.rb +204 -214
  37. data/lib/og/types.rb +1 -1
  38. data/lib/og/validation.rb +57 -57
  39. data/lib/vendor/mysql.rb +376 -376
  40. data/lib/vendor/mysql411.rb +10 -10
  41. data/test/og/mixin/tc_hierarchical.rb +59 -59
  42. data/test/og/mixin/tc_optimistic_locking.rb +40 -40
  43. data/test/og/mixin/tc_orderable.rb +67 -67
  44. data/test/og/mixin/tc_timestamped.rb +19 -19
  45. data/test/og/store/tc_filesys.rb +46 -46
  46. data/test/og/tc_inheritance.rb +81 -81
  47. data/test/og/tc_join.rb +67 -0
  48. data/test/og/tc_polymorphic.rb +49 -49
  49. data/test/og/tc_relation.rb +57 -30
  50. data/test/og/tc_select.rb +49 -0
  51. data/test/og/tc_store.rb +345 -337
  52. data/test/og/tc_types.rb +11 -11
  53. metadata +11 -18
@@ -189,9 +189,9 @@ class Mysql
189
189
  field_count.times do
190
190
  len = get_length data
191
191
  if len == nil then
192
- rec << len
192
+ rec << len
193
193
  else
194
- rec << data.slice!(0,len)
194
+ rec << data.slice!(0,len)
195
195
  end
196
196
  end
197
197
  rec
@@ -213,8 +213,8 @@ class Mysql
213
213
  def skip_result_41()
214
214
  if @status == :STATUS_USE_RESULT then
215
215
  loop do
216
- data = read
217
- break if data[0] == 254 and data.length == 1
216
+ data = read
217
+ break if data[0] == 254 and data.length == 1
218
218
  end
219
219
  @status = :STATUS_READY
220
220
  end
@@ -277,11 +277,11 @@ class Mysql
277
277
  def read_query_result_41
278
278
  data = read
279
279
  @field_count = get_length(data)
280
- if @field_count == nil then # LOAD DATA LOCAL INFILE
280
+ if @field_count == nil then # LOAD DATA LOCAL INFILE
281
281
  File::open(data) do |f|
282
- write f.read
282
+ write f.read
283
283
  end
284
- write "" # mark EOF
284
+ write "" # mark EOF
285
285
  data = read
286
286
  @field_count = get_length(data)
287
287
  end
@@ -289,11 +289,11 @@ class Mysql
289
289
  @affected_rows = get_length(data, true)
290
290
  @insert_id = get_length(data, true)
291
291
  if @server_capabilities & CLIENT_TRANSACTIONS != 0 then
292
- a = data.slice!(0,2)
293
- @server_status = a[0]+a[1]*256
292
+ a = data.slice!(0,2)
293
+ @server_status = a[0]+a[1]*256
294
294
  end
295
295
  if data.size > 0 and get_length(data) then
296
- @info = data
296
+ @info = data
297
297
  end
298
298
  else
299
299
  @extra_info = get_length(data, true)
@@ -7,74 +7,74 @@ require 'og'
7
7
  require 'og/mixin/hierarchical'
8
8
 
9
9
  $og = Og.setup(
10
- :store => 'mysql',
11
- :name => 'test',
12
- :user => 'root',
13
- :password => 'navelrulez',
14
- :destroy => true
10
+ :store => 'mysql',
11
+ :name => 'test',
12
+ :user => 'root',
13
+ :password => 'navelrulez',
14
+ :destroy => true
15
15
  )
16
16
 
17
17
  class TC_OgHierarchical < Test::Unit::TestCase # :nodoc: all
18
18
 
19
- class Comment
20
- property :body, String
21
- property :create_time, Time
22
-
23
- include Og::NestedSets
19
+ class Comment
20
+ property :body, String
21
+ property :create_time, Time
22
+
23
+ include Og::NestedSets
24
24
 
25
- def initialize(body = nil)
26
- @body = body
27
- @create_time = Time.now
28
- end
25
+ def initialize(body = nil)
26
+ @body = body
27
+ @create_time = Time.now
28
+ end
29
29
 
30
- def to_s
31
- sprintf("%3d %3d %s", @lft, @rgt, @body)
32
- end
33
- end
30
+ def to_s
31
+ sprintf("%3d %3d %s", @lft, @rgt, @body)
32
+ end
33
+ end
34
34
 
35
- def test_all
36
- $og.manage_classes
35
+ def test_all
36
+ $og.manage_classes
37
37
 
38
- root = Comment.create('root')
39
- c1 = Comment.new('1')
40
- root.add_comment c1
41
- c2 = Comment.new('1.1')
42
- c1.add_comment c2
43
- c3 = Comment.new('1.2')
44
- c1.add_comment c3
45
- c4 = Comment.new('1.1.1')
46
- c2.add_comment c4
47
- c5 = Comment.new('1.2.1')
48
- c3.add_comment c5
49
- c6 = Comment.new('1.1.1.1')
50
- c4.add_comment c6
51
- c7 = Comment.new('2')
52
- root.add_comment c7
53
- c8 = Comment.new('3')
54
- root.add_comment c8
55
- c9 = Comment.new('2.1')
56
- c7.add_comment c9
38
+ root = Comment.create('root')
39
+ c1 = Comment.new('1')
40
+ root.add_comment c1
41
+ c2 = Comment.new('1.1')
42
+ c1.add_comment c2
43
+ c3 = Comment.new('1.2')
44
+ c1.add_comment c3
45
+ c4 = Comment.new('1.1.1')
46
+ c2.add_comment c4
47
+ c5 = Comment.new('1.2.1')
48
+ c3.add_comment c5
49
+ c6 = Comment.new('1.1.1.1')
50
+ c4.add_comment c6
51
+ c7 = Comment.new('2')
52
+ root.add_comment c7
53
+ c8 = Comment.new('3')
54
+ root.add_comment c8
55
+ c9 = Comment.new('2.1')
56
+ c7.add_comment c9
57
57
 
58
- c1.reload
59
-
60
- Comment.all(:order => "lft, rgt").each { |c|
61
- puts sprintf("%3d %3d %s", c.lft, c.rgt, c.body)
62
- # p c
63
- }
64
- puts '--1'
65
- c1.comments(:order => "lft, rgt").each { |c| puts c.body }
66
- puts '--2'
67
- c1.full_comments(:order => "lft, rgt").each { |c| puts c.body }
68
- puts '--3'
69
- c1.direct_comments(:order => "lft, rgt").each { |c| puts c.body }
58
+ c1.reload
59
+
60
+ Comment.all(:order => "lft, rgt").each { |c|
61
+ puts sprintf("%3d %3d %s", c.lft, c.rgt, c.body)
62
+ # p c
63
+ }
64
+ puts '--1'
65
+ c1.comments(:order => "lft, rgt").each { |c| puts c.body }
66
+ puts '--2'
67
+ c1.full_comments(:order => "lft, rgt").each { |c| puts c.body }
68
+ puts '--3'
69
+ c1.direct_comments(:order => "lft, rgt").each { |c| puts c.body }
70
70
 
71
- assert_equal 6, c1.full_comments.size
72
- assert_equal 5, c1.comments.size
73
- assert_equal 2, c1.direct_comments.size
74
-
75
- c8.reload
76
-
77
- assert_equal 'root', c8.parent.body
78
- end
71
+ assert_equal 6, c1.full_comments.size
72
+ assert_equal 5, c1.comments.size
73
+ assert_equal 2, c1.direct_comments.size
74
+
75
+ c8.reload
76
+
77
+ assert_equal 'root', c8.parent.body
78
+ end
79
79
 
80
80
  end
@@ -8,49 +8,49 @@ require 'og'
8
8
  require 'og/mixin/optimistic_locking'
9
9
 
10
10
  $og = Og.setup(
11
- :store => 'psql',
12
- :name => 'test',
13
- :user => 'postgres',
14
- :password => 'navelrulez',
15
- :destroy => true
11
+ :store => 'psql',
12
+ :name => 'test',
13
+ :user => 'postgres',
14
+ :password => 'navelrulez',
15
+ :destroy => true
16
16
  )
17
17
 
18
18
  class TC_OgLocking < Test::Unit::TestCase # :nodoc: all
19
- include Og
20
-
21
- class Article
22
- property :body, String
23
- include Og::Locking
24
-
25
- def initialize(body)
26
- @body = body
27
- end
28
- end
29
-
30
- def test_all
31
- $og.manage_classes
32
-
33
- Article.create('test')
19
+ include Og
20
+
21
+ class Article
22
+ property :body, String
23
+ include Og::Locking
24
+
25
+ def initialize(body)
26
+ @body = body
27
+ end
28
+ end
29
+
30
+ def test_all
31
+ $og.manage_classes
32
+
33
+ Article.create('test')
34
34
 
35
- a = Article[1]
36
-
37
- b = Article[1]
38
-
39
- a.body = 'Changed'
40
- assert_nothing_raised do
41
- a.save
42
- end
43
-
44
- b.body = 'Ooops'
45
- assert_raise(Og::StaleObjectError) do
46
- b.update
47
- end
48
-
49
- c = Article[1]
50
- a.body = 'Changed again'
51
- assert_nothing_raised do
52
- a.update
53
- end
54
- end
35
+ a = Article[1]
36
+
37
+ b = Article[1]
38
+
39
+ a.body = 'Changed'
40
+ assert_nothing_raised do
41
+ a.save
42
+ end
43
+
44
+ b.body = 'Ooops'
45
+ assert_raise(Og::StaleObjectError) do
46
+ b.update
47
+ end
48
+
49
+ c = Article[1]
50
+ a.body = 'Changed again'
51
+ assert_nothing_raised do
52
+ a.update
53
+ end
54
+ end
55
55
 
56
56
  end
@@ -7,101 +7,101 @@ require 'og'
7
7
  require 'og/mixin/orderable'
8
8
 
9
9
  $og = Og.setup(
10
- :store => 'psql',
11
- # :store => :memory,
12
- :name => 'test',
13
- :user => 'postgres',
14
- :password => 'navelrulez',
15
- :destroy => true
10
+ :store => 'psql',
11
+ # :store => :memory,
12
+ :name => 'test',
13
+ :user => 'postgres',
14
+ :password => 'navelrulez',
15
+ :destroy => true
16
16
  )
17
17
 
18
18
  class TestCaseOgOrderable < Test::Unit::TestCase # :nodoc: all
19
19
 
20
- class Comment; end
20
+ class Comment; end
21
21
 
22
- class Article
23
- property :title, :body, String
24
- has_many :comments, Comment, :list => true, :order => 'position DESC'
22
+ class Article
23
+ property :title, :body, String
24
+ has_many :comments, Comment, :list => true, :order => 'position DESC'
25
25
 
26
- def initialize(title = nil)
27
- @title = title
28
- end
29
- end
26
+ def initialize(title = nil)
27
+ @title = title
28
+ end
29
+ end
30
30
 
31
- class Comment
32
- property :body, String
33
- belongs_to :article, Article
34
-
35
- include Og::Orderable #, :scope => :article
31
+ class Comment
32
+ property :body, String
33
+ belongs_to :article, Article
34
+
35
+ include Og::Orderable #, :scope => :article
36
36
 
37
- def initialize(body = nil)
38
- @body = body
39
- end
40
- end
37
+ def initialize(body = nil)
38
+ @body = body
39
+ end
40
+ end
41
41
 
42
- def test_all
43
- $og.manage_classes
42
+ def test_all
43
+ $og.manage_classes
44
44
 
45
- a = Article.create('article')
46
- a.save
45
+ a = Article.create('article')
46
+ a.save
47
47
 
48
- c1 = Comment.create('1')
49
- a.comments << c1
50
- c2 = Comment.create('2')
51
- a.comments << c2
52
- c3 = Comment.create('3')
53
- a.comments << c3
48
+ c1 = Comment.create('1')
49
+ a.comments << c1
50
+ c2 = Comment.create('2')
51
+ a.comments << c2
52
+ c3 = Comment.create('3')
53
+ a.comments << c3
54
54
 
55
- assert_equal 1, c1.position
56
- assert_equal 2, c2.position
57
- assert_equal 3, c3.position
55
+ assert_equal 1, c1.position
56
+ assert_equal 2, c2.position
57
+ assert_equal 3, c3.position
58
58
 
59
- c3.move_higher
59
+ c3.move_higher
60
60
 
61
- c1.reload
62
- c2.reload
63
- c3.reload
61
+ c1.reload
62
+ c2.reload
63
+ c3.reload
64
64
 
65
- assert_equal 1, c1.position
65
+ assert_equal 1, c1.position
66
66
 
67
- assert_equal 2, c3.position
68
- assert_equal 3, c2.position
67
+ assert_equal 2, c3.position
68
+ assert_equal 3, c2.position
69
69
 
70
- c2.move_to_top
70
+ c2.move_to_top
71
71
 
72
- c1.reload
73
- c2.reload
74
- c3.reload
72
+ c1.reload
73
+ c2.reload
74
+ c3.reload
75
75
 
76
- assert_equal 1, c2.position
77
- assert_equal 2, c1.position
78
- assert_equal 3, c3.position
76
+ assert_equal 1, c2.position
77
+ assert_equal 2, c1.position
78
+ assert_equal 3, c3.position
79
79
 
80
- c2.move_to_bottom
80
+ c2.move_to_bottom
81
81
 
82
- c1.reload
83
- c2.reload
84
- c3.reload
82
+ c1.reload
83
+ c2.reload
84
+ c3.reload
85
85
 
86
- assert_equal 1, c1.position
87
- assert_equal 2, c3.position
88
- assert_equal 3, c2.position
86
+ assert_equal 1, c1.position
87
+ assert_equal 2, c3.position
88
+ assert_equal 3, c2.position
89
89
 
90
- c3.delete!
90
+ c3.delete!
91
91
 
92
- c1.reload
93
- c2.reload
92
+ c1.reload
93
+ c2.reload
94
94
 
95
- assert_equal 1, c1.position
96
- assert_equal 2, c2.position
95
+ assert_equal 1, c1.position
96
+ assert_equal 2, c2.position
97
97
 
98
- c2.delete!
98
+ c2.delete!
99
99
 
100
- c1.reload
100
+ c1.reload
101
101
 
102
- assert_equal 1, c1.position
102
+ assert_equal 1, c1.position
103
103
 
104
- c1.delete!
105
- end
104
+ c1.delete!
105
+ end
106
106
 
107
107
  end
@@ -7,32 +7,32 @@ require 'og'
7
7
  require 'og/mixin/timestamped'
8
8
 
9
9
  $og = Og.setup(
10
- :store => 'psql',
11
- :name => 'test',
12
- :user => 'postgres',
13
- :password => 'navelrulez',
14
- :destroy => true
10
+ :store => 'psql',
11
+ :name => 'test',
12
+ :user => 'postgres',
13
+ :password => 'navelrulez',
14
+ :destroy => true
15
15
  )
16
16
 
17
17
  class TestCaseOgTimestamped < Test::Unit::TestCase # :nodoc: all
18
18
 
19
- class Article
20
- include Og::Timestamped
21
- property :body, String
19
+ class Article
20
+ include Og::Timestamped
21
+ property :body, String
22
22
 
23
- def initialize(body = nil)
24
- @body = body
25
- end
26
- end
23
+ def initialize(body = nil)
24
+ @body = body
25
+ end
26
+ end
27
27
 
28
- def test_all
29
- $og.manage_classes
28
+ def test_all
29
+ $og.manage_classes
30
30
 
31
- a = Article.create('article')
32
- a.save
31
+ a = Article.create('article')
32
+ a.save
33
33
 
34
- a = Article[1]
35
- assert a.create_time
36
- end
34
+ a = Article[1]
35
+ assert a.create_time
36
+ end
37
37
 
38
38
  end