lore 0.4.6 → 0.4.7
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/History.txt +5 -0
- data/custom_models.rb +60 -0
- data/lib/lore/connection.rb +1 -4
- data/lib/lore/exception/invalid_klass_parameters.rb +1 -1
- data/lib/lore/exception/invalid_parameter.rb +0 -1
- data/lib/lore/table_deleter.rb +14 -15
- data/lib/lore/table_instance.rb +5 -1
- data/lib/lore/table_selector.rb +1 -1
- data/lib/lore.rb +25 -12
- data/lore.gemspec +1 -1
- data/lore_test.log +2366 -0
- metadata +3 -3
data/History.txt
CHANGED
data/custom_models.rb
CHANGED
@@ -91,3 +91,63 @@ module App
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
module Some
|
95
|
+
module App
|
96
|
+
|
97
|
+
class New_Model < Lore::Model
|
98
|
+
table :new_model, :public
|
99
|
+
primary_key :model_id, :model_id_seq
|
100
|
+
has_attribute :name, Lore::Type.integer
|
101
|
+
has_attribute :created, Lore::Type.timestamp
|
102
|
+
has_attribute :model_id, Lore::Type.integer
|
103
|
+
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
module Some
|
110
|
+
module App
|
111
|
+
|
112
|
+
class New_Model < Lore::Model
|
113
|
+
table :new_model, :public
|
114
|
+
primary_key :model_id, :model_id_seq
|
115
|
+
has_attribute :name, Lore::Type.integer
|
116
|
+
has_attribute :created, Lore::Type.timestamp
|
117
|
+
has_attribute :model_id, Lore::Type.integer
|
118
|
+
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
module Some
|
125
|
+
module App
|
126
|
+
|
127
|
+
class New_Model < Lore::Model
|
128
|
+
table :new_model, :public
|
129
|
+
primary_key :model_id, :model_id_seq
|
130
|
+
has_attribute :name, Lore::Type.integer
|
131
|
+
has_attribute :created, Lore::Type.timestamp
|
132
|
+
has_attribute :model_id, Lore::Type.integer
|
133
|
+
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
module Some
|
140
|
+
module App
|
141
|
+
|
142
|
+
class New_Model < Lore::Model
|
143
|
+
table :new_model, :public
|
144
|
+
primary_key :model_id, :model_id_seq
|
145
|
+
has_attribute :name, Lore::Type.integer
|
146
|
+
has_attribute :created, Lore::Type.timestamp
|
147
|
+
has_attribute :model_id, Lore::Type.integer
|
148
|
+
|
149
|
+
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
data/lib/lore/connection.rb
CHANGED
@@ -29,7 +29,7 @@ class Context
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.enter(context_name)
|
32
|
-
|
32
|
+
Lore.log { 'Entering context ' + context_name.to_s }
|
33
33
|
@@context_stack.push(context_name)
|
34
34
|
end
|
35
35
|
|
@@ -128,9 +128,6 @@ class Connection # :nodoc
|
|
128
128
|
# Log database query on low level:
|
129
129
|
|
130
130
|
if Lore.log_queries? then
|
131
|
-
query = query.gsub('WHERE', "\nWHERE").gsub('FROM', "\n}}} \nFROM").gsub('JOIN', "\nJOIN")
|
132
|
-
query = query.gsub('SELECT', "\nSELECT \n{{{").gsub("\n\n","\n")
|
133
|
-
query = query.gsub('SET', "SET\n").gsub(' , ', ", \n")
|
134
131
|
query.split("\n").each { |line|
|
135
132
|
@@logger.debug { line }
|
136
133
|
}
|
data/lib/lore/table_deleter.rb
CHANGED
@@ -33,7 +33,7 @@ module Table_Deleter # :nodoc:
|
|
33
33
|
end
|
34
34
|
field_counter += 1
|
35
35
|
}
|
36
|
-
query_string += ';'
|
36
|
+
query_string += '; '
|
37
37
|
|
38
38
|
query_string
|
39
39
|
|
@@ -62,24 +62,23 @@ module Table_Deleter # :nodoc:
|
|
62
62
|
|
63
63
|
def self.delete_query(table_name, is_a_hierarchy, primary_keys, value_keys, query_string='')
|
64
64
|
|
65
|
-
is_a_hierarchy.each_pair { |table, base_tables|
|
66
|
-
|
67
|
-
# pass base tables first, recursively, as IS_A-based creation has
|
68
|
-
# to be done bottom-up:
|
69
|
-
query_string += delete_query(table,
|
70
|
-
base_tables,
|
71
|
-
|
72
|
-
primary_keys,
|
73
|
-
value_keys,
|
74
|
-
|
75
|
-
query_string
|
76
|
-
).to_s
|
77
|
-
}
|
78
|
-
# finally, add query string for this table:
|
79
65
|
query_string += atomic_delete_query(table_name,
|
80
66
|
primary_keys[table_name],
|
81
67
|
value_keys[table_name]
|
82
68
|
).to_s
|
69
|
+
is_a_hierarchy.each_pair { |table, base_tables|
|
70
|
+
|
71
|
+
# pass base tables afterwards, recursively, as IS_A-based deletion has
|
72
|
+
# to be done top-down (derived tabled first):
|
73
|
+
query_string = delete_query(table,
|
74
|
+
base_tables,
|
75
|
+
|
76
|
+
primary_keys,
|
77
|
+
value_keys,
|
78
|
+
|
79
|
+
query_string
|
80
|
+
).to_s
|
81
|
+
}
|
83
82
|
|
84
83
|
query_string
|
85
84
|
|
data/lib/lore/table_instance.rb
CHANGED
@@ -113,7 +113,7 @@ module Table_Instance
|
|
113
113
|
def marshal_load(dump)
|
114
114
|
klass = eval(dump[:klass])
|
115
115
|
dump[:joined].map { |m| m = eval(m) }
|
116
|
-
return initialize(dump[:values], dump[:
|
116
|
+
return initialize(dump[:values], dump[:joined], :cached)
|
117
117
|
end
|
118
118
|
|
119
119
|
# Whether this instance has been loaded from
|
@@ -378,6 +378,10 @@ module Table_Instance
|
|
378
378
|
table_accessor.after_instance_delete(self)
|
379
379
|
|
380
380
|
end # def
|
381
|
+
|
382
|
+
def inspect
|
383
|
+
get_attribute_values.inspect
|
384
|
+
end # def
|
381
385
|
|
382
386
|
end # module
|
383
387
|
|
data/lib/lore/table_selector.rb
CHANGED
@@ -192,7 +192,7 @@ protected
|
|
192
192
|
accessor,
|
193
193
|
&block)
|
194
194
|
|
195
|
-
|
195
|
+
Lore.log { 'Select on ' << accessor.to_s }
|
196
196
|
|
197
197
|
result = Array.new
|
198
198
|
if Lore.cache_enabled? && accessor.entity_cache && accessor.entity_cache.include?(accessor, query_string) then
|
data/lib/lore.rb
CHANGED
@@ -3,9 +3,17 @@ require('logger')
|
|
3
3
|
|
4
4
|
module Lore
|
5
5
|
|
6
|
-
VERSION='0.4.
|
6
|
+
VERSION='0.4.7'
|
7
|
+
|
8
|
+
@logfile = STDERR
|
9
|
+
@log_queries = false
|
10
|
+
@logging_enabled = false
|
11
|
+
@cache_entities = false
|
12
|
+
@pg_server = 'localhost'
|
13
|
+
@pg_port = 5432
|
14
|
+
@logins = { }
|
15
|
+
|
7
16
|
|
8
|
-
@logfile = '/var/log/lore/query.log'
|
9
17
|
def self.logfile
|
10
18
|
@logfile
|
11
19
|
end
|
@@ -23,17 +31,25 @@ module Lore
|
|
23
31
|
end
|
24
32
|
|
25
33
|
def self.log_queries?
|
26
|
-
|
34
|
+
@log_queries && @logging_enabled
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.disable_logging
|
38
|
+
@logging_enabled = false
|
39
|
+
end
|
40
|
+
def self.enable_logging
|
41
|
+
@logging_enabled = true
|
42
|
+
end
|
43
|
+
def self.enable_query_log
|
44
|
+
@log_queries = true
|
45
|
+
end
|
46
|
+
def self.disable_query_log
|
47
|
+
@log_queries = false
|
27
48
|
end
|
28
49
|
def self.logging_disabled?
|
29
|
-
|
50
|
+
!@logging_enabled
|
30
51
|
end
|
31
52
|
|
32
|
-
@cache_entities = false
|
33
|
-
|
34
|
-
@logins = {
|
35
|
-
}
|
36
|
-
|
37
53
|
def self.set_login_data(login_hash)
|
38
54
|
@logins = login_hash
|
39
55
|
end
|
@@ -45,9 +61,6 @@ module Lore
|
|
45
61
|
File.expand_path(File.dirname(__FILE__)) + '/'
|
46
62
|
end
|
47
63
|
|
48
|
-
@pg_server = 'localhost'
|
49
|
-
@pg_port = 5432
|
50
|
-
|
51
64
|
def self.pg_server
|
52
65
|
@pg_server
|
53
66
|
end
|
data/lore.gemspec
CHANGED
@@ -16,7 +16,7 @@ spec = Gem::Specification.new { |s|
|
|
16
16
|
high coverage of native SQL functions and features.
|
17
17
|
Lore is currently using PostgreSQL as database backend.
|
18
18
|
EOF
|
19
|
-
s.version = '0.4.
|
19
|
+
s.version = '0.4.7'
|
20
20
|
s.author = 'Tobias Fuchs'
|
21
21
|
s.email = 'fuchs@atomnode.net'
|
22
22
|
s.date = Time.now
|