og 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +796 -664
- data/INSTALL +24 -24
- data/README +39 -32
- data/Rakefile +41 -42
- data/benchmark/bench.rb +36 -36
- data/doc/AUTHORS +15 -12
- data/doc/LICENSE +3 -3
- data/doc/RELEASES +311 -243
- data/doc/config.txt +1 -1
- data/examples/mysql_to_psql.rb +15 -15
- data/examples/run.rb +92 -92
- data/install.rb +7 -17
- data/lib/og.rb +76 -75
- data/lib/og/collection.rb +203 -160
- data/lib/og/entity.rb +168 -169
- data/lib/og/errors.rb +5 -5
- data/lib/og/manager.rb +179 -178
- data/lib/og/mixin/hierarchical.rb +107 -107
- data/lib/og/mixin/optimistic_locking.rb +36 -36
- data/lib/og/mixin/orderable.rb +148 -148
- data/lib/og/mixin/timestamped.rb +8 -8
- data/lib/og/mixin/tree.rb +124 -124
- data/lib/og/relation.rb +237 -213
- data/lib/og/relation/belongs_to.rb +5 -5
- data/lib/og/relation/has_many.rb +60 -58
- data/lib/og/relation/joins_many.rb +93 -47
- data/lib/og/relation/refers_to.rb +25 -21
- data/lib/og/store.rb +210 -207
- data/lib/og/store/filesys.rb +79 -79
- data/lib/og/store/kirby.rb +263 -258
- data/lib/og/store/memory.rb +261 -261
- data/lib/og/store/mysql.rb +288 -284
- data/lib/og/store/psql.rb +261 -244
- data/lib/og/store/sql.rb +873 -720
- data/lib/og/store/sqlite.rb +177 -175
- data/lib/og/store/sqlserver.rb +204 -214
- data/lib/og/types.rb +1 -1
- data/lib/og/validation.rb +57 -57
- data/lib/vendor/mysql.rb +376 -376
- data/lib/vendor/mysql411.rb +10 -10
- data/test/og/mixin/tc_hierarchical.rb +59 -59
- data/test/og/mixin/tc_optimistic_locking.rb +40 -40
- data/test/og/mixin/tc_orderable.rb +67 -67
- data/test/og/mixin/tc_timestamped.rb +19 -19
- data/test/og/store/tc_filesys.rb +46 -46
- data/test/og/tc_inheritance.rb +81 -81
- data/test/og/tc_join.rb +67 -0
- data/test/og/tc_polymorphic.rb +49 -49
- data/test/og/tc_relation.rb +57 -30
- data/test/og/tc_select.rb +49 -0
- data/test/og/tc_store.rb +345 -337
- data/test/og/tc_types.rb +11 -11
- metadata +11 -18
data/lib/vendor/mysql411.rb
CHANGED
@@ -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
|
-
|
192
|
+
rec << len
|
193
193
|
else
|
194
|
-
|
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
|
-
|
217
|
-
|
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
|
280
|
+
if @field_count == nil then # LOAD DATA LOCAL INFILE
|
281
281
|
File::open(data) do |f|
|
282
|
-
|
282
|
+
write f.read
|
283
283
|
end
|
284
|
-
write ""
|
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
|
-
|
293
|
-
|
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
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
class Comment
|
20
|
+
property :body, String
|
21
|
+
property :create_time, Time
|
22
|
+
|
23
|
+
include Og::NestedSets
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def initialize(body = nil)
|
26
|
+
@body = body
|
27
|
+
@create_time = Time.now
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def to_s
|
31
|
+
sprintf("%3d %3d %s", @lft, @rgt, @body)
|
32
|
+
end
|
33
|
+
end
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
def test_all
|
36
|
+
$og.manage_classes
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
20
|
+
class Comment; end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
class Article
|
23
|
+
property :title, :body, String
|
24
|
+
has_many :comments, Comment, :list => true, :order => 'position DESC'
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def initialize(title = nil)
|
27
|
+
@title = title
|
28
|
+
end
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
class Comment
|
32
|
+
property :body, String
|
33
|
+
belongs_to :article, Article
|
34
|
+
|
35
|
+
include Og::Orderable #, :scope => :article
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
def initialize(body = nil)
|
38
|
+
@body = body
|
39
|
+
end
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
def test_all
|
43
|
+
$og.manage_classes
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
a = Article.create('article')
|
46
|
+
a.save
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
55
|
+
assert_equal 1, c1.position
|
56
|
+
assert_equal 2, c2.position
|
57
|
+
assert_equal 3, c3.position
|
58
58
|
|
59
|
-
|
59
|
+
c3.move_higher
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
c1.reload
|
62
|
+
c2.reload
|
63
|
+
c3.reload
|
64
64
|
|
65
|
-
|
65
|
+
assert_equal 1, c1.position
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
assert_equal 2, c3.position
|
68
|
+
assert_equal 3, c2.position
|
69
69
|
|
70
|
-
|
70
|
+
c2.move_to_top
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
c1.reload
|
73
|
+
c2.reload
|
74
|
+
c3.reload
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
assert_equal 1, c2.position
|
77
|
+
assert_equal 2, c1.position
|
78
|
+
assert_equal 3, c3.position
|
79
79
|
|
80
|
-
|
80
|
+
c2.move_to_bottom
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
c1.reload
|
83
|
+
c2.reload
|
84
|
+
c3.reload
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
assert_equal 1, c1.position
|
87
|
+
assert_equal 2, c3.position
|
88
|
+
assert_equal 3, c2.position
|
89
89
|
|
90
|
-
|
90
|
+
c3.delete!
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
c1.reload
|
93
|
+
c2.reload
|
94
94
|
|
95
|
-
|
96
|
-
|
95
|
+
assert_equal 1, c1.position
|
96
|
+
assert_equal 2, c2.position
|
97
97
|
|
98
|
-
|
98
|
+
c2.delete!
|
99
99
|
|
100
|
-
|
100
|
+
c1.reload
|
101
101
|
|
102
|
-
|
102
|
+
assert_equal 1, c1.position
|
103
103
|
|
104
|
-
|
105
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
19
|
+
class Article
|
20
|
+
include Og::Timestamped
|
21
|
+
property :body, String
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def initialize(body = nil)
|
24
|
+
@body = body
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
def test_all
|
29
|
+
$og.manage_classes
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
a = Article.create('article')
|
32
|
+
a.save
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
a = Article[1]
|
35
|
+
assert a.create_time
|
36
|
+
end
|
37
37
|
|
38
38
|
end
|