- sql += ')'
- cond_tbl = [sql] + cond_tbl
-
- # Matching for tags column
- if type and value
- cond_tags = ['tags LIKE ? OR tags LIKE ? OR tags LIKE ? OR tags LIKE ?',
- ''+type+'='+value+'',
- ''+type+'='+value+';%',
- '%;'+type+'='+value+';%',
- '%;'+type+'='+value+'' ]
- elsif type
- cond_tags = ['tags LIKE ? OR tags LIKE ?',
- ''+type+'=%',
- '%;'+type+'=%' ]
- elsif value
- cond_tags = ['tags LIKE ? OR tags LIKE ?',
- '%='+value+';%',
- '%='+value+'' ]
- else
- cond_tags = ['1=1']
+ cond_node = [sql] + cond_node
+
+ # Matching for way tags table
+ cond_way = Array.new
+ sql = '1=1'
+ if type
+ sql += ' AND current_way_tags.k=?'
+ cond_way += [type]
+ end
+ if value
+ sql += ' AND current_way_tags.v=?'
+ cond_way += [value]
+ end
+ cond_way = [sql] + cond_way
+
+ # Matching for relation tags table
+ cond_rel = Array.new
+ sql = '1=1'
+ if type
+ sql += ' AND current_relation_tags.k=?'
+ cond_rel += [type]
+ end
+ if value
+ sql += ' AND current_relation_tags.v=?'
+ cond_rel += [value]