og 0.19.0 → 0.20.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.
- data/CHANGELOG +63 -0
- data/INSTALL +4 -0
- data/README +23 -22
- data/doc/AUTHORS +3 -0
- data/doc/RELEASES +24 -1
- data/lib/og.rb +9 -8
- data/lib/og/collection.rb +4 -3
- data/lib/og/entity.rb +26 -7
- data/lib/og/manager.rb +1 -1
- data/lib/og/mixin/hierarchical.rb +9 -0
- data/lib/og/relation.rb +5 -3
- data/lib/og/relation/has_many.rb +6 -2
- data/lib/og/store.rb +3 -1
- data/lib/og/store/mysql.rb +17 -1
- data/lib/og/store/sql.rb +6 -4
- data/lib/og/store/sqlite.rb +1 -1
- data/lib/vendor/README +3 -0
- data/lib/{og/store/kirby → vendor}/kirbybase.rb +0 -0
- data/lib/vendor/mysql.rb +1117 -0
- data/lib/vendor/mysql411.rb +306 -0
- data/test/og/mixin/tc_hierarchical.rb +6 -2
- data/test/og/tc_relation.rb +6 -0
- data/test/og/tc_store.rb +21 -0
- metadata +8 -7
- data/lib/og/store/kirby/README +0 -6
- data/lib/og/store/kirby/readme.txt +0 -63
data/CHANGELOG
CHANGED
@@ -1,5 +1,68 @@
|
|
1
|
+
11-07-2005 George Moschovitis <gm@navel.gr>
|
2
|
+
|
3
|
+
* doc/RELEASES: updated.
|
4
|
+
|
5
|
+
* lib/og/store/sql.rb: escape all condition interpolations [miika].
|
6
|
+
|
7
|
+
* vendor/kirbybase.rb: copied here, cleaned up store dir.
|
8
|
+
|
9
|
+
* lib/og/store/mysql.rb: check if reconnect exists,
|
10
|
+
verified that the fallback adapter works.
|
11
|
+
|
12
|
+
11-07-2005 Aleksi Niemela <Aleksi.Niemela@cs.helsinki.fi>
|
13
|
+
|
14
|
+
* lib/og/mixin/hierarchical.rb (#parent): added.
|
15
|
+
|
16
|
+
07-07-2005 George Moschovitis <gm@navel.gr>
|
17
|
+
|
18
|
+
* lib/vendor/mysql.rb: added as a fallback [james_b].
|
19
|
+
|
20
|
+
05-07-2005 George Moschovitis <gm@navel.gr>
|
21
|
+
|
22
|
+
* lib/og/entity.rb (##find): fixed NASTY bug!
|
23
|
+
|
24
|
+
* lib/og/store.rb: introduced :uniq keyword.
|
25
|
+
|
26
|
+
03-07-2005 George Moschovitis <gm@navel.gr>
|
27
|
+
|
28
|
+
* lib/og/store/sql.rb (#find_one): should not limit by default.
|
29
|
+
|
30
|
+
* added more comments to various classes.
|
31
|
+
|
32
|
+
01-07-2005 George Moschovitis <gm@navel.gr>
|
33
|
+
|
34
|
+
* lib/og/store/sql.rb (#join_table): fix for self join case [petr].
|
35
|
+
|
36
|
+
30-06-2005 George Moschovitis <gm@navel.gr>
|
37
|
+
|
38
|
+
* lib/og/relations/has_many.rb (#resolve_polymorphic): made
|
39
|
+
more fault tolerant.
|
40
|
+
|
41
|
+
24-06-2005 George Moschovitis <gm@navel.gr>
|
42
|
+
|
43
|
+
* lib/og.rb: added various settings.
|
44
|
+
|
45
|
+
* doc/AUTHORS: updated.
|
46
|
+
|
47
|
+
21-06-2005 Aleksi Niemela <Aleksi.Niemela@cs.helsinki.fi>
|
48
|
+
|
49
|
+
* lib/og/relation.rb (#resolve_target): fixed infinite loop
|
50
|
+
bug.
|
51
|
+
|
52
|
+
20-06-2005 George Moschovitis <gm@navel.gr>
|
53
|
+
|
54
|
+
* README: facet/redcloth pointers [bcandler]
|
55
|
+
|
56
|
+
* INSTALL: facet/redcloth pointers [bcandler]
|
57
|
+
|
58
|
+
18-06-2005 George Moschovitis <gm@navel.gr>
|
59
|
+
|
60
|
+
* lib/og/store/sql.rb (#find_by_sql): alias for select.
|
61
|
+
|
1
62
|
17-06-2005 George Moschovitis <gm@navel.gr>
|
2
63
|
|
64
|
+
* --- VERSION 0.19.0 ---
|
65
|
+
|
3
66
|
* examples/run.rb: fixes to make it run again.
|
4
67
|
|
5
68
|
* README: updated.
|
data/INSTALL
CHANGED
@@ -45,6 +45,10 @@ a standard installation script is provided.
|
|
45
45
|
This installation script also installs some vendor libraries
|
46
46
|
that you possibly have allready installed. Use with caution.
|
47
47
|
|
48
|
+
You also have to manualy install the following libraries:
|
49
|
+
|
50
|
+
* Facets
|
51
|
+
* RedCloth
|
48
52
|
|
49
53
|
= Manual installation.
|
50
54
|
|
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Og 0.
|
1
|
+
= Og 0.19.0 README
|
2
2
|
|
3
3
|
Og (ObjectGraph) is a powerfull object-relational mapping library. Og provides
|
4
4
|
transparent serialization of object graphs to a RDBMS
|
@@ -18,30 +18,31 @@ PostgreSQL, MySQL and SQLite are included.
|
|
18
18
|
|
19
19
|
Og is part of the Nitro project, released as a stand-alone library
|
20
20
|
due to popular demand. You can find the ChangeLog in the Nitro
|
21
|
-
distribution (http://
|
21
|
+
distribution (http://www.nitrohq.com).
|
22
22
|
|
23
23
|
|
24
24
|
== Features
|
25
25
|
|
26
26
|
The library provides the following features:
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
* Object-Relational mapping.
|
29
|
+
* Absolutely no configuration files.
|
30
|
+
* Multiple stores (PostgreSQL, MySQL, SQLite, Oraclei, SqlServer, ..).
|
31
|
+
* Supports non SQL stores.
|
32
|
+
* ActiveRecord-style meta language and db aware methods.
|
33
|
+
* Deserialize to Ruby Objects.
|
34
|
+
* Deserialize sql join queries to Ruby Objects.
|
35
|
+
* Eager associations.
|
36
|
+
* Serialize arbitrary ruby object graphs through YAML.
|
37
|
+
* Connection pooling.
|
38
|
+
* Thread safety (temporarily dissabled).
|
39
|
+
* SQL transactions.
|
40
|
+
* Aspect oriented constructs allow interception of lifecycle callbacks.
|
41
|
+
* Transparent support for cascading deletes for all backends.
|
42
|
+
* Hierarchical structures (nested sets)
|
43
|
+
* Works safely as part of distributed application.
|
44
|
+
* Optimistic locking.
|
45
|
+
* Simple implementation.
|
45
46
|
|
46
47
|
|
47
48
|
== What's new
|
@@ -56,13 +57,13 @@ doc/RELEASES
|
|
56
57
|
|
57
58
|
The latest version of Og can be found at
|
58
59
|
|
59
|
-
* http://
|
60
|
+
* http://www.nitrohq.com
|
60
61
|
|
61
62
|
== Documentation
|
62
63
|
|
63
64
|
Documentation for Og can be found at
|
64
65
|
|
65
|
-
* http://
|
66
|
+
* http://www.nitrohq.com
|
66
67
|
|
67
68
|
Don't forget to read the file doc/RELEASES for usefull
|
68
69
|
documentation bits. Also, have a look at the test cases in
|
@@ -151,7 +152,7 @@ http://rubyforge.org/mailman/listinfo/nitro-general
|
|
151
152
|
Copyright (c) 2004-2005, George 'tml' Moschovitis.
|
152
153
|
Copyright (c) 2004-2005, Navel Ltd (http://www.navel.gr)
|
153
154
|
|
154
|
-
Og (http://www.
|
155
|
+
Og (http://www.nitrohq.com) is copyrighted free
|
155
156
|
software created and maintained by George Moschovitis (mailto:gm@navel.gr)
|
156
157
|
and released under the standard BSD Licence. For details consult
|
157
158
|
the file LICENCE.
|
data/doc/AUTHORS
CHANGED
@@ -15,6 +15,9 @@ IDEAS, ADDITIONAL CODING, SUPPORT:
|
|
15
15
|
* Matt Bowen <matt.bowen@farweststeel.com>
|
16
16
|
Oracle dirver, documentation.
|
17
17
|
|
18
|
+
* Aleksi Niemela <Aleksi.Niemela@cs.helsinki.fi>
|
19
|
+
Bug reports and patches.
|
20
|
+
|
18
21
|
* Julien Perrot <jperrot@exosec.fr>
|
19
22
|
Bug reports and patches.
|
20
23
|
|
data/doc/RELEASES
CHANGED
@@ -1,4 +1,27 @@
|
|
1
|
-
== Version 0.
|
1
|
+
== Version 0.20.0
|
2
|
+
|
3
|
+
A bug fix release.
|
4
|
+
|
5
|
+
Some notable changes:
|
6
|
+
|
7
|
+
* Added better sql injection protection in Og sql stores.
|
8
|
+
|
9
|
+
* Fixed Mysql store reconnect bug.
|
10
|
+
|
11
|
+
* Og falls back to pure ruby adapters for Mysql and Postgres, to
|
12
|
+
make it easier to run out of the box. Please, don't forget to
|
13
|
+
switch to the natively compiled adapters for production sites.
|
14
|
+
|
15
|
+
* :uniq keyword
|
16
|
+
|
17
|
+
* fix for self join.
|
18
|
+
|
19
|
+
* Many, many, many bug fixes and small improvements. This release
|
20
|
+
fixes all reported bugs in the spirit of out zero-bug tolerance
|
21
|
+
philosophy.
|
22
|
+
|
23
|
+
|
24
|
+
== Version 0.19.0 was released on 31/05/2005.
|
2
25
|
|
3
26
|
Og reloaded part 2: Another superb release introducing a balanced
|
4
27
|
mix of innovative new features, common but useful stuff and bug
|
data/lib/og.rb
CHANGED
@@ -17,6 +17,7 @@ require 'glue/time'
|
|
17
17
|
require 'glue/pool'
|
18
18
|
require 'glue/validation'
|
19
19
|
require 'glue/aspects'
|
20
|
+
require 'glue/configuration'
|
20
21
|
|
21
22
|
# Og (ObjectGraph) manages Ruby objects and their relations and
|
22
23
|
# provides transparent and efficient object-relational mapping
|
@@ -73,7 +74,7 @@ module Og
|
|
73
74
|
|
74
75
|
# The version.
|
75
76
|
|
76
|
-
Version = '0.
|
77
|
+
Version = '0.20.0'
|
77
78
|
|
78
79
|
# Library path.
|
79
80
|
|
@@ -84,13 +85,13 @@ module Og
|
|
84
85
|
# the object might be removed from his previous parent.
|
85
86
|
# In this case Og emmits a warning.
|
86
87
|
|
87
|
-
|
88
|
+
setting :check_implicit_graph_changes, :default => false, :doc => 'If true, check for implicit changes in the object graph'
|
88
89
|
|
89
90
|
# If true, only allow reading from the database. Usefull
|
90
91
|
# for maintainance.
|
91
92
|
# WARNING: not implemented yet.
|
92
93
|
|
93
|
-
|
94
|
+
setting :read_only_mode, :default => false, :doc => 'If true, only allow reading from the database'
|
94
95
|
|
95
96
|
# Prepend the following prefix to all generated SQL table names.
|
96
97
|
# Usefull on hosting scenarios where you have to run multiple
|
@@ -105,7 +106,7 @@ module Og
|
|
105
106
|
# TODO: move this to the sql store.
|
106
107
|
#++
|
107
108
|
|
108
|
-
|
109
|
+
setting :table_prefix, :default => 'og', :doc => 'Prepend the prefix to all generated SQL table names'
|
109
110
|
|
110
111
|
# If true, Og tries to create/update the schema in the
|
111
112
|
# data store. For production/live environments set this to
|
@@ -113,18 +114,18 @@ module Og
|
|
113
114
|
# upadated. For debug/development environments this should
|
114
115
|
# stay true for convienience.
|
115
116
|
|
116
|
-
|
117
|
+
setting :create_schema, :default => true, :doc => 'If true, Og tries to create/update the schema in the data store'
|
117
118
|
|
118
119
|
# If true raises exceptions on store errors, usefull when
|
119
120
|
# debugging. For production environments it should probably be
|
120
121
|
# set to false to make the application more fault tolerant.
|
121
122
|
|
122
|
-
|
123
|
+
setting :raise_store_exceptions, :default => true, :doc => 'If true raises exceptions on store errors'
|
123
124
|
|
124
125
|
# Enable/dissable thread safe mode.
|
125
126
|
|
126
|
-
|
127
|
-
|
127
|
+
setting :thread_safe, :default => true, :doc => 'Enable/dissable thread safe mode'
|
128
|
+
|
128
129
|
# Marker module. If included in a class, the Og automanager
|
129
130
|
# ignores this class.
|
130
131
|
|
data/lib/og/collection.rb
CHANGED
@@ -11,7 +11,7 @@ class Collection
|
|
11
11
|
attr_accessor :owner
|
12
12
|
|
13
13
|
# The members of this collection. Keeps the objects
|
14
|
-
#
|
14
|
+
# that belong to this collection.
|
15
15
|
|
16
16
|
attr_accessor :members
|
17
17
|
|
@@ -66,8 +66,9 @@ class Collection
|
|
66
66
|
# Reload the collection.
|
67
67
|
|
68
68
|
def reload(options)
|
69
|
-
|
70
|
-
@
|
69
|
+
# gmosx, NOOO: this was a bug! it corrupts the default options.
|
70
|
+
# @find_options = options
|
71
|
+
@members = @owner.send(@find_proc, options)
|
71
72
|
end
|
72
73
|
|
73
74
|
# Convert the collection to an array.
|
data/lib/og/entity.rb
CHANGED
@@ -31,11 +31,15 @@ module EntityMixin
|
|
31
31
|
self.class.ogmanager.store.update_properties(self, set)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Reload this entity instance from the store.
|
35
|
+
|
34
36
|
def reload
|
35
37
|
self.class.ogmanager.store.reload(self, self.pk)
|
36
38
|
end
|
37
39
|
alias_method :reload!, :reload
|
38
40
|
|
41
|
+
# Delete this entity instance from the store.
|
42
|
+
|
39
43
|
def delete
|
40
44
|
self.class.ogmanager.store.delete(self)
|
41
45
|
end
|
@@ -56,7 +60,10 @@ module EntityMixin
|
|
56
60
|
ogmanager.store.save(obj)
|
57
61
|
return obj
|
58
62
|
end
|
59
|
-
|
63
|
+
|
64
|
+
# Load an instance of this Entity class using the primary
|
65
|
+
# key.
|
66
|
+
|
60
67
|
def load(pk)
|
61
68
|
ogmanager.store.load(pk, self)
|
62
69
|
end
|
@@ -71,8 +78,11 @@ module EntityMixin
|
|
71
78
|
alias_method :batch_update, :update_properties
|
72
79
|
|
73
80
|
def find(options = {})
|
81
|
+
# gmosx, FIXME: this code seems too complex,
|
82
|
+
# improve this!
|
83
|
+
|
74
84
|
if find_options = self.__meta[:find_options]
|
75
|
-
options = find_options.first.update(options)
|
85
|
+
options = find_options.first.dup.update(options)
|
76
86
|
end
|
77
87
|
options[:class] = self
|
78
88
|
if self.metadata.superclass
|
@@ -102,6 +112,9 @@ module EntityMixin
|
|
102
112
|
ogmanager.store.count(options)
|
103
113
|
end
|
104
114
|
|
115
|
+
# Delete an instance of this Entity class using the actual
|
116
|
+
# instance or the primary key.
|
117
|
+
|
105
118
|
def delete(obj_or_pk)
|
106
119
|
ogmanager.store.delete(obj_or_pk, self)
|
107
120
|
end
|
@@ -118,10 +131,6 @@ module EntityMixin
|
|
118
131
|
@__meta[:primary_key].flatten
|
119
132
|
end
|
120
133
|
|
121
|
-
def const_missing(sym)
|
122
|
-
return sym
|
123
|
-
end
|
124
|
-
|
125
134
|
# Set the default find options for this entity.
|
126
135
|
|
127
136
|
def find_options(options)
|
@@ -133,7 +142,10 @@ module EntityMixin
|
|
133
142
|
def order(order_str)
|
134
143
|
meta :find_options, :order => order_str
|
135
144
|
end
|
136
|
-
|
145
|
+
|
146
|
+
# Enable schema inheritance for this Entity class.
|
147
|
+
# The Single Table Inheritance pattern is used.
|
148
|
+
|
137
149
|
def schema_inheritance
|
138
150
|
meta :schema_inheritance
|
139
151
|
end
|
@@ -143,6 +155,13 @@ module EntityMixin
|
|
143
155
|
def polymorphic_parent?
|
144
156
|
self.to_s == self.metadata.polymorphic.to_s
|
145
157
|
end
|
158
|
+
|
159
|
+
# :nodoc:
|
160
|
+
# Used internally to fix the forward reference problem.
|
161
|
+
|
162
|
+
def const_missing(sym)
|
163
|
+
return sym
|
164
|
+
end
|
146
165
|
end
|
147
166
|
end
|
148
167
|
|
data/lib/og/manager.rb
CHANGED
@@ -59,6 +59,14 @@ module NestedSets
|
|
59
59
|
def child?
|
60
60
|
(@#{parent} && @#{parent} != 0) && (@#{left} > 1) && (@#{right} > @#{left})
|
61
61
|
end
|
62
|
+
|
63
|
+
def parent
|
64
|
+
if root?
|
65
|
+
nil
|
66
|
+
else
|
67
|
+
#{base}[@#{parent}]
|
68
|
+
end
|
69
|
+
end
|
62
70
|
|
63
71
|
def #{children}_count
|
64
72
|
return (@#{right} - @#{left} - 1)/2
|
@@ -137,3 +145,4 @@ end
|
|
137
145
|
end
|
138
146
|
|
139
147
|
# * George Moschovitis <gm@navel.gr>
|
148
|
+
# * Aleksi Niemela <Aleksi.Niemela@cs.helsinki.fi>
|
data/lib/og/relation.rb
CHANGED
@@ -100,7 +100,7 @@ class Relation
|
|
100
100
|
#--
|
101
101
|
# FIXME: do something more elegant here.
|
102
102
|
#++
|
103
|
-
|
103
|
+
|
104
104
|
def resolve_target
|
105
105
|
if target_class.is_a?(Symbol)
|
106
106
|
c = owner_class.name.dup
|
@@ -110,8 +110,10 @@ class Relation
|
|
110
110
|
begin
|
111
111
|
klass = constant(c)
|
112
112
|
rescue
|
113
|
-
c
|
114
|
-
|
113
|
+
unless c == target_class
|
114
|
+
c = target_class
|
115
|
+
retry
|
116
|
+
end
|
115
117
|
end
|
116
118
|
@options[:target_class] = klass
|
117
119
|
end
|
data/lib/og/relation/has_many.rb
CHANGED
@@ -31,8 +31,10 @@ class HasMany < Relation
|
|
31
31
|
end
|
32
32
|
=end
|
33
33
|
def resolve_polymorphic
|
34
|
-
|
35
|
-
target_class.
|
34
|
+
if target_class.relations
|
35
|
+
unless target_class.relations.find { |r| r.is_a?(BelongsTo) and r.target_class == owner_class }
|
36
|
+
target_class.belongs_to(owner_class)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -82,3 +84,5 @@ class HasMany < Relation
|
|
82
84
|
end
|
83
85
|
|
84
86
|
end
|
87
|
+
|
88
|
+
__END__
|
data/lib/og/store.rb
CHANGED
@@ -81,7 +81,9 @@ class Store
|
|
81
81
|
code = ''
|
82
82
|
|
83
83
|
for p in klass.properties
|
84
|
-
|
84
|
+
# gmosx: :uniq does NOT set a unique constrain in the
|
85
|
+
# database.
|
86
|
+
finder = p.meta[:uniq] || p.meta[:unique] ? 'find_one' : 'find'
|
85
87
|
|
86
88
|
code << %{
|
87
89
|
def self.find_by_#{p.symbol}(val, operator = '=', options = {})
|