og 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/INSTALL CHANGED
@@ -2,27 +2,27 @@
2
2
 
3
3
  1. Download and install RubyGems:
4
4
 
5
- http://rubygems.rubyforge.org
5
+ http://rubygems.rubyforge.org
6
6
 
7
7
  2. Install the distribution:
8
8
 
9
- gem install og
9
+ gem install og
10
10
 
11
- (make sure you have the latest stable versions of Ruby and RubyGems
12
- installed)
11
+ (make sure you have the latest stable versions of Ruby and RubyGems
12
+ installed)
13
13
 
14
- When asked about the dependencies to include, only accept
15
- the dependencies for the RDBMS backends you are planning
16
- to use.
14
+ When asked about the dependencies to include, only accept
15
+ the dependencies for the RDBMS backends you are planning
16
+ to use.
17
17
 
18
18
  3. Set environment variable (required to load RubyGems):
19
19
 
20
- export RUBYOPT=-rubygems
20
+ export RUBYOPT=-rubygems
21
21
 
22
- You can add this in you .bashrc in Unix.
22
+ You can add this in you .bashrc in Unix.
23
23
 
24
- Alternatively you can run your applications with the -rubygem
25
- option:
24
+ Alternatively you can run your applications with the -rubygem
25
+ option:
26
26
 
27
27
  ruby -rubygem xxx.rb
28
28
 
@@ -34,13 +34,13 @@ a standard installation script is provided.
34
34
 
35
35
  1. Switch to an administrator account
36
36
 
37
- For example in Unix:
37
+ For example in Unix:
38
38
 
39
- $ su -
39
+ $ su -
40
40
 
41
41
  2. Run the installation script.
42
42
 
43
- $ ruby install.rb
43
+ $ ruby install.rb
44
44
 
45
45
  This installation script also installs some vendor libraries
46
46
  that you possibly have allready installed. Use with caution.
@@ -69,17 +69,17 @@ installs most of them, but here is the complete
69
69
  list for your reference:
70
70
 
71
71
  * Ruby-psql
72
- http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
73
- Ruby interface to the PostgreSQL RDBMS.
72
+ http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
73
+ Ruby interface to the PostgreSQL RDBMS.
74
74
 
75
75
  * Ruby-mysql
76
- http://tmtm.org/ja/ruby/mysql/README_en.html
77
- Ruby interface to the MySQL RDBMS.
78
-
76
+ http://tmtm.org/ja/ruby/mysql/README_en.html
77
+ Ruby interface to the MySQL RDBMS.
78
+
79
79
  * PostgreSQL
80
- http://www.postgres.org
81
- Used for the Database Backend.
82
-
80
+ http://www.postgres.org
81
+ Used for the Database Backend.
82
+
83
83
  * MySQL
84
- http://www.mysql.org
85
- Used for the Database Backend.
84
+ http://www.mysql.org
85
+ Used for the Database Backend.
data/README CHANGED
@@ -1,20 +1,23 @@
1
- = Og 0.19.0 README
2
-
3
- Og (ObjectGraph) is a powerfull object-relational mapping library. Og provides
4
- transparent serialization of object graphs to a RDBMS
5
- backend. Unlike other similar libraries Og maps standard Ruby
6
- objects to SQL tables and not vice versa. Og provides a meta language
7
- to describe the relations between objects, a flexible and intuitive api
8
- for querieng the database, raw access to the SQL language if needed
9
- (for example to fine tune the automatically generated SQL tables, or
10
- for custom queries), suports deserialization to Ruby objects or tuples,
1
+ = Og 0.21.0 README
2
+
3
+ Og (ObjectGraph) is a powerful and elegant object-relational mapping
4
+ library. Og manages the lifecycle of Ruby objects and provides
5
+ transparent serialization of object graphs to stores (typically
6
+ RDBM systems)/.
7
+
8
+ Unlike other similar solutions Og maps standard Ruby objects
9
+ to SQL tables and not vice versa. Og provides a domain specific
10
+ language to describe the relations between objects, a flexible
11
+ and intuitive api for querieng the database, raw access to the
12
+ SQL language if needed (for example to fine tune the automatically
13
+ generated SQL tables, or for custom queries), provides automatic
14
+ validation, suports deserialization to Ruby objects or tuples,
11
15
  automatically generates join tables for many_to_many relations
12
- and provides a collection of usefull Mixins to synthesize common
13
- Entities.
16
+ and provides a collection of usefull Mixins to synthesize
17
+ common Entities.
14
18
 
15
- Og is a combination of the best features of Active Record and the
16
- former O-R mapping library included in Nitro (NDB). Adapters for
17
- PostgreSQL, MySQL and SQLite are included.
19
+ Adapters for PostgreSQL, MySQL, SQLite3, Memory, Filesystem,
20
+ Oracle and SQL Server are included.
18
21
 
19
22
  Og is part of the Nitro project, released as a stand-alone library
20
23
  due to popular demand. You can find the ChangeLog in the Nitro
@@ -29,7 +32,11 @@ The library provides the following features:
29
32
  * Absolutely no configuration files.
30
33
  * Multiple stores (PostgreSQL, MySQL, SQLite, Oraclei, SqlServer, ..).
31
34
  * Supports non SQL stores.
32
- * ActiveRecord-style meta language and db aware methods.
35
+ * ActiveRecord-style domain specific language and db synchronized
36
+ collections.
37
+ * Transforms resultsets from arbitrary sql queries to Ruby objects.
38
+ * Automatically generate join tables for many to many relations.
39
+ * Can use any Ruby object to join other Ruby objects.
33
40
  * Deserialize to Ruby Objects.
34
41
  * Deserialize sql join queries to Ruby Objects.
35
42
  * Eager associations.
@@ -79,30 +86,30 @@ of new features have been added in the meantime.
79
86
  Og requires the following applications or libraries:
80
87
 
81
88
  * Ruby 1.8.1 and greater
82
- http://www.ruby-lang.org
83
- Version 1.8.2 is recomended.
89
+ http://www.ruby-lang.org
90
+ Version 1.8.2 is recomended.
84
91
 
85
92
  * Ruby-psql
86
- http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
87
- Ruby interface to the PostgreSQL RDBMS.
93
+ http://www.postgresql.jp/interfaces/ruby/archive/ruby-postgres-0.7.1.tar.gz
94
+ Ruby interface to the PostgreSQL RDBMS.
88
95
 
89
96
  * Ruby-mysql
90
- http://tmtm.org/ja/ruby/mysql/README_en.html
91
- Ruby interface to the MySQL RDBMS.
92
- Pure Ruby Mysql interface:
93
- http://www.tmtm.org/ruby/mysql/
94
-
97
+ http://tmtm.org/ja/ruby/mysql/README_en.html
98
+ Ruby interface to the MySQL RDBMS.
99
+ Pure Ruby Mysql interface:
100
+ http://www.tmtm.org/ruby/mysql/
101
+
95
102
  * PostgreSQL
96
- http://www.postgres.org
97
- Used for the Database Backend.
98
-
103
+ http://www.postgres.org
104
+ Used for the Database Backend.
105
+
99
106
  * MySQL
100
- http://www.mysql.org
101
- Used for the Database Backend.
107
+ http://www.mysql.org
108
+ Used for the Database Backend.
102
109
 
103
110
  * SQLite
104
- http://www.sqlite.org/download.html
105
- WARNING: you need sqlite3-ruby > 1.1.0
111
+ http://www.sqlite.org/download.html
112
+ WARNING: you need sqlite3-ruby > 1.1.0
106
113
 
107
114
  Please install the required applications and libraries before continuing
108
115
  with the installation of Og. Only install the libraries needed for
data/Rakefile CHANGED
@@ -23,64 +23,63 @@ VersionFile = MainFile = File.join("lib", Name + '.rb')
23
23
 
24
24
  RubyForgeProject = 'nitro'
25
25
  RubyForgeUser = 'gmosx'
26
- Homepage = "http://#{RubyForgeProject}.rubyforge.org/"
26
+ Homepage = "http://www.nitrohq.com/"
27
27
 
28
28
  task :default => :package
29
29
 
30
30
  # Run the tests.
31
31
 
32
32
  Rake::TestTask.new do |t|
33
- t.libs << 'test'
34
- t.test_files = FileList['test/**/tc*.rb']
35
- t.verbose = true
33
+ t.libs << 'test'
34
+ t.test_files = FileList['test/**/tc*.rb']
35
+ t.verbose = true
36
36
  end
37
37
 
38
38
  # Generate RDoc documentation.
39
39
 
40
40
  Rake::RDocTask.new do |rd|
41
- rd.main = 'README'
42
- rd.rdoc_dir = 'rdoc'
43
- rd.rdoc_files.include('README', 'INSTALL', 'doc/config.txt', 'doc/tutorial.txt', 'lib/**/*.rb')
44
- rd.options << '--all --inline-source'
41
+ rd.main = 'README'
42
+ rd.rdoc_dir = 'rdoc'
43
+ rd.rdoc_files.include('README', 'INSTALL', 'doc/tutorial.txt', 'lib/**/*.rb')
44
+ rd.options << '--all --inline-source'
45
45
  end
46
46
 
47
47
  # Build gem.
48
48
 
49
49
  spec = Gem::Specification.new do |s|
50
- s.name = 'og'
51
- if File.read('lib/og.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
52
- s.version = $1
53
- else
54
- raise 'No version found'
55
- end
56
- s.summary = 'Og (ObjectGraph)'
57
- s.description = 'An efficient and transparent Object-Relational mapping library'
58
-
59
- s.add_dependency 'glue', "= #{s.version}"
60
- s.add_dependency 'facets', '>= 0.7.1'
61
- #s.add_dependency 'postgres-pr', '>= 0.3.0'
62
- #s.add_dependency 'postgres', '>= 0.7.1'
63
- #s.add_dependency 'sqlite3-ruby', '>= 1.0.0'
64
- #s.add_dependency 'mysql', '>= 2.5.1'
65
-
66
- s.required_ruby_version = '>= 1.8.2'
67
-
68
- s.files = FileList[
69
- '[A-Z]*', 'install.rb', '{bin,benchmark,examples,doc,lib,test,vendor}/**/*'
70
- ].exclude('.svn/**/*').exclude('**/*.log').to_a
71
-
72
- s.require_path = 'lib'
73
- s.autorequire = 'og'
74
-
75
- s.has_rdoc = true
76
- s.extra_rdoc_files = FileList['README', 'doc/RELEASES', 'doc/LICENSE', 'doc/AUTHORS'].to_a
77
- s.rdoc_options << '--main' << 'README' << '--title' << 'Og Documentation'
78
- s.rdoc_options << '--all' << '--inline-source'
79
-
80
- s.author = 'George Moschovitis'
81
- s.email = 'gm@navel.gr'
82
- s.homepage = 'http://nitro.rubyforge.org'
83
- s.rubyforge_project = 'nitro'
50
+ s.name = 'og'
51
+ if File.read('lib/og.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
52
+ s.version = $1
53
+ else
54
+ raise 'No version found'
55
+ end
56
+ s.summary = 'Og (ObjectGraph)'
57
+ s.description = 'An efficient and transparent Object-Relational mapping library'
58
+
59
+ s.add_dependency 'glue', "= #{s.version}"
60
+ #s.add_dependency 'postgres-pr', '>= 0.3.0'
61
+ #s.add_dependency 'postgres', '>= 0.7.1'
62
+ #s.add_dependency 'sqlite3-ruby', '>= 1.0.0'
63
+ #s.add_dependency 'mysql', '>= 2.5.1'
64
+
65
+ s.required_ruby_version = '>= 1.8.2'
66
+
67
+ s.files = FileList[
68
+ '[A-Z]*', 'install.rb', '{bin,benchmark,examples,doc,lib,test,vendor}/**/*'
69
+ ].exclude('.svn/**/*').exclude('**/*.log').to_a
70
+
71
+ s.require_path = 'lib'
72
+ s.autorequire = 'og'
73
+
74
+ s.has_rdoc = true
75
+ s.extra_rdoc_files = FileList['README', 'INSTALL', 'doc/tutorial.txt'].to_a
76
+ s.rdoc_options << '--main' << 'README' << '--title' << 'Og Documentation'
77
+ s.rdoc_options << '--all' << '--inline-source'
78
+
79
+ s.author = 'George Moschovitis'
80
+ s.email = 'gm@navel.gr'
81
+ s.homepage = 'http://www.nitrohq.com'
82
+ s.rubyforge_project = 'nitro'
84
83
  end
85
84
 
86
85
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -1,28 +1,28 @@
1
1
  # * George Moschovitis <gm@navel.gr>
2
2
  # (c) 2004-2005 Navel, all rights reserved.
3
- # $Id: bench.rb 34 2005-04-26 09:07:39Z gmosx $
3
+ # $Id: bench.rb 182 2005-07-22 10:07:50Z gmosx $
4
4
 
5
5
  require 'og'; include Og
6
6
 
7
7
 
8
8
  config = {
9
- :adapter => 'sqlite',
10
- :database => 'test',
11
- :connection_count => 5
9
+ :adapter => 'sqlite',
10
+ :database => 'test',
11
+ :connection_count => 5
12
12
  }
13
13
 
14
14
  class Article
15
- prop_accessor :title, String
16
- prop_accessor :body, String
17
- prop_accessor :hits, Fixnum
18
- prop_accessor :rate, Fixnum
19
-
20
- def initialize(title = nil, body = nil)
21
- @title = title
22
- @body = body
23
- @hits = rand(5)
24
- @rate = rand(100)
25
- end
15
+ prop_accessor :title, String
16
+ prop_accessor :body, String
17
+ prop_accessor :hits, Fixnum
18
+ prop_accessor :rate, Fixnum
19
+
20
+ def initialize(title = nil, body = nil)
21
+ @title = title
22
+ @body = body
23
+ @hits = rand(5)
24
+ @rate = rand(100)
25
+ end
26
26
  end
27
27
 
28
28
  Database.drop_db!(config)
@@ -34,7 +34,7 @@ db = Database.new(config)
34
34
  articles = []
35
35
 
36
36
  500.times do |i|
37
- articles << Article.new("Title#{i}", "Body#{i}")
37
+ articles << Article.new("Title#{i}", "Body#{i}")
38
38
  end
39
39
 
40
40
  sum = 0
@@ -45,26 +45,26 @@ GC.disable
45
45
 
46
46
  10.times do |i|
47
47
 
48
- db.exec "DELETE FROM #{Article::DBTABLE}"
49
-
50
- for article in articles
51
- article.oid = nil
52
- end
53
-
54
- Article.create("Dummy", "Dummy")
55
-
56
- t1 = Time.now
57
- articles.each do |a|
58
- a.save!
59
- end
60
- t2 = Time.now
61
-
62
- d = t2 - t1
63
- sum += d
64
- min = d if d < min
65
- max = d if d > max
66
-
67
- puts "Insert test #{i}: #{d} seconds"
48
+ db.exec "DELETE FROM #{Article::DBTABLE}"
49
+
50
+ for article in articles
51
+ article.oid = nil
52
+ end
53
+
54
+ Article.create("Dummy", "Dummy")
55
+
56
+ t1 = Time.now
57
+ articles.each do |a|
58
+ a.save!
59
+ end
60
+ t2 = Time.now
61
+
62
+ d = t2 - t1
63
+ sum += d
64
+ min = d if d < min
65
+ max = d if d > max
66
+
67
+ puts "Insert test #{i}: #{d} seconds"
68
68
 
69
69
  end
70
70
 
@@ -1,28 +1,31 @@
1
1
  MAIN DEVELOPER:
2
2
 
3
3
  * George Moschovitis <gm@navel.gr>
4
- Project leader, architecture and design, main coder,
5
- documentation, maintainer.
6
-
4
+ Project leader, architecture and design, main coder,
5
+ documentation, maintainer.
6
+
7
7
  IDEAS, ADDITIONAL CODING, SUPPORT:
8
8
 
9
9
  * Michael Neumann <mneumann@ntecs.de>
10
- Design, additional coding and bug reports.
10
+ Design, additional coding and bug reports.
11
11
 
12
12
  * Anastasios Koutoumanos <ak@navel.gr>
13
- Design, additional coding.
13
+ Design, additional coding.
14
14
 
15
- * Matt Bowen <matt.bowen@farweststeel.com>
16
- Oracle dirver, documentation.
15
+ * Matt Bowen <matt.bowen@farweststeel.com>
16
+ Oracle driver, documentation.
17
17
 
18
+ * Ysabel <deb@ysabel.org>
19
+ Refactoring, patches.
20
+
18
21
  * Aleksi Niemela <Aleksi.Niemela@cs.helsinki.fi>
19
- Bug reports and patches.
22
+ Bug reports and patches.
20
23
 
21
- * Julien Perrot <jperrot@exosec.fr>
22
- Bug reports and patches.
24
+ * Julien Perrot <jperrot@exosec.fr>
25
+ Bug reports and patches.
23
26
 
24
27
  * Ghislain Mary <gmary@lunacymaze.org>
25
- Bug reports and patches (sqlite3 driver).
28
+ Bug reports and patches (sqlite3 driver).
26
29
 
27
30
  * Thomas Quas <tquas@yahoo.com>
28
- Ideas, bug reports, unit tests.
31
+ Ideas, bug reports, unit tests.
@@ -1,6 +1,6 @@
1
1
  The BSD License
2
2
 
3
- Copyright (c) 2004-2005, George 'tml' Moschovitis.
3
+ Copyright (c) 2004-2005, George 'gmosx' Moschovitis. (http://www.gmosx.com)
4
4
  Copyright (c) 2004-2005, Navel Ltd. (http://www.navel.gr)
5
5
  All rights reserved.
6
6
 
@@ -10,11 +10,11 @@ met:
10
10
 
11
11
  * Redistributions of source code must retain the above copyright
12
12
  notice, this list of conditions and the following disclaimer.
13
-
13
+
14
14
  * Redistributions in binary form must reproduce the above copyright
15
15
  notice, this list of conditions and the following disclaimer in the
16
16
  documentation and/or other materials provided with the distribution.
17
-
17
+
18
18
  * Neither the name of Navel nor the names of its contributors may be
19
19
  used to endorse or promote products derived from this software
20
20
  without specific prior written permission.