瀏覽代碼

[#68] get_relations method is implemented in LeDataSourceSQL

Roland Haroutiounian 9 年之前
父節點
當前提交
70c237d65f
共有 1 個檔案被更改,包括 14 行新增1 行删除
  1. 14
    1
      leobject/datasources/ledatasourcesql.py

+ 14
- 1
leobject/datasources/ledatasourcesql.py 查看文件

@@ -245,4 +245,17 @@ class LeDataSourceSQL(DummyDatasource):
245 245
     # @param nature str|None : Search for relations with the given nature (if None rel2type)
246 246
     # @param return an array of dict with keys [ id_sup, id_sub, rank, depth, nature ]
247 247
     def get_relations(self, lodel_id, superior=True, nature=None):
248
-        raise NotImplementedError()
248
+        select_params = {}
249
+        if superior is True:
250
+            select_params['id_sup'] = lodel_id
251
+        else:
252
+            select_params['id_sub'] = lodel_id
253
+
254
+        select_params['nature'] = nature
255
+
256
+        sql = select(self.datasource_utils.relations_table_name, select_params)
257
+
258
+        with self.connection as cur:
259
+            results = all_to_dicts(cur.execute(sql))
260
+
261
+        return results

Loading…
取消
儲存