@@ -172,7 +172,7 @@ defmodule Hierarch do
172
172
173
173
from (
174
174
t in unquote ( table ) ,
175
- where: fragment ( "path = ?" , ^ roots_path )
175
+ where: field ( t , ^ unquote ( path_column ) ) == ^ roots_path
176
176
)
177
177
end
178
178
@@ -187,17 +187,17 @@ defmodule Hierarch do
187
187
Build child of a node
188
188
"""
189
189
def build_child_of ( schema , attrs \\ % { } )
190
- def build_child_of ( schema = % { unquote ( :" #{ path_column } " ) => path , __struct__: __MODULE__ } , attrs ) do
190
+ def build_child_of ( schema = unquote ( schema_argument ) , attrs ) do
191
191
{ _ , id } = get_primary_key ( schema )
192
192
193
193
path = LTree . concat ( path , to_string ( id ) )
194
- node_attrs = Map . put ( attrs , :path , path )
195
- struct ( __MODULE__ , node_attrs )
194
+ schema_attrs = Map . put ( attrs , unquote ( path_column ) , path )
195
+ struct ( __MODULE__ , schema_attrs )
196
196
end
197
197
# Build the root
198
198
def build_child_of ( _ , attrs ) do
199
- node_attrs = Map . put ( attrs , :path , "" )
200
- struct ( __MODULE__ , node_attrs )
199
+ schema_attrs = Map . put ( attrs , unquote ( path_column ) , "" )
200
+ struct ( __MODULE__ , schema_attrs )
201
201
end
202
202
203
203
defp blank_query do
0 commit comments