summaryrefslogtreecommitdiff
path: root/odoo/tools/sql.py
AgeCommit message (Collapse)Author
2021-03-19[FIX] base: allow using another postgres schema than publicStéphane Bidoul
Before 1721ec1363 and fdc4ef97c9d09, Odoo did work fine when the user had another default schema than 'public'. This commit restores this behaviour by searching for existing objects in the user's current schema, which is the first in the schema search path and the one used when no schema is specified when creating objects. closes odoo/odoo#68141 X-original-commit: 223781b34afacd1c0c5674d395cece6d472b048c Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2020-09-28[FIX] tools.sql, website_*: increment counter with skip lockJeremy Kersten
*blog, forum, slides Based on https://github.com/odoo/odoo/pull/48552#discussion_r440061218 suggestion Add a new method 'increment_skip_lock' in tools.sql to allow to easily increment a specific field of 1 if the record is not locked. The method return boolean if at least 1 record has been incremented. closes odoo/odoo#58534 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-04-03[IMP] core: optimize `model._auto_init()` on a new modelRaphael Collet
Create the table with all the columns from scratch, with the NOT NULL constraint when required. Also do not call `_check_removed_columns()` on a new table. This saves 0.5% of the total installation time. X-original-commit: 0727cacf5194a143b15ab4cb9893f3035a67be1f
2020-02-06[FIX] core: delay constraint application in case of upgradeAdrian Torres
closes odoo/odoo#44800 Co-authored-with: Xavier Dollé <xdo@odoo.com> X-original-commit: bc2bb5e03c2b32d4ee1b0597ea5889c17d2b0e0e Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2019-12-24[FIX] sql_db: ignore PG views when verifying table typeDenis Vermylen
Collisions in table names of ORM models with built-in PG structures such as "attributes", "domains", "routines", "parameters", ... could occur and render the result of `table_kind` meaningless. Based on what was done via https://github.com/odoo/odoo/pull/16651 more than 2 years ago, it seems relying on our tables being in the 'public' schema is safe, even though it's only a default from PG. We reuse that same logic rather than the alternative of excluding ('information_schema', 'pg_catalog', ...), even though it looks safer at first. If we did the latter we'd have to change the other comparison for consistency, i.e. more risks. closes odoo/odoo#42358 X-original-commit: d8e74eb14990c82f65a44ffe163aa84159d6ccc4 Signed-off-by: Denis Vermylen <Icallhimtest@users.noreply.github.com>
2019-12-03[FIX] base: allow custom model to use SQL (materialized) views instead of tableNicolas Vannieuwerburgh
closes odoo/odoo#41267 X-original-commit: f17d389c4625e95f52c299c13a3f2983127c70bc Signed-off-by: Raphael Collet (rco) <rco@openerp.com> Co-authored-by: Denis Ledoux <dle@odoo.com> Co-authored-by: Raphael Collet <rco@odoo.com>
2019-10-02[ADD] test_lint: Add sql-injection pylint checkMoisés López
closes odoo/odoo#36583 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-08-26[FIX] sql_db: add flush() in savepoint()Raphael Collet
closes odoo/odoo#36060 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-08-20[IMP] models: ORM speedupRaphael Collet
This branch is the combination of several optimizations in the ORM: * store field values once in the cache: the cache reflects more faithfully the database, only fields that explicitly depend on the context have an extra indirection in the cache; * delay recomputations by default: use method `recompute` to explicitly flush out pending recomputations; * delay updates in method `write`: updates are stored in a data structure that can be flushed efficiently to the database with method `flush` (which also flush out recomputations); * make method `modified` take advantage of inverse fields to inverse dependencies; * filter records by evaluating a domain on records in Python; * a computed field with `readonly=False` behaves like a normal field with an onchange method; * computed fields are computed in superuser mode by default. Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien Pinckaers. closes odoo/odoo#35659 Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2018-08-16[RFR] Hide implementation of constraint definition storage, courtesy of ↵Stefan Rijnhart
Raphael Collet
2018-08-16[IMP] Store the original constraint definition as a comment on the constraintStefan Rijnhart
and use it to determine if the constraint definition was changed. This prevents endless readding of constraints that are reformatted by postgresql in an unrecognizable way (in which e.g. "CHECK (credit*debit=0)" becomes "CHECK ((credit * debit) = 0::numeric)")
2017-09-12[MERGE] forward port branch saas-17 up to d08b4407be3Christophe Simonis
2017-09-11[FIX] core: only check table existance in public schemaChristophe Simonis
This allow the use of tables defined in other schemas, like `domains`, already defined in `information_schema`. See #16651
2017-09-06[MERGE] forward port branch saas-17 up to b8dd34fcbb8Christophe Simonis
2017-09-06[MERGE] forward port branch saas-16 up to 64d56995e04Christophe Simonis
2017-09-04[MERGE] forward port branch saas-15 up to 4d4d75709dcChristophe Simonis
2017-09-04[FIX] core: also consider materialized views as existingChristophe Simonis
At the end of registry loading, a check is made on every model to verify its table exists in the database. Materialized views weren't considered during this check. Note that we can't use `information_schema` views in this case because it does include materialized views on purpose [1]. Forward-port of 4ca6945256f9353ab7f9633552872fd1fa7fdaca [1] http://www.postgresql-archive.org/Materialized-views-don-t-show-up-in-information-schema-tp5822643p5822644.html
2017-08-07[IMP] sql: harvest less information from pg's information_schema (Fixes #18490)Fabien Meghazi
Avoid `SELECT *` on `information_schema.columns` because specific access right restrictions in the context of shared hosting (Heroku, OVH, ...) might prevent a postgres user to read this field.
2017-07-10[IMP] registry: check existence of tables with a single SQL queryRaphael Collet
2017-07-05[FIX] sql: Do no consider a table exists if this is a schema table/viewDenis Ledoux
Before this revision, this is not possible to create a model with a `_table` set to `domains`, for instance.
2017-05-03[REF] registry: always perform registry/cache signaling at the end of requestRaphael Collet
Problem: the update of custom models/fields is not fully transactional, and may potentially lead to an inconsistent database. An other problem is creating two custom fields by writing on a model: if the second one fails, the first one has been committed without notice. Retrying the request will give an unexpected error (duplicate field name). Solution: never commit in the middle of a request. If the changes have an impact on the registry, then mark it as invalid (with a new flag), and signal registry invalidation after everything has been committed. If the request fails, reset the registry. Both registry and cache invalidation are handled the same way.
2017-04-28[FIX] tools.sql: correct queries used to rename fieldChristophe Simonis
2017-03-14[FIX] tools/sql: column name in `fix_foreign_key`Raphael Collet
2017-02-22[IMP] tools: use `information_schema` instead of pg-specific tablesRaphael Collet
2017-02-22[REF] models: refactoring of foreign keysRaphael Collet
2017-02-22[REF] tools: add functions for SQL schema manipulationRaphael Collet
This helps factoring out a certain number of similar queries, and removing a few methods from `BaseModel`.
2016-09-16[IMP] models: change API of `_group_by_full`Raphael Collet
The dictionary `_group_by_full` is replaced by a field parameter `group_expand` that is assigned to the method name. The API of the method has been simplified as well: @api.multi def _read_group_stage_ids(self, domain, read_group_order=None, access_rights_uid=None): # the stages are given by self.ids (wrong model); # read_group_order is the order given to read_group() on self; # return stages.name_get(), {stage.id: stage.fold) _group_by_full = {'stage_id': _read_group_stage_ids} is now written: stage_id = fields.Many2one(..., group_expand='_read_group_stage_ids') @api.model def _read_group_stage_ids(self, stages, domain, order): # stages is a recordset; # order is the order to use on stages' model; # return a recordset which is a superset of stages
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet