lore 0.4.3 → 0.4.5

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.
@@ -88,7 +88,8 @@ module Table_Instance
88
88
  def marshal_dump
89
89
  {
90
90
  :klass => self.class.to_s,
91
- :values => get_attribute_values
91
+ :values => get_attribute_values,
92
+ :joined => @joined_models
92
93
  }
93
94
  end
94
95
 
@@ -112,7 +113,8 @@ module Table_Instance
112
113
  # Creates an instance of self from marshalled value set.
113
114
  def marshal_load(dump)
114
115
  klass = eval(dump[:klass])
115
- return initialize(dump[:values], :cached)
116
+ dump[:joined].map { |m| m = eval(m) }
117
+ return initialize(dump[:values], dump[:fields], dump[:joined], :cached)
116
118
  end
117
119
 
118
120
  # Whether this instance has been loaded from
@@ -163,7 +163,7 @@ protected
163
163
 
164
164
  clause_string = ''
165
165
  if block_given? then
166
- yield_obj = Lore::Clause_Parser.new(accessor.table_name, *(accessor.get_attributes))
166
+ yield_obj = Lore::Clause_Parser.new(accessor)
167
167
  clause = yield *yield_obj
168
168
  end
169
169
  # Extend AS part by attributes that have been added in clause
@@ -190,7 +190,7 @@ protected
190
190
  # but generating a Plan instead the query.
191
191
  # Pass block& to Plan_Clause, too, only in case a plan is needed.
192
192
 
193
- return query_string
193
+ return { :query => query_string, :joined_models => clause.parts[:joined] }
194
194
 
195
195
  end
196
196
 
@@ -210,7 +210,7 @@ protected
210
210
  accessor,
211
211
  &block)
212
212
 
213
- return perform_select(accessor, query_string)
213
+ return perform_select(accessor, query_string[:query])
214
214
 
215
215
  end # def
216
216
 
@@ -230,9 +230,9 @@ protected
230
230
  result = nil if result == ''
231
231
  @@logger.debug { "cache contents for #{accessor.table_name} found: #{result.to_s != ''}" }
232
232
  else
233
- db_result = perform_select(accessor, query_string)
234
- db_result.get_rows[:values].each { |row|
235
- result.push(accessor.new(row))
233
+ db_result = perform_select(accessor, query_string[:query]).get_rows()
234
+ db_result[:values].each { |row|
235
+ result.push(accessor.new(row, db_result[:fields], query_string[:joined_models]))
236
236
  }
237
237
  if Lore.cache_enabled? && accessor.entity_cache then
238
238
  accessor.entity_cache.create(accessor, query_string, result)
@@ -241,6 +241,7 @@ protected
241
241
  return result
242
242
  end # def
243
243
 
244
+ # DELETE ME
244
245
  def self.select_on_keys(accessor,
245
246
  value_keys)
246
247
 
@@ -255,7 +256,7 @@ protected
255
256
  args_string = ''
256
257
  args.map { |a| a = Lore::TYPE_NAMES[a] }
257
258
  if args.to_s != '' && args.length > 0 then args_string = "(#{args.join(',')})" end
258
- query_string = "PREPARE #{accessor.table_name.gsub('.','_')}__#{plan_name.to_s}#{args_string} AS " << select_query(nil, accessor, &block)
259
+ query_string = "PREPARE #{accessor.table_name.gsub('.','_')}__#{plan_name.to_s}#{args_string} AS " << select_query(nil, accessor, &block)[:query]
259
260
  begin
260
261
  result = Lore::Connection.perform(query_string)
261
262
  rescue ::Exception => excep
@@ -273,9 +274,9 @@ protected
273
274
  result = nil if result == ''
274
275
  @@logger.debug { "cache contents for prepared #{accessor.table_name}: #{result.to_s.inspect}" }
275
276
  else
276
- db_result = perform_select(accessor, query_string)
277
- db_result.get_rows[:values].each { |row|
278
- result.push(accessor.new(row))
277
+ db_result = perform_select(accessor, query_string).get_rows()
278
+ db_result[:values].each { |row|
279
+ result.push(accessor.new(row, db_result[:fields]))
279
280
  }
280
281
  if Lore.cache_enabled? && accessor.entity_cache then
281
282
  accessor.create_entity_cache(query_string, result)
@@ -305,7 +306,7 @@ private
305
306
  raise pge
306
307
  ensure
307
308
  Context.leave unless accessor.get_context.nil?
308
- GC.start
309
+ # GC.start
309
310
  end
310
311
  end
311
312
 
data/lib/lore.rb CHANGED
@@ -3,7 +3,7 @@ require('logger')
3
3
 
4
4
  module Lore
5
5
 
6
- VERSION='0.4.3'
6
+ VERSION='0.4.5'
7
7
 
8
8
  @logfile = '/var/log/lore/query.log'
9
9
  def self.logfile
data/lore.gemspec CHANGED
@@ -12,9 +12,11 @@ spec = Gem::Specification.new { |s|
12
12
  (multiple) inheritance, a comfortable query syntax,
13
13
  highly customizable automated form generation,
14
14
  and result caching using memory mapping (MMap).
15
+ It aims at performance, usability and - unlike most ORMs -
16
+ high coverage of native SQL functions and features.
15
17
  Lore is currently using PostgreSQL as database backend.
16
18
  EOF
17
- s.version = '0.4.3'
19
+ s.version = '0.4.5'
18
20
  s.author = 'Tobias Fuchs'
19
21
  s.email = 'fuchs@atomnode.net'
20
22
  s.date = Time.now
@@ -34,8 +36,8 @@ spec = Gem::Specification.new { |s|
34
36
 
35
37
  s.has_rdoc = true
36
38
  s.rdoc_options << '--title' << 'Lore ORM' <<
37
- '--main' << 'README.txt' <<
38
- '--line-numbers'
39
+ '--main' << 'Lore::Model' <<
40
+ '--line-numbers'
39
41
 
40
42
  s.homepage = 'http://lore.rubyforge.org'
41
43
 
data/test/model.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'rubygems'
3
- require('lore/test/env')
3
+ require('./test/env')
4
4
  require('lore/model')
5
5
 
6
6
  Lore::Context.enter :test
data/test/tc_aspect.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require('lore/test/model')
3
+ require('./test/model')
4
4
 
5
5
 
6
6
  module Lore
data/test/tc_cache.rb CHANGED
@@ -1,8 +1,7 @@
1
1
 
2
2
  require 'test/unit'
3
3
 
4
- require('lore/test/model')
5
- require('lore/test/ts_lore')
4
+ require('./test/model')
6
5
 
7
6
  module Lore
8
7
  module Unit
@@ -40,6 +39,9 @@ module Unit
40
39
  end
41
40
 
42
41
  def test_basic
42
+ Lore.enable_cache
43
+ Car.use_entity_cache Lore::Cache::Mmap_Entity_Cache
44
+
43
45
  passed = true
44
46
  org_name = Car.all.entity.name
45
47
  20.times {
@@ -62,6 +64,7 @@ module Unit
62
64
  cached_inst.commit
63
65
  passed = passed && (!Lore.cache_enabled? || !cached_inst.is_cached_entity?)
64
66
  }
67
+ Lore.disable_cache
65
68
  assert(passed, 'Cached value and original value differ')
66
69
  end
67
70
 
data/test/tc_clause.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require('lore/test/model')
3
+ require('./test/model')
4
4
  require('lore/clause')
5
5
 
6
6
  module Lore
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require 'lore/test/model'
3
+ require './test/model'
4
4
  require 'lore/symbol'
5
5
 
6
6
  module Lore
data/test/tc_factory.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require 'lore/test/model'
3
+ require './test/model'
4
4
  require 'lore/model_factory'
5
5
  require 'lore/gui/form_generator'
6
6
 
data/test/tc_filter.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require 'lore/test/model'
3
+ require './test/model'
4
4
 
5
5
  module Lore
6
6
  module Unit
data/test/tc_form.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'test/unit'
3
3
  require 'lore/gui/form_generator'
4
- require 'lore/test/model'
4
+ require './test/model'
5
5
 
6
6
  module Lore
7
7
  module Unit
data/test/tc_model.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require 'lore/test/model'
3
+ require './test/model'
4
4
  require 'lore/symbol'
5
5
 
6
6
  module Lore
@@ -43,8 +43,8 @@ module Unit
43
43
 
44
44
  def test_create
45
45
  v = Vehicle.create(:name => 'Async', :maxspeed => 100,
46
- :owner_id => 0, :num_seats => 2,
47
- :manuf_id => 0)
46
+ :num_seats => 2,
47
+ :manuf_id => 0)
48
48
 
49
49
  car_type = Car_Type.create(:name => 'Basic_Type')
50
50
  assert_equal(car_type.name, 'Basic_Type')
@@ -55,6 +55,60 @@ module Unit
55
55
  ct.delete
56
56
  end
57
57
 
58
+ def test_joined_attributes_order
59
+
60
+ num_loops = 25
61
+
62
+ Vehicle_Owner.delete_all
63
+ owners = []
64
+ vehicles = []
65
+ for i in 0...num_loops do
66
+ o = Owner.create(:name => "owner_#{i}")
67
+ v = Vehicle.create(:name => 'Async', :maxspeed => 10*i,
68
+ :num_seats => i,
69
+ :manuf_id => i)
70
+ j = Vehicle_Owner.create(:vehicle_id => v.id, :owner_id => o.id)
71
+ owners << o
72
+ vehicles << v
73
+ end
74
+ vo = Vehicle_Owner.find(num_loops).sort_by(:vehicle_id, :asc).entities
75
+ for i in 0...vo.length do
76
+ assert_equal(owners[i].id, vo[i].owner_id)
77
+ assert_equal(vehicles[i].id, vo[i].vehicle_id)
78
+ end
79
+
80
+ join = Vehicle_Owner.select { |vo|
81
+ vo.join(Vehicle).on(Vehicle_Owner.vehicle_id == Vehicle.id) { |v|
82
+ v.join(Owner).on(Owner.owner_id == Vehicle_Owner.owner_id) { |o|
83
+ o.where(true)
84
+ o.limit(num_loops)
85
+ o.order_by(:vehicle_id, :asc)
86
+ }
87
+ }
88
+ }
89
+ assert_equal(num_loops, join.length)
90
+
91
+ for i in 0...join.length do
92
+ fulljoin = join[i]
93
+ assert_equal(owners[i].id, fulljoin.owner_id)
94
+ assert_equal(vehicles[i].id, fulljoin.vehicle_id)
95
+ end
96
+
97
+ join_ids = Vehicle_Owner.select_values(:vehicle_id) { |vo|
98
+ vo.join(Vehicle).on(Vehicle_Owner.vehicle_id == Vehicle.id) { |v|
99
+ v.join(Owner).on(Owner.owner_id == Vehicle_Owner.owner_id) { |o|
100
+ o.where(true)
101
+ o.limit(num_loops)
102
+ o.order_by(:vehicle_id, :asc)
103
+ }
104
+ }
105
+ }
106
+ for i in 0...join_ids.length do
107
+ assert_equal(vehicles[i].id, join_ids[i])
108
+ end
109
+
110
+ end
111
+
58
112
  def test_create_with_inheritance
59
113
  car_type = Car_Type.create(:name => 'Temp')
60
114
  inst_attribs = {
data/test/tc_prepare.rb CHANGED
@@ -1,8 +1,7 @@
1
1
 
2
2
  require 'test/unit'
3
3
 
4
- require('lore/test/model')
5
- require('lore/test/ts_lore')
4
+ require('./test/model')
6
5
 
7
6
  module Lore
8
7
  module Unit
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'test/unit'
3
- require('lore/test/model')
3
+ require('./test/model')
4
4
  require('lore/clause')
5
5
 
6
6
  module Lore
@@ -253,6 +253,8 @@ module Unit
253
253
 
254
254
  assert(!c1_s.nil? && c1_s[Vehicle.name] == '318i')
255
255
 
256
+ c1.delete
257
+
256
258
  end
257
259
 
258
260
  def test_create_multi_inherit
data/test/tc_thread.rb ADDED
@@ -0,0 +1,100 @@
1
+
2
+ require 'test/unit'
3
+ require './test/model'
4
+ require 'lore/symbol'
5
+
6
+ module Lore
7
+ module Unit
8
+
9
+
10
+ class TC_Model < Test::Unit::TestCase
11
+
12
+ def setup
13
+ end
14
+
15
+ def teardown
16
+ end
17
+
18
+ def test_simple
19
+ t1 = Thread.new {
20
+ 30.times {
21
+ Car.find(10)
22
+ }
23
+ }
24
+ t2 = Thread.new {
25
+ 30.times {
26
+ Car.find(10)
27
+ }
28
+ }
29
+ t3 = Thread.new {
30
+ 30.times {
31
+ Car.find(10)
32
+ }
33
+ }
34
+ t1.join
35
+ t2.join
36
+ t3.join
37
+ end
38
+ def test_create
39
+ c1 = Car.create(
40
+ :manuf_id => 0,
41
+ :name => '318i',
42
+ :num_seats => 5,
43
+ :maxspeed => 180,
44
+ :num_doors => 5,
45
+ :owner_id => 1,
46
+ :car_type_id => 23
47
+ )
48
+ c1.delete
49
+ return
50
+ t1 = Thread.new {
51
+ 30.times {
52
+ c1 = Car.create(
53
+ :manuf_id => 0,
54
+ :name => '318i',
55
+ :num_seats => 5,
56
+ :maxspeed => 180,
57
+ :num_doors => 5,
58
+ :owner_id => 1,
59
+ :car_type_id => 23
60
+ )
61
+ c1.delete
62
+ }
63
+ }
64
+ t2 = Thread.new {
65
+ 30.times {
66
+ c1 = Car.create(
67
+ :manuf_id => 0,
68
+ :name => '318i',
69
+ :num_seats => 5,
70
+ :maxspeed => 180,
71
+ :num_doors => 5,
72
+ :owner_id => 1,
73
+ :car_type_id => 23
74
+ )
75
+ c1.delete
76
+ }
77
+ }
78
+ t3 = Thread.new {
79
+ 30.times {
80
+ c1 = Car.create(
81
+ :manuf_id => 0,
82
+ :name => '318i',
83
+ :num_seats => 5,
84
+ :maxspeed => 180,
85
+ :num_doors => 5,
86
+ :owner_id => 1,
87
+ :car_type_id => 23
88
+ )
89
+ c1.delete
90
+ }
91
+ }
92
+ t1.join
93
+ t2.join
94
+ t3.join
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+ end
data/test/test_lore.rb CHANGED
@@ -1,23 +1,24 @@
1
1
 
2
+ require 'rubygems'
2
3
  require 'test/unit/testsuite'
3
4
 
4
5
  require('lore')
5
6
  Lore.logfile = './lore_test.log'
6
7
  require('rubygems')
7
- require('lore/test/model')
8
+ require('./test/model')
8
9
  require('lore/connection')
9
10
  require('lore/cache/mmap_entity_cache')
10
11
 
11
- require('lore/test/tc_table_accessor')
12
- require('lore/test/tc_clause')
13
- require('lore/test/tc_model')
14
- require('lore/test/tc_form')
15
- require('lore/test/tc_cache')
16
- require('lore/test/tc_factory')
17
- require('lore/test/tc_refined_query')
18
- require('lore/test/tc_filter')
19
- require('lore/test/tc_deep_inheritance')
20
- require('lore/test/tc_prepare')
12
+ require('./test/tc_table_accessor')
13
+ require('./test/tc_clause')
14
+ require('./test/tc_model')
15
+ require('./test/tc_form')
16
+ require('./test/tc_cache')
17
+ require('./test/tc_factory')
18
+ require('./test/tc_refined_query')
19
+ require('./test/tc_filter')
20
+ require('./test/tc_deep_inheritance')
21
+ require('./test/tc_prepare')
21
22
 
22
23
  module Lore
23
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Fuchs
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-10 00:00:00 +01:00
12
+ date: 2008-11-12 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: "0.1"
23
23
  version:
24
- description: Lore is an object-relational mapping (ORM) implementation providing many features like prepared statements, (multiple) inheritance, a comfortable query syntax, highly customizable automated form generation, and result caching using memory mapping (MMap). Lore is currently using PostgreSQL as database backend.
24
+ description: Lore is an object-relational mapping (ORM) implementation providing many features like prepared statements, (multiple) inheritance, a comfortable query syntax, highly customizable automated form generation, and result caching using memory mapping (MMap). It aims at performance, usability and - unlike most ORMs - high coverage of native SQL functions and features. Lore is currently using PostgreSQL as database backend.
25
25
  email: fuchs@atomnode.net
26
26
  executables: []
27
27
 
@@ -31,6 +31,7 @@ extra_rdoc_files: []
31
31
 
32
32
  files:
33
33
  - History.txt
34
+ - custom_models.rb
34
35
  - lib
35
36
  - Manifest.txt
36
37
  - bin
@@ -38,7 +39,6 @@ files:
38
39
  - Rakefile
39
40
  - lore.gemspec
40
41
  - LICENSE
41
- - lore-0.4.3.gem
42
42
  - lib/lore
43
43
  - lib/lore.rb
44
44
  - lib/lore/table_updater.rb
@@ -118,6 +118,7 @@ files:
118
118
  - test/tc_refined_query.rb
119
119
  - test/tc_deep_inheritance.rb
120
120
  - test/prepare.rb
121
+ - test/tc_thread.rb
121
122
  - test/tc_model.rb
122
123
  - test/README
123
124
  - test/model.rb
@@ -127,7 +128,6 @@ files:
127
128
  - test/tc_aspect.rb
128
129
  - test/tc_filter.rb
129
130
  - test/env.rb
130
- - test/lore_test.log
131
131
  - test/benchmark
132
132
  - test/tc_factory.rb
133
133
  - test/tc_prepare.rb
@@ -139,7 +139,7 @@ rdoc_options:
139
139
  - --title
140
140
  - Lore ORM
141
141
  - --main
142
- - README.txt
142
+ - Lore::Model
143
143
  - --line-numbers
144
144
  require_paths:
145
145
  - lib
data/lore-0.4.3.gem DELETED
File without changes