og 0.9.3 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +64 -0
- data/README.og +2 -2
- data/examples/og/mock_example.rb +1 -4
- data/examples/og/mysql_to_psql.rb +2 -4
- data/lib/glue/cache.rb +32 -34
- data/lib/glue/number.rb +3 -9
- data/lib/glue/time.rb +14 -22
- data/lib/glue/validation.rb +2 -4
- data/lib/og/backend.rb +36 -40
- data/lib/og/backends/psql.rb +7 -7
- data/lib/og/backends/sqlite.rb +383 -0
- data/lib/og/connection.rb +34 -34
- data/lib/og/meta.rb +8 -0
- data/lib/og/version.rb +1 -1
- metadata +3 -2
data/ChangeLog
CHANGED
@@ -1,6 +1,70 @@
|
|
1
1
|
|
2
|
+
04-02-2005 George Moschovitis <gm@navel.gr>
|
3
|
+
|
4
|
+
* lib/nitro/adaptors/fastcgi.rb: convert conf to Flexob.
|
5
|
+
|
6
|
+
* lib/nitro/adaptors/webrick.rb: added REQUEST_MUTEX to temp-fix windows bug.
|
7
|
+
|
8
|
+
03-02-2005 George Moschovitis <gm@navel.gr>
|
9
|
+
|
10
|
+
* lib/glue/*: cleaned up some files.
|
11
|
+
|
12
|
+
* lib/og/*: cleaned up some files.
|
13
|
+
|
14
|
+
* lib/nitro/dispatchers.rb (#initialize): accept class as input.
|
15
|
+
|
16
|
+
* Updated all examples.
|
17
|
+
|
18
|
+
* lib/nitro/context.rb: out == XhtmlString to allow convienient
|
19
|
+
access to the programmatic rendering functionality and make
|
20
|
+
the wee example cooler.
|
21
|
+
|
22
|
+
* lib/nitro/adaptors/webrick.rb (#start): better handling of conf parameters,
|
23
|
+
better handling of logging,
|
24
|
+
autoconvert conf to Flexob if needed.
|
25
|
+
|
26
|
+
* examples/wee_style/wee.rb: implemented,
|
27
|
+
looks cool (but useles? :-))
|
28
|
+
|
29
|
+
* examples/wee_style/README: introduced.
|
30
|
+
|
31
|
+
* examples/wee_style/*: introduced wee-style example.
|
32
|
+
|
33
|
+
* examples/blog/lib/blog.rb: updated for new RSS.
|
34
|
+
|
35
|
+
* test/nitro/builders/tc_rss.rb: introduced.
|
36
|
+
|
37
|
+
* lib/nitro/builders/rss.rb: pass parameters,
|
38
|
+
(#render): now alias for render_0_9
|
39
|
+
|
40
|
+
* lib/og/meta.rb (#joins): introduced new metadata macro.
|
41
|
+
|
42
|
+
02-02-2005 George Moschovitis <gm@navel.gr>
|
43
|
+
|
44
|
+
* --- VERSION 0.9.4 ---
|
45
|
+
|
46
|
+
* lib/og/backends/sqlite.rb: introduced.
|
47
|
+
|
48
|
+
* lib/og/backends/psql.rb: minor cleanup.
|
49
|
+
|
50
|
+
* examples/blog/root/style.css: fixes for IE, more needed.
|
51
|
+
|
52
|
+
* lib/nitro/adaptors/fastcgi.rb (#handle): restore Og connection.
|
53
|
+
|
54
|
+
* lib/nitro/adaptors/webrick.rb (#handle): restore Og connection, fixes
|
55
|
+
Windows deadlock. [james_b]
|
56
|
+
|
57
|
+
* examples/no_xsl_blog/lib/blog/template.rb: fixed ruby in template (login).
|
58
|
+
|
59
|
+
* changed default port to 8069, to avoid conflicts with
|
60
|
+
other servers (8080 was too common). [james_b]
|
61
|
+
|
2
62
|
01-02-2005 George Moschovitis <gm@navel.gr>
|
3
63
|
|
64
|
+
* updated Rubyforge page, added wiki.
|
65
|
+
|
66
|
+
* --- VERSION 0.9.3 ---
|
67
|
+
|
4
68
|
* small fixes to make tests pass again.
|
5
69
|
|
6
70
|
* lib/nitro/adaptors/webrick.rb: update headers with req.meta_vars.
|
data/README.og
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Og 0.9.
|
1
|
+
= Og 0.9.3
|
2
2
|
|
3
3
|
Nitro integrates the Og (ObjectGraph) object-relational mapping
|
4
4
|
library. Og provides transparent serialization of object graphs to a RDBMS
|
@@ -18,7 +18,7 @@ PostgreSQL and MySQL 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://www.
|
21
|
+
distribution (http://www.rubyforge.com/projects/nitro).
|
22
22
|
|
23
23
|
|
24
24
|
== Features
|
data/examples/og/mock_example.rb
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
# A simple example to demonstrate how to mock Og.
|
4
4
|
# Very useful in test units.
|
5
5
|
#
|
6
|
-
# code:
|
7
6
|
# * George Moschovitis <gm@navel.gr>
|
8
|
-
#
|
9
|
-
# (c) 2004 Navel, all rights reserved.
|
7
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
10
8
|
# $Id: run.rb 185 2004-12-10 13:29:09Z gmosx $
|
11
9
|
|
12
10
|
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
@@ -52,4 +50,3 @@ class SimpleTest < Test::Unit::TestCase
|
|
52
50
|
end
|
53
51
|
|
54
52
|
end
|
55
|
-
|
@@ -7,10 +7,8 @@
|
|
7
7
|
#
|
8
8
|
# Og makes it easier to switch to a REAL database :)
|
9
9
|
#
|
10
|
-
# code:
|
11
10
|
# * George Moschovitis <gm@navel.gr>
|
12
|
-
#
|
13
|
-
# (c) 2004 Navel, all rights reserved.
|
11
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
14
12
|
# $Id$
|
15
13
|
|
16
14
|
raise 'WARNING, this example does not work yet, for the moment ' +
|
@@ -22,7 +20,7 @@ require 'og'
|
|
22
20
|
|
23
21
|
# An example managed object.
|
24
22
|
# Looks like an ordinary Ruby object.
|
25
|
-
|
23
|
+
|
26
24
|
class Article
|
27
25
|
prop_accessor :name, :body, String
|
28
26
|
|
data/lib/glue/cache.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
# code:
|
2
1
|
# * George Moschovitis <gm@navel.gr>
|
3
2
|
# * Anastasios Koutoumanos <ak@navel.gr>
|
4
|
-
#
|
5
|
-
# (c) 2004 Navel, all rights reserved.
|
3
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
6
4
|
# $Id: cache.rb 202 2005-01-17 10:44:13Z gmosx $
|
7
5
|
|
8
|
-
module N
|
6
|
+
module N
|
9
7
|
|
10
|
-
# = LRUCache
|
11
|
-
#
|
12
8
|
# A cache utilizing a simple LRU (Least Recently Used) policy.
|
13
9
|
# The items managed by this cache must respond to the #key method.
|
14
10
|
# Attempts to optimize reads rather than inserts!
|
@@ -16,36 +12,38 @@ module N;
|
|
16
12
|
# LRU semantics are enforced by inserting the items in a queue.
|
17
13
|
# The lru item is always at the tail. Two special sentinels
|
18
14
|
# (head, tail) are used to simplify (?) the code.
|
19
|
-
|
15
|
+
|
20
16
|
class LRUCache < Hash
|
21
17
|
|
22
18
|
# Mix this in your class to make LRU-managable.
|
23
|
-
|
19
|
+
|
24
20
|
module Item
|
25
21
|
attr_accessor :lru_key, :lru_prev, :lru_next
|
26
22
|
end
|
27
23
|
|
28
24
|
# head-tail sentinels
|
29
|
-
|
25
|
+
|
30
26
|
class Sentinel; include Item; end
|
31
27
|
|
32
|
-
# the maximum number of items in the cache
|
28
|
+
# the maximum number of items in the cache.
|
29
|
+
|
33
30
|
attr_accessor :max_items
|
34
31
|
|
35
32
|
# the head sentinel
|
33
|
+
|
36
34
|
attr :head
|
35
|
+
|
37
36
|
# the tail sentinel, tail.prev points to the lru item.
|
37
|
+
|
38
38
|
attr :tail
|
39
39
|
|
40
|
-
#
|
41
|
-
#
|
42
40
|
def initialize(max_items)
|
43
41
|
@max_items = max_items
|
44
42
|
lru_clear()
|
45
43
|
end
|
46
44
|
|
47
|
-
# Lookup an item in the cache
|
48
|
-
|
45
|
+
# Lookup an item in the cache.
|
46
|
+
|
49
47
|
def [](key)
|
50
48
|
if item = super
|
51
49
|
return lru_touch(item)
|
@@ -53,36 +51,36 @@ class LRUCache < Hash
|
|
53
51
|
end
|
54
52
|
|
55
53
|
# The inserted item is considered mru!
|
56
|
-
|
54
|
+
|
57
55
|
def []=(key, item)
|
58
56
|
item = super
|
59
57
|
item.lru_key = key
|
60
58
|
lru_insert(item)
|
61
59
|
end
|
62
60
|
|
63
|
-
# Delete an item from the cache
|
64
|
-
|
61
|
+
# Delete an item from the cache.
|
62
|
+
|
65
63
|
def delete(key)
|
66
64
|
if item = super
|
67
65
|
lru_delete(item)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
71
|
-
# Clear the cache
|
72
|
-
|
69
|
+
# Clear the cache.
|
70
|
+
|
73
71
|
def clear
|
74
72
|
super
|
75
73
|
lru_clear()
|
76
74
|
end
|
77
75
|
|
78
|
-
# The first (mru) element in the cache
|
79
|
-
|
76
|
+
# The first (mru) element in the cache.
|
77
|
+
|
80
78
|
def first
|
81
79
|
@head.lru_next
|
82
80
|
end
|
83
81
|
|
84
|
-
# The last (lru) element in the cache
|
85
|
-
|
82
|
+
# The last (lru) element in the cache.
|
83
|
+
|
86
84
|
def last
|
87
85
|
@tail.lru_prev
|
88
86
|
end
|
@@ -91,15 +89,15 @@ class LRUCache < Hash
|
|
91
89
|
private
|
92
90
|
|
93
91
|
# Delete an item from the lru list.
|
94
|
-
|
92
|
+
|
95
93
|
def lru_delete(item)
|
96
94
|
lru_join(item.lru_prev, item.lru_next)
|
97
95
|
return item
|
98
96
|
end
|
99
97
|
|
100
|
-
# Join two items in the lru list
|
101
|
-
# Return y to allow for chaining
|
102
|
-
|
98
|
+
# Join two items in the lru list.
|
99
|
+
# Return y to allow for chaining.
|
100
|
+
|
103
101
|
def lru_join(x, y)
|
104
102
|
x.lru_next = y
|
105
103
|
y.lru_prev = x
|
@@ -108,28 +106,28 @@ class LRUCache < Hash
|
|
108
106
|
|
109
107
|
# Append a child item to a parent item in the lru list
|
110
108
|
# (Re)inserts the child in the list.
|
111
|
-
|
109
|
+
|
112
110
|
def lru_append(parent, child)
|
113
111
|
lru_join(child, parent.lru_next)
|
114
112
|
lru_join(parent, child)
|
115
113
|
end
|
116
114
|
|
117
115
|
# Insert an item
|
118
|
-
|
116
|
+
|
119
117
|
def lru_insert(item)
|
120
118
|
delete(last.lru_key) if size() > @max_items
|
121
119
|
lru_append(@head, item)
|
122
120
|
end
|
123
121
|
|
124
122
|
# Touch an item, make mru!
|
125
|
-
# Returns the item
|
126
|
-
|
123
|
+
# Returns the item.
|
124
|
+
|
127
125
|
def lru_touch(item)
|
128
126
|
lru_append(@head, lru_delete(item))
|
129
127
|
end
|
130
128
|
|
131
|
-
# Clear the lru
|
132
|
-
|
129
|
+
# Clear the lru.
|
130
|
+
|
133
131
|
def lru_clear
|
134
132
|
@head = Sentinel.new
|
135
133
|
@tail = Sentinel.new
|
@@ -137,4 +135,4 @@ class LRUCache < Hash
|
|
137
135
|
end
|
138
136
|
end
|
139
137
|
|
140
|
-
end
|
138
|
+
end
|
data/lib/glue/number.rb
CHANGED
@@ -1,20 +1,14 @@
|
|
1
|
-
# code:
|
2
1
|
# * George Moschovitis <gm@navel.gr>
|
3
|
-
#
|
4
|
-
# (c) 2004 Navel, all rights reserved.
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
5
3
|
# $Id: number.rb 202 2005-01-17 10:44:13Z gmosx $
|
6
4
|
|
7
5
|
module N;
|
8
6
|
|
9
|
-
# = NumberUtils
|
10
|
-
#
|
11
|
-
# === Design:
|
12
|
-
#
|
13
7
|
# Implement as a module to avoid class polution. You can
|
14
8
|
# still use Ruby's advanced features to include the module in your
|
15
9
|
# class. Passing the object to act upon allows to check for nil,
|
16
10
|
# which isn't possible if you use self.
|
17
|
-
|
11
|
+
|
18
12
|
module NumberUtils
|
19
13
|
|
20
14
|
# Returns the multiple ceil of a number
|
@@ -27,4 +21,4 @@ module NumberUtils
|
|
27
21
|
|
28
22
|
end
|
29
23
|
|
30
|
-
end
|
24
|
+
end
|
data/lib/glue/time.rb
CHANGED
@@ -1,29 +1,23 @@
|
|
1
|
-
# code:
|
2
1
|
# * George Moschovitis <gm@navel.gr>
|
3
|
-
#
|
4
|
-
# (c) 2004 Navel, all rights reserved.
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
5
3
|
# $Id: time.rb 202 2005-01-17 10:44:13Z gmosx $
|
6
4
|
|
7
5
|
require "time.rb"
|
8
6
|
|
9
7
|
module N;
|
10
8
|
|
11
|
-
# = Time
|
12
|
-
#
|
13
9
|
# General time utilities collection
|
14
10
|
#
|
15
|
-
# === Design:
|
16
|
-
#
|
17
11
|
# Implement as a module to avoid class polution. You can
|
18
12
|
# still Ruby's advanced features to include the module in your
|
19
13
|
# class. Passing the object to act upon allows to check for nil,
|
20
14
|
# which isn't possible if you use self.
|
21
15
|
#
|
22
|
-
#
|
16
|
+
# == TODO
|
23
17
|
#
|
24
18
|
# - SOS: add test units.
|
25
19
|
# - add aliases for those methods in Kernel ?
|
26
|
-
|
20
|
+
|
27
21
|
module TimeUtils
|
28
22
|
|
29
23
|
NOW = Time.now
|
@@ -31,13 +25,13 @@ module TimeUtils
|
|
31
25
|
ZERO = Time.mktime(1972)
|
32
26
|
|
33
27
|
# Convert the time to a nice String representation.
|
34
|
-
|
28
|
+
|
35
29
|
def self.date_time(time)
|
36
30
|
return nil unless time
|
37
31
|
return time.strftime("%d-%m-%Y %H:%M")
|
38
32
|
end
|
39
33
|
|
40
|
-
#
|
34
|
+
# This method calculates the days extrema given two time objects.
|
41
35
|
# start time is the given time1 at 00:00:00
|
42
36
|
# end time is the given time2 at 23:59:59:999
|
43
37
|
#
|
@@ -48,7 +42,7 @@ module TimeUtils
|
|
48
42
|
# Output
|
49
43
|
# - the time range. you can get the start/end times using
|
50
44
|
# range methods.
|
51
|
-
|
45
|
+
|
52
46
|
def self.days_extrema(time1, time2=nil)
|
53
47
|
time2 = time1 if (not time2.valid? Time)
|
54
48
|
time2 = NEVER if (time2 <= time1)
|
@@ -57,24 +51,23 @@ module TimeUtils
|
|
57
51
|
return (start_time..end_time)
|
58
52
|
end
|
59
53
|
|
60
|
-
#
|
61
|
-
|
62
|
-
#
|
54
|
+
# Set time to start of day
|
55
|
+
|
63
56
|
def self.start_of_day(time)
|
64
57
|
return Time.mktime(time.year, time.month, time.day, 0, 0, 0, 0)
|
65
58
|
end
|
66
59
|
|
67
|
-
|
68
|
-
#
|
69
|
-
|
60
|
+
|
61
|
+
# Set time to end of day
|
62
|
+
|
70
63
|
def self.end_of_day(time)
|
71
64
|
return Time.mktime(time.year, time.month, time.day, 23, 59, 59, 999)
|
72
65
|
end
|
73
66
|
|
74
67
|
|
75
|
-
#
|
68
|
+
# Returns true only if day of time is included in the
|
76
69
|
# range (stime..etime). Only year days are checked.
|
77
|
-
|
70
|
+
|
78
71
|
def self.time_in_day_range(time, stime=ZERO, etime=NEVER)
|
79
72
|
if (etime <= stime)
|
80
73
|
Logger.debug "Invalid end time (#{etime} < #{stime})" if $DBG
|
@@ -89,5 +82,4 @@ module TimeUtils
|
|
89
82
|
|
90
83
|
end
|
91
84
|
|
92
|
-
end
|
93
|
-
|
85
|
+
end
|
data/lib/glue/validation.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
# George Moschovitis <gm@navel.gr>
|
2
|
-
# (c) 2005 Navel, all rights reserved.
|
1
|
+
# * George Moschovitis <gm@navel.gr>
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
3
3
|
# $Id$
|
4
4
|
|
5
5
|
module N
|
6
6
|
|
7
|
-
# = Validation
|
8
|
-
#
|
9
7
|
# Implements a meta-language for validating managed
|
10
8
|
# objects. Typically used in Validator objects but can be
|
11
9
|
# included in managed objects too.
|
data/lib/og/backend.rb
CHANGED
@@ -1,73 +1,69 @@
|
|
1
|
-
# code:
|
2
1
|
# * George Moschovitis <gm@navel.gr>
|
3
|
-
#
|
4
|
-
# (c) 2004 Navel, all rights reserved.
|
2
|
+
# (c) 2004-2005 Navel, all rights reserved.
|
5
3
|
# $Id: backend.rb 202 2005-01-17 10:44:13Z gmosx $
|
6
4
|
|
7
|
-
require
|
5
|
+
require 'yaml'
|
8
6
|
|
9
|
-
require
|
7
|
+
require 'og/connection'
|
10
8
|
|
11
9
|
class Og
|
12
10
|
|
13
|
-
# = Backend
|
14
|
-
#
|
15
11
|
# Abstract backend. A backend communicates with the RDBMS.
|
16
12
|
# This is the base class for the various backend implementations.
|
17
|
-
|
13
|
+
|
18
14
|
class Backend
|
19
15
|
|
20
16
|
# The actual connection to the database
|
21
17
|
attr_accessor :conn
|
22
18
|
|
23
19
|
# Intitialize the connection to the RDBMS.
|
24
|
-
|
20
|
+
|
25
21
|
def initialize(config)
|
26
22
|
raise "Not implemented"
|
27
23
|
end
|
28
24
|
|
29
25
|
# Close the connection to the RDBMS.
|
30
|
-
|
26
|
+
|
31
27
|
def close()
|
32
28
|
@conn.close()
|
33
29
|
end
|
34
30
|
|
35
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
36
|
-
# Utilities
|
31
|
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
32
|
+
# :section: Utilities
|
37
33
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
38
34
|
|
39
35
|
# Encode the name of the klass as an sql safe string.
|
40
36
|
# The Module separators are replaced with _ and NOT stripped
|
41
37
|
# out so that we can convert back to the original notation if
|
42
38
|
# needed. The leading module if available is removed.
|
43
|
-
|
39
|
+
|
44
40
|
def self.encode(klass)
|
45
41
|
"#{klass.name.gsub(/^.*::/, "")}".gsub(/::/, "_").downcase
|
46
42
|
end
|
47
43
|
|
48
44
|
# The name of the SQL table where objects of this class
|
49
45
|
# are stored.
|
50
|
-
|
46
|
+
|
51
47
|
def self.table(klass)
|
52
48
|
"_#{Og.table_prefix}#{encode(klass)}"
|
53
49
|
end
|
54
50
|
|
55
51
|
# The name of the join table for the two given classes.
|
56
|
-
|
52
|
+
|
57
53
|
def self.join_table(klass1, klass2)
|
58
54
|
"_#{Og.table_prefix}j_#{encode(klass1)}_#{encode(klass2)}"
|
59
55
|
end
|
60
56
|
|
61
57
|
# Returns the props that will be included in the insert query.
|
62
58
|
# For some backends the oid should be stripped.
|
63
|
-
|
59
|
+
|
64
60
|
def self.props_for_insert(klass)
|
65
61
|
klass.__props
|
66
62
|
end
|
67
63
|
|
68
64
|
# Precompile the insert code for the given class.
|
69
65
|
# The generated code sets the oid when inserting!
|
70
|
-
|
66
|
+
|
71
67
|
def self.eval_og_insert(klass)
|
72
68
|
props = props_for_insert(klass)
|
73
69
|
|
@@ -104,7 +100,7 @@ class Backend
|
|
104
100
|
|
105
101
|
# Precompile the update code for the given class.
|
106
102
|
# Ignore the oid when updating!
|
107
|
-
|
103
|
+
|
108
104
|
def self.eval_og_update(klass)
|
109
105
|
props = klass.__props.reject { |p| :oid == p.symbol }
|
110
106
|
|
@@ -146,7 +142,7 @@ class Backend
|
|
146
142
|
# Precompile the code to read objects of the given class
|
147
143
|
# from the backend. In order to allow for changing
|
148
144
|
# field/attribute orders we have to use a field mapping hash.
|
149
|
-
|
145
|
+
|
150
146
|
def self.eval_og_deserialize(klass, og)
|
151
147
|
calc_field_index(klass, og)
|
152
148
|
|
@@ -169,67 +165,67 @@ class Backend
|
|
169
165
|
end
|
170
166
|
|
171
167
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
172
|
-
# Connection methods.
|
168
|
+
# :section: Connection methods.
|
173
169
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
174
170
|
|
175
171
|
# Create the database.
|
176
|
-
|
172
|
+
|
177
173
|
def self.create_db(database, user = nil, password = nil)
|
178
174
|
Logger.info "Creating database '#{database}'."
|
179
175
|
end
|
180
176
|
|
181
177
|
# Drop the database.
|
182
|
-
|
178
|
+
|
183
179
|
def self.drop_db(database, user = nil, password = nil)
|
184
180
|
Logger.info "Dropping database '#{database}'."
|
185
181
|
end
|
186
182
|
|
187
183
|
# Execute an SQL query and return the result.
|
188
|
-
|
184
|
+
|
189
185
|
def query(sql)
|
190
186
|
raise "Not implemented"
|
191
187
|
end
|
192
188
|
|
193
189
|
# Execute an SQL query, no result returned.
|
194
|
-
|
190
|
+
|
195
191
|
def exec(sql)
|
196
192
|
raise "Not implemented"
|
197
193
|
end
|
198
194
|
|
199
195
|
# Execute an SQL query and return the result. Wrapped in a
|
200
196
|
# rescue block.
|
201
|
-
|
197
|
+
|
202
198
|
def safe_query(sql)
|
203
199
|
raise "Not implemented"
|
204
200
|
end
|
205
201
|
|
206
202
|
# Execute an SQL query, no result returned. Wrapped in a
|
207
203
|
# rescue block.
|
208
|
-
|
204
|
+
|
209
205
|
def safe_exec(sql)
|
210
206
|
raise "Not implemented"
|
211
207
|
end
|
212
208
|
|
213
209
|
# Check if it is a valid resultset.
|
214
|
-
|
210
|
+
|
215
211
|
def valid?(res)
|
216
212
|
raise "Not implemented"
|
217
213
|
end
|
218
214
|
|
219
215
|
# Start a new transaction.
|
220
|
-
|
216
|
+
|
221
217
|
def start
|
222
218
|
exec "START TRANSACTION"
|
223
219
|
end
|
224
220
|
|
225
221
|
# Commit a transaction.
|
226
|
-
|
222
|
+
|
227
223
|
def commit
|
228
224
|
exec "COMMIT"
|
229
225
|
end
|
230
226
|
|
231
227
|
# Rollback transaction.
|
232
|
-
|
228
|
+
|
233
229
|
def rollback
|
234
230
|
exec "ROLLBACK"
|
235
231
|
end
|
@@ -239,7 +235,7 @@ class Backend
|
|
239
235
|
# If the property has an :sql metadata this overrides the
|
240
236
|
# default mapping. If the property has an :extra_sql metadata
|
241
237
|
# the extra sql is appended after the default mapping.
|
242
|
-
|
238
|
+
|
243
239
|
def create_fields(klass, typemap)
|
244
240
|
fields = []
|
245
241
|
|
@@ -267,35 +263,35 @@ class Backend
|
|
267
263
|
# Create the managed object table. The properties of the
|
268
264
|
# object are mapped to the table columns. Additional sql relations
|
269
265
|
# and constrains are created (indicices, sequences, etc).
|
270
|
-
|
266
|
+
|
271
267
|
def create_table(klass)
|
272
268
|
return if query("SELECT * FROM #{klass::DBTABLE} LIMIT 1")
|
273
269
|
end
|
274
270
|
|
275
271
|
# Drop the managed object table
|
276
|
-
|
272
|
+
|
277
273
|
def drop_table(klass)
|
278
274
|
exec "DROP TABLE #{klass::DBTABLE}"
|
279
275
|
end
|
280
276
|
|
281
277
|
# Deserialize one row of the resultset.
|
282
|
-
|
278
|
+
|
283
279
|
def deserialize_one(res, klass)
|
284
|
-
raise
|
280
|
+
raise 'Not implemented'
|
285
281
|
end
|
286
282
|
|
287
283
|
# Deserialize all rows of the resultset.
|
288
|
-
|
284
|
+
|
289
285
|
def deserialize_all(res, klass)
|
290
|
-
raise
|
286
|
+
raise 'Not implemented'
|
291
287
|
end
|
292
288
|
|
293
289
|
# Return a single integer value from the resultset.
|
294
|
-
|
290
|
+
|
295
291
|
def get_int(res, idx = 0)
|
296
|
-
raise
|
292
|
+
raise 'Not implemented'
|
297
293
|
end
|
298
294
|
|
299
295
|
end
|
300
296
|
|
301
|
-
end
|
297
|
+
end
|