simple_nested_set 0.0.23 → 0.0.24
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/lib/simple_nested_set/nested_set.rb +12 -40
- data/lib/simple_nested_set/version.rb +1 -1
- metadata +3 -3
@@ -122,49 +122,21 @@ module SimpleNestedSet
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def denormalize_level_query
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
scope = where_clauses.map { |clause| clause.gsub(table_name, 'l') }.join(' AND ')
|
133
|
-
scope = "AND #{scope}" unless scope.empty?
|
134
|
-
|
135
|
-
%(
|
136
|
-
level = (
|
137
|
-
SELECT COUNT("l"."id")
|
138
|
-
FROM #{table_name} AS l
|
139
|
-
WHERE
|
140
|
-
l.lft < #{table_name}.lft AND
|
141
|
-
l.rgt > #{table_name}.rgt
|
142
|
-
#{scope}
|
143
|
-
)
|
144
|
-
)
|
125
|
+
aliaz = arel_table.as(:l)
|
126
|
+
query = aliaz.project(aliaz[:id].count).
|
127
|
+
where(aliaz[:lft].lt(arel_table[:lft])).
|
128
|
+
where(aliaz[:rgt].gt(arel_table[:rgt]))
|
129
|
+
query = [query.to_sql] + where_clauses.map { |clause| clause.gsub(arel_table.name, 'l') }
|
130
|
+
"level = (#{query.join(' AND ')})"
|
145
131
|
end
|
146
132
|
|
147
133
|
def denormalize_path_query
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
scope = where_clauses.map { |clause| clause.gsub(table_name, 'l') }.join(' AND ')
|
156
|
-
scope = "AND #{scope}" unless scope.empty?
|
157
|
-
|
158
|
-
%(
|
159
|
-
path = (
|
160
|
-
SELECT #{group_concat(db_adapter, :slug)}
|
161
|
-
FROM #{table_name} AS l
|
162
|
-
WHERE
|
163
|
-
l.lft <= #{table_name}.lft AND
|
164
|
-
l.rgt >= #{table_name}.rgt
|
165
|
-
#{scope}
|
166
|
-
)
|
167
|
-
)
|
134
|
+
aliaz = arel_table.as(:l)
|
135
|
+
query = aliaz.project(group_concat(db_adapter, :slug)).
|
136
|
+
where(aliaz[:lft].lteq(arel_table[:lft])).
|
137
|
+
where(aliaz[:rgt].gteq(arel_table[:rgt]))
|
138
|
+
query = [query.to_sql] + where_clauses.map { |clause| clause.gsub(arel_table.name, 'l') }
|
139
|
+
"path = (#{query.join(' AND ')})"
|
168
140
|
end
|
169
141
|
|
170
142
|
def db_adapter
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 24
|
10
|
+
version: 0.0.24
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sven Fuchs
|