Commit Graph
321 Commits
Author SHA1 Message Date
Cédric Krier d766a67fbb Use cache to fill Reference selections
issue9235
review335301003
2020-12-27 00:19:30 +01:00
Cédric Krier 4f83dff439 Convert rule domain for _write and _delete without active test
We must convert in ModelSQL.read the rule domains like the ModelSQL.write and
ModelSQL.delete convert their rule without the active test to have the same
result.

issue9819
review300951006
2020-11-23 23:43:01 +01:00
Cédric Krier 1f013a7eec Convert read column into proper type with SQLite
As SQLite has few basic types, we must use column names cast parsing to ensure
to read values in proper type.

issue9652
review310801004
2020-10-21 23:11:13 +02:00
Nicolas Évrard 70b2c9b56c Manage deletable and writable state from ir.rule
issue9357
review290101002
2020-09-23 10:04:19 +02:00
Cédric Krier b3f8d125f9 Use custom class to store record data
By using a class with slots instead of standard dict, we can reduce a lot the
memory usage to store the record data in the caches and values.
Also we can rely on the data in the cache to exist only for real field which
can be used to create a fast path in ModelStorage.__getattr__.
As now storing data in the cache has no extra cost, we can store data from the
transactional cache in the local. This allow also to have a shorter path in
ModelStorage.__getattr__.
For more memory efficiency, we remove the record from the cache instead of
clearing them. It was better to clear a dict but a record is less expensive to
re-instantiate than clearing.

issue9369
issue9225
review297861002
2020-06-13 09:48:03 +02:00
Cédric Krier d7ed5f91f5 Fix flake8 errors and warnings
We add the flake8 configuration used so we ensure everyone uses the same.
We remove the usage of __all__ for non public API.
When possible, we rationalize the class name according to its __name__ and module.

issue9082
review297061002
2020-03-01 12:33:54 +01:00
Cédric Krier a99931c5c4 Do use translation cache if records were modified after last synchronisation
On distributed setup, the cache is not synchronized instantaneously so we can
not use the cache if the record was modified by another process since the last
synchronisation.

issue9013
review262841002
2020-02-15 01:36:48 +01:00
Cédric Krier e118cb894a Apply Exclude where clause when searching other records
When we simulate the Exclude constraints, we must apply the where clause also
to existing records.

issue8954
review284651002
2020-01-13 23:58:14 +01:00
Cédric Krier 6b14518eff Position new record based on order
We sent an order to the client for action and xxx2Many so its screen has
always a default order set.
To position a new record on non editable tree, we use the order of the 'id'
column if presents.

issue8880
review276501003
2019-12-28 18:16:28 +01:00
Nicolas Évrard 8fb13634ea Use direct access to backend classes
issue8836
review258421002
2019-12-06 17:33:47 +01:00
Cédric Krier b8af68cf59 Do not check timestamp when it is None
issue8779
review268321002
2019-11-05 10:33:25 +01:00
Cédric Krier 34678d2be6 Backed out changeset f08b9ce07a7b 2019-11-04 16:05:28 +01:00
Cédric Krier 65650004c9 Update release number 2019-11-04 16:01:28 +01:00
Cédric Krier 0b5dc3e389 Compare timestamps as Char for inequality
Databases are too random about rounding when casting epoch into numerical
value. So it is better to check against inequality of the string.

issue8779
review254571002
2019-11-03 17:49:03 +01:00
Cédric Krier 7729badb30 Cast timestamp epoch into FLOAT to avoid rounding
On PostgreSQL-12, the epoch FLOAT is now 6 digits but rounded to 5 digits when
cast into NUMERIC.

issue8779
review264501002
2019-11-01 23:04:50 +01:00
Cédric Krier 4154b93a01 Prevent assign unknown attributes on Model
by adding __slots__ on PoolMeta

issue8567
review254091002
2019-09-07 23:45:08 +02:00
Cédric Krier 23dabd10b2 Always return 'id' key in the read result
The 'id' should not be removed from the result if a field use it as an extra
(e.g. for context).

issue8470
review263841002
2019-07-08 21:30:43 +02:00
Cédric Krier 5c2782626b Use freezed context in order function
The hash method can no hash tuple containing unhashable element like a list.

issue8265
review265341002
2019-04-25 15:24:01 +02:00
Cédric Krier 12376f30e5 Order by target name and context hash
None can not be compared to a class so we always use strings to order before
grouping. Also dictionary can not be compared neither.

issue8265
review253351002
2019-04-24 23:40:46 +02:00
Cédric Krier 3e9784c8d7 Set context on record instantiated in Field.__set__ and read related
Field may have a context defined so when it instantiate a relational record,
the field should set this context like when the record is read from the
database in ModelStorage.__getattr__.
And when such field is read as related field, the context should also be set.

issue8225
review287171002
2019-04-04 19:06:09 +02:00
Cédric Krier bb0242faf8 Raise NotImplementedError when setting Function field without setter
issue7985
review265101002
2019-03-27 00:28:58 +01:00
Cédric Krier 10e31bc311 Add Model.__names__ to retrieve model and field names
issue8159
review72431002
2019-03-15 12:27:44 +01:00
Cédric Krier c255cfe785 Display ids and rule names on access error
issue8093
review60551002
2019-03-03 23:11:17 +01:00
Cédric Krier b34cac78d5 Allow to lock records for update
issue8012
review45901002
2019-01-30 09:45:59 +01:00
Cédric Krier 83bf159aef Check foreign key in last on database integrity error
The search is done on a new transaction so it can not find targets that were
created during the main transaction.
2018-12-29 23:28:40 +01:00
Cédric Krier 1738a4ec35 Add ir.message and use custom exceptions
issue3672
review35291002
2018-12-29 14:19:08 +01:00
Cédric Krier b387adc7bc Add check on ModelSQL for positive id
issue7867
review50631002
2018-12-22 00:01:41 +01:00
Cédric Krier d1bb790cb8 New API to read related fields
issue7888
review58431002
2018-12-21 23:41:56 +01:00
Sergi Almacellas Abellana fc5f906ce5 Do not initiate sql table when table_query is defined
issue7896
review64491002
2018-12-03 11:29:43 +01:00
Cédric Krier c7f5c54a83 Remove implicit fields names in ModelStorage.read
It is a bad practice to not explicit the fields to read. So we should not
support it.

issue7830
review54421002
2018-11-28 10:05:01 +01:00
Cédric Krier 1a3ee131fe Check read access on field in search domain
issue7766
review50591002
2018-11-12 17:18:06 +01:00
Cédric Krier 7a2ce7905a Add __table_handler__ to ModelSQL
issue7581
review48531002
2018-07-24 22:01:08 +02:00
Cédric Krier d2a461390a Remove support for Python 2.7
issue7497
review53261002
2018-06-26 19:11:19 +02:00
Cédric Krier 93526b9cd0 Check rule after indirect fields and modification
The rule may depend on indirect field written latter so it must be checked
after the storage of those fields.
On write, the rule must be checked before the modification but also after to
ensure users do not generate records that they can not modify after.

issue7403
review53301002
2018-06-24 16:54:46 +02:00
Cédric Krier d23d7c9ccb Do not call table_query for testing
Only the callable property of table_query is used to test if the ModelSQL uses
a table query or not.

issue5726
review47321002
2018-04-30 15:55:31 +02:00
Cédric Krier 60f167bcfe Add index method to order field set calls
issue7090
review46301002
2018-04-05 19:18:52 +02:00
Cédric Krier b15f3fb4c5 Do not append Exclude where clause if empty 2018-03-19 17:48:55 +01:00
Cédric Krier b3ca13748b Add Exclude constraint
issue1422
review44061002
2018-03-19 16:57:49 +01:00
Cédric Krier 62a90a603e Use unicode instead of str for DatabaseIntegrityError
The exception message could contain non-ASCII errors for which standard
__str__ may fail, but as the database should always be in UTF-8 we may except
that unicode will not fail.

issue6128
review43971002
2018-02-19 19:09:06 +01:00
Cédric Krier f911f48ed4 Delete translations only when model has translatable field
The call to Translation.delete_ids has a cost as it does search queries. So it
is better to not call it if we already know that there is nothing to delete.

issue7118
review37981003
2018-02-11 14:59:58 +01:00
Cédric Krier d813ac2090 Add limit to SQL queries consumed with a single fetchone call
This remove some load on the database server.
This is only needed for queries that may have more than one rows.

issue7040
review43001003
2018-01-09 18:31:00 +01:00
Sergi Almacellas Abellana 1aae453480 Don't use an sql query to delete target models if not ModelSQL
issue6525
review35431002
2017-06-30 09:46:21 +02:00
Cédric Krier a53883484e Update MPTT before the validation of created records
This prevent to fill the cache of the instances created with wrong values for
left/right fields. And it ensure that the validation code has valid MPTT
values.

issue6591
review34211002
2017-06-29 23:08:36 +02:00
Cédric Krier 4520afedd3 Convert into hash too long data name
Some back-ends have constraint on the length of data name, they usually
silently truncate them, but this can create collision. The solution is to hash
the name when it is too long.

issue4620
issue6494
review37381003
2017-05-12 12:00:44 +02:00
Sergi Almacellas Abellana 7ed3976d80 Use issubclass to test if foreign keys must be created
issue6491

review42321002
2017-05-08 12:00:37 +02:00
Cédric Krier 826f30219d Re-use method as default parameter of TableHandler add_column
There is no guarantee that the method will not raise a database error on the
first registration because it can rely on other tables being registered.
So the method must be called only when needed. This is when the table already
exists and has records. In this case other tables also already exist.

issue6409
2017-04-01 16:14:36 +02:00
Nicolas Évrard aa9c9cc9e7 Use sql type instead of field related argument in the column creation
issue6348
review26231002
2017-03-31 13:21:51 +02:00
Nicolas Évrard c3f69d1db7 Add NULLS ordering
issue5858
review27651002
2017-03-29 23:12:01 +02:00
Cédric Krier 2569f4dd52 Allow Many2One on ModelSQL to target ModelStorage
issue6237
review26081002
2017-02-11 19:08:52 +01:00
Cédric Krier 2351008095 Fill cache with selected columns in ModelSQL.read
This minimizes missing cache on the instances when computing Function field.

issue6209
review31981002
2017-02-02 11:57:18 +01:00