Commit Graph
28 Commits
Author SHA1 Message Date
XavierDoandChristophe Monniez c44fe91232 [IMP] http,server: add query count and request times in logs
When there is a performance issue, it's sometimes difficult to discover
which request increased the query count or its duration.

With this commit, the query count, the query time and "python and io" time are displayed
in the logs at the end of each werkzeug request line.

Co-authored-by: Christophe Monniez <moc@odoo.com>
2018-09-07 10:27:46 +02:00
Raphael Collet 960360afe4 [REF] *: use native date/datetime for Date/Datetime fields
From this commit onwards, Date fields will return datetime.date objects and Datetime fields will return datetime.datetime objects, this implies a number of things that are clearly explained both in the ORM API for master.

This commit also introduces a number of helper functions for dates and datetimes that are exposed in tools.date_utils and fields.Date[time], explained in the documentation as well.

Task-ID: 47189
2018-08-06 14:37:19 +02:00
Nicolas Lempereur db86e1d9e4 [FIX] sql_db: log-level debug_sql log parameters
Since 1a58e108 (on 10.0 and over) parameters are no longer present when
logging sql queries.

This removes some of the usefulness of the feature, and this commit adds
them back.

Since mogrify returns a byte string in the database encoding, we decode
it using the corresponding python encoding.

opw-1839241
closes #24446
2018-04-26 16:54:32 +02:00
Raphael Collet 7ea4f13f16 [REF] tests: TestCursor is now a proxy to a real Cursor
This allows rpc requests in `HttpCase` to use the cursor `self.cr`, which is
now shared between the Python test and the rpc requests.  This simplifies code
to prepare a JS test, and code to check the result of a JS tour.

Fixes #12237
2018-02-12 10:31:59 +01:00
Christophe Simonis 693f8dc68a [MERGE] forward port branch saas-16 up to 7bfde6e05d 2017-10-25 14:57:24 +02:00
Christophe Simonis 7bfde6e05d [MERGE] forward port branch saas-15 up to d516d39948 2017-10-25 14:20:51 +02:00
Christophe Simonis f86141aac2 [MERGE] forward port branch 10.0 up to 598ac60a77 2017-10-25 12:52:00 +02:00
Christophe Simonis ea9b574ac6 [MERGE] forward port branch 9.0 up to 6366150484 2017-10-25 11:28:25 +02:00
Christophe Simonis a8ecfd03c6 [IMP] core: allow to connect to database server with a secure SSL TCP/IP connection 2017-09-28 14:47:59 +02:00
Julien Legros ecbfcb6dcf [FIX] sql_db: use pycompat string_types 2017-09-11 11:49:13 +02:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Christophe Simonis 4f501348c4 [MERGE] forward port branch saas-16 up to 46e1104ce1 2017-07-26 19:55:44 +02:00
Christophe Simonis 46e1104ce1 [MERGE] forward port branch saas-15 up to 681f03e309 2017-07-26 19:41:57 +02:00
Christophe Simonis c4e9b854ff [IMP] core: log bad queries as ERROR
Also adapt default config and config mapping.
2017-07-26 17:46:20 +02:00
Xavier Morel 5ee9ec7d6c [FIX] P3: __nonzero__ -> __bool__
Also ~removed bool-testing on cursors
2017-06-26 16:45:03 +02:00
Christophe Simonis fd78b89a02 [MERGE] forward port branch saas-16 up to acfebff880 2017-06-15 21:50:35 +02:00
Christophe Simonis acfebff880 [FIX] *: correct PY3 compatibility introduced by previous forward-ports 2017-06-15 19:24:03 +02:00
Christophe Simonis ed2ddeccdf [MERGE] forward port branch saas-16 up to 1b50c829ef 2017-06-15 18:46:47 +02:00
Christophe Simonis 1b50c829ef [MERGE] forward port branch saas-15 up to 9713dc2e1f 2017-06-15 18:44:16 +02:00
Christophe Simonis 96595772e0 [MERGE] forward port branch 10.0 up to dc8b473a03 2017-06-15 18:35:46 +02:00
Olivier Dony 4acfe3577b [FIX] sql_db: port fix from psycopg/psycopg2#459
NUL characters must not be used in query parameters,
as they will be ignored by libpq, being end-of-string
characters.

Preventing NULs avoids unexpected results from
queries. It is only necessary with psycopg2
versions before 2.7, which includes the upstream
fix.
2017-06-15 16:23:35 +02:00
Xavier Morel 01e3514147 [FIX] P3: urllib, urllib2 and urlparse
In Python 3, all of these were "consolidated" under urllib(.request,
.parse, .errors) which is inconvenient.

Since we already have hard dependencies on requests and
werkzeug(.urls, which is a backport of Python 3's unicode-aware
urllib.parse) migrate *everything* to that.

A sticking point is urllib2.URLError, those were (mostly) replaced by
the slightly more general IOError which URLError extends.
2017-05-15 12:26:30 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
xmo-odoo 2e6a589f41 [FIX] builtins removed from Python 3
* Reverse wrapper courtesy of @rco-odoo's original P3 branch
* thin compat module stripped down from werkzeug (to augment as needed)

issue 8530
2017-04-27 13:59:33 +02:00
Devendra Kavthekar 8872800e75 [IMP] sql_db: Improve error message logging on database querries
Purpose:

When we have a SQL error, it's not very easy to identify the root of the crash. For example if a mandatory field is not set on a row creation, it difficult to see which field isn't correctly set as a lot of fields are not required and a lot a NULL values are present in the INSERT querry.

Specification:

Show a proper log message, with the reason (cause) of the sql error.

Behavior Modification Examples:
Some sample log after applied fix. The new line are those beginning by '+'

2016-10-25 09:59:40,208 21161 INFO ent_master odoo.sql_db: bad query: INSERT INTO "res_partner_category" ("id", "active", "color", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('res_partner_category_id_seq'), true, 10, 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
+REASON: null value in column "name" violates not-null constraint
+DETAIL:  Failing row contains (27, null, null, 1, null, 10, 1, null, 2016-10-25 09:59:40.207202, t, 2016-10-25 09:59:40.207202).

2016-10-25 10:00:29,710 21161 INFO ent_master odoo.sql_db: bad query: UPDATE "res_partner" SET "parent_id"=1001,"type"='contact',"name"='Course Script',"company_name"=NULL,"write_uid"=1,"write_date"=(now() at time zone 'UTC') WHERE id IN (1)
+REASON: insert or update on table "res_partner" violates foreign key constraint "res_partner_parent_id_fkey"
+DETAIL:  Key (parent_id)=(1001) is not present in table "res_partner".

2016-10-25 10:23:28,690 21336 INFO ent_master odoo.sql_db: bad query: DELETE FROM res_country WHERE id IN (235)
+REASON: null value in column "country_id" violates not-null constraint
+DETAIL:  Failing row contains (9, 1, AL, Alabama, null, 1, 2016-10-24 10:19:58.765552, 2016-10-21 09:32:26.939607).
+CONTEXT:  SQL statement "UPDATE ONLY "public"."res_country_state" SET "country_id" = NULL WHERE $1 OPERATOR(pg_catalog.=) "country_id""
2016-11-17 16:33:57 +01:00
Raphael Collet 4a700d0ad9 [FIX] odoo: rename imports and adapt import hooks 2016-09-02 17:28:12 +02:00
Raphael Collet 9e64f9f951 [REF] openerp: move openerp to odoo 2016-09-02 17:28:12 +02:00