|
@@ -43,7 +43,7 @@ class LeDataSourceSQL(DummyDatasource):
|
43
|
43
|
# @todo for speed get rid of all_to_dicts
|
44
|
44
|
# @todo filters: all use cases are not implemented
|
45
|
45
|
# @todo group: mosql does not permit direction in group_by clause, it should, so for now we don't use direction in group clause
|
46
|
|
- def select(self, target_cls, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=None):
|
|
46
|
+ def select(self, target_cls, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=None, instanciate=True):
|
47
|
47
|
|
48
|
48
|
joins = []
|
49
|
49
|
# it is a LeObject, query only on main table
|
|
@@ -119,8 +119,9 @@ class LeDataSourceSQL(DummyDatasource):
|
119
|
119
|
#print(results)
|
120
|
120
|
|
121
|
121
|
# instanciate each row to editorial components
|
122
|
|
- results = [target_cls.object_from_data(datas) for datas in results]
|
123
|
|
- #print('results', results)
|
|
122
|
+ if instanciate:
|
|
123
|
+ results = [target_cls.object_from_data(datas) for datas in results]
|
|
124
|
+ #print('results', results)
|
124
|
125
|
|
125
|
126
|
return results
|
126
|
127
|
|
|
@@ -167,7 +168,7 @@ class LeDataSourceSQL(DummyDatasource):
|
167
|
168
|
return result
|
168
|
169
|
|
169
|
170
|
## @brief update an existing lodel editorial component
|
170
|
|
- # @param target_cls LeCrud(class) : The component class concerned by the update (a LeCrud child class (not instance !) )
|
|
171
|
+ # @param target_cls LeCrud(class) : Instance of the object concerned by the update
|
171
|
172
|
# @param filters list : List of filters (see @ref leobject_filters)
|
172
|
173
|
# @param rel_filters list : List of relationnal filters (see @ref leobject_filters)
|
173
|
174
|
# @param **datas : Datas in kwargs
|
|
@@ -191,7 +192,7 @@ class LeDataSourceSQL(DummyDatasource):
|
191
|
192
|
|
192
|
193
|
class_table = utils.r2t_table_name(target_cls._superior_cls.__name__, target_cls._subordinate_cls.__name__)
|
193
|
194
|
else:
|
194
|
|
- raise AttributeError("'%s' is not a LeType or a LeRelation, it is not possible to insert it" % target_cls)
|
|
195
|
+ raise AttributeError("'%s' is not a LeType nor a LeRelation, it's impossible to update it" % target_cls)
|
195
|
196
|
|
196
|
197
|
for main_column_name in main_fields:
|
197
|
198
|
if main_column_name in datas:
|
|
@@ -246,7 +247,7 @@ class LeDataSourceSQL(DummyDatasource):
|
246
|
247
|
class_table = utils.r2t_table_name(superior_class.__name__, datas['subordinate'].__class__.__name__)
|
247
|
248
|
fk_name = superior_class.name2class('LeRelation').uidname()
|
248
|
249
|
else:
|
249
|
|
- raise AttributeError("'%s' is not a LeType or a LeRelation, it is not possible to insert it" % target_cls)
|
|
250
|
+ raise AttributeError("'%s' is not a LeType nor a LeRelation, it's impossible to insert it" % target_cls)
|
250
|
251
|
|
251
|
252
|
# extract main table datas from datas
|
252
|
253
|
for main_column_name in main_fields:
|