Explicity raise error when creating/writing/deleting models with table_query
issue4822 review16351002
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
* Allow to override ModelSQL._table
|
||||
* Allow to import backend from entry points
|
||||
* Add reversed operators to PYSON expressions
|
||||
* Explicity raise error when creating/writing/deleting models with table_query
|
||||
* Use CURRENT_TIMESTAMP instead of now
|
||||
* Use Constraint instance in ModelSQL._sql_constraints
|
||||
* Only return default record if no domain supplied on ModelSingleton search
|
||||
|
||||
@@ -424,6 +424,12 @@ Class methods:
|
||||
Could be overrided to use a custom SQL query instead of a table of the
|
||||
database. It should return a SQL FromItem.
|
||||
|
||||
.. warning::
|
||||
By default all CRUD operation will raise an error on models
|
||||
implementing this method so the create, write and delete methods may
|
||||
also been overriden if needed.
|
||||
..
|
||||
|
||||
.. classmethod:: ModelSQL.history_revisions(ids)
|
||||
|
||||
Return a sorted list of all revisions for ids. The list is composed of
|
||||
|
||||
@@ -471,7 +471,7 @@ class ModelSQL(ModelStorage):
|
||||
super(ModelSQL, cls).create(vlist)
|
||||
|
||||
if cls.table_query():
|
||||
return False
|
||||
raise NotImplementedError('Can not create model with table_query')
|
||||
|
||||
table = cls.__table__()
|
||||
modified_fields = set()
|
||||
@@ -841,7 +841,8 @@ class ModelSQL(ModelStorage):
|
||||
super(ModelSQL, cls).write(records, values, *args)
|
||||
|
||||
if cls.table_query():
|
||||
return
|
||||
raise NotImplementedError(
|
||||
'Can not write on model with table_query')
|
||||
table = cls.__table__()
|
||||
|
||||
cls.__check_timestamp(all_ids)
|
||||
@@ -941,7 +942,7 @@ class ModelSQL(ModelStorage):
|
||||
return
|
||||
|
||||
if cls.table_query():
|
||||
return
|
||||
raise NotImplementedError('Can not delete model with table_query')
|
||||
table = cls.__table__()
|
||||
|
||||
if transaction.delete and transaction.delete.get(cls.__name__):
|
||||
|
||||
Reference in New Issue
Block a user