summaryrefslogtreecommitdiff
path: root/openerp/sql_db.py
AgeCommit message (Collapse)Author
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet
2016-09-01[REF] registry: move functionalities from `RegistryManager` to `Registry`Raphael Collet
The API of `Registry` has been modified as follows: - `Registry(name)` returns the registry of the given database - `Registry.new(name)` forces the creation of a new `Registry` object - `Registry.delete(name)` discards the given registry - `Registry.delete_all()` discards all registries - `registry.setup_signaling()` initializes the signaling for `registry` - `registry.check_signaling()` returns an up-to-date `registry` - `registry.signal_registry_change()` notifies that `registry` has changed - `registry.signal_caches_change()` notifies potential cache invalidation
2016-06-16[MIG] models: convert class BaseModel to the new APIRaphael Collet
2016-03-08[REM] sql_db: legacy useless tests and duplicate exception blockOlivier Dony
- The test for %f/%d is useless, eveybody has been using %s for ages, and the psycopg2 error is pretty explicit if you don't. It can introduce a small but useless delay for long queries. - The duplicate except block was redundant with the generic `except Exception` block, with only a different log prefix. + the logging for the type testing of `params` was useless too, raising a error is enough (though that particular test is still relatively useful because the psycopg2 error isn't very clear when you mess up the parameters)
2016-03-08[IMP] sql_db: use time.time() for timing query executionOlivier Dony
Minor improvement: subtracting time.time() floats is about 10x faster than creating `timedelta` objects, and the code is simpler.
2016-03-08[IMP] sql_db: log SQL queries before executing themLionel Sausin
That way queries are visible at DEBUG level while they are executing, rather than after the fact, making the log less confusing to watch when long-running queries are involved. Closes #11182
2016-02-17[IMP] provide pg connection information as keywordsXavier Morel
When the database_or_uri is not a URI, rather than generate a dsn string just collect the various psycopg2.connect keyword arguments in a dictionary, and return that. This way psycopg2/libpq is the one doing any necessary processing on the various parameters. Fixes #3865 and fixes #6958 in a more resilient manner than manually escaping dsn-injected values so database names or passwords containing spaces or non-ascii characters work correctly. In case a URI is provided to the dsn() function, return it as the `dsn` keyword to get the same behaviour as previously. Since we're checking dsns by equality, a dict should work just as well as a string.
2016-01-29[MERGE] forward port of branch saas-6 up to 2616defDenis Ledoux
2016-01-29[MERGE] forward port of branch 8.0 up to edeb5a8Denis Ledoux
2016-01-29[IMP] fields: use a "lazy" cursor to compute attribute `digits`Raphael Collet
Borrowing a cursor each time you access `field.digits` may be costly, because of the connection reset. Moreover, in most cases, the cursor is not used at all, since the decimal precision are kept in cache. For the installation of module `product` with its demo data, the number of cursor allocations was reduced from ~1500 to about 50!
2016-01-15[IMP] sql_db: add event handlers for post-commit and post-rollbackRaphael Collet
2016-01-15[FIX] sql_db: do not handle errors when releasing savepointRaphael Collet
If you commit the transaction inside the context manager `cr.savepoint()`, the savepoint is lost. In that case, releasing the savepoint fails. That failure should not be handled by rolling back to the savepoint...
2015-06-02[LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate textOlivier Dony
- Preserved explicit 3rd-party copyright notices - Explicit boilerplate should not be necessary - copyright law applies automatically in all countries thanks to Berne Convention + WTO rules, and a reference to the applicable license is clear enough.
2015-05-28[MERGE] forward port of branch saas-6 up to bf1e999Christophe Simonis
2015-05-18[MERGE] forward port of branch 8.0 up to f722254Christophe Simonis
2015-05-11[FIX] Cursor.closed propertyChristophe Simonis
`_obj` doesn't exists anymore when the cursor is effectively closed.
2015-05-11[MERGE] forward port of branch 8.0 up to bff6dffChristophe Simonis
2015-05-08[FIX] sql_db: add `closed` property on `Cursor`.Christophe Simonis
2015-05-05[IMP] accounting v9. Yeeeeaahqdp-odoo
2015-04-27[MERGE] forward port of branch 8.0 up to cf4d14cChristophe Simonis
2015-04-27[MERGE] forward port of branch saas-3 up to 09b277cDenis Ledoux
2015-04-27[MERGE] forward port of branch 7.0 up to 3e7d3c7Denis Ledoux
2015-04-22[FIX] orm: ordering on >1000 recordsdhr-odoo
When reading over IN_MAX (currently 1000) records, the select is slip into subsets of IN_MAX records. However the list of ids was split using set() method which removes order that may have been pass. The subsets are ordered using _order attribute but the subsets were not ordered between themself. This is an issue in case of browsing a o2m field with more than 1000 lines as it will return sorted blocked but the order of the blocks is the order of the contained ids (e.g. split(2, [5, 4, 3, 2, 1]) -> [[2,1], [4,3], [5]]). Removes the set() to make sure the order of the given ids is preserved. opw 616070, linked to #439
2015-01-16[IMP] Cleanup and refactoring of exception handlingGoffin Simon
Unify and refactor exception handling in framework and addons. The generic `except_osv` is now deprecated, and replaced by more specialized exception subtypes: - `UserError` (renamed from Warning, as it conflicts with the built-in `Warning`) raised when a non-technical error occurs during a business operation. It could be a missing information in the data provided by the user, or a misconfiguration. - `AccessError`: raised when any operation is denied because the user conducting it does not have the required access rights. - `AccessDenied`: raised when an operation that requires authenticated access is attempted via an unauthenticated request. - `MissingError`: raised when an operation is attempted on a record that does not exist. - `ValidationError`: raised when an operation violates a SQL or Python constraint. - All other exceptions are internal errors due to a system problem or bug, and raised untouched to the client-side, which should display a traceback. All exceptions take a single message argument. The `test_exceptions` module has been updated to showcase both new and old (deprecated) exceptions. A great many old `except_osv` had a useless title with "Error!" or "Warning", those have been removed, as this is handled by the client-side widget that displays the messages. This commit introduces a more consistent policy for logging errors and warnings: - All messages that do not require administrator attention should be logged at INFO level or lower. This includes all errors that are notified to the user in a friendly manner, even for access right problems or validation errors during business operations. - All messages that indicate a likely misconfiguration or malicious use by the users should be logged at WARNING level, as they typically require administrator attention. - All other unhandled internal errors cannot typically be handled by the user and should be logged at ERROR or higher level, as they require immediate administrator attention.
2015-01-06[MERGE] forward port of branch 8.0 up to ea54d4aChristophe Simonis
2014-12-31[REF] remove vim modelines and resulting trailing blank linesLeonardo Donelli
Let 2015 be a year without modelines! cf #4174
2014-12-23[MERGE] forward port of branch saas-3 up to 30674c3Denis Ledoux
2014-12-23[MERGE] forward port of branch 7.0 up to e151e8fDenis Ledoux
2014-12-21[FIX] sql_db: close db connexions before removing them.Cedric Le Brouster
Closes #831 aka lp 1322191
2014-10-28[FIX] sql_db: don't log dsn with unmasked passwordsFlorian Kisser
The dsn may contain the connection password of the database when not accessed from a psycopg connection object. Replace the unfiltered logs to use cxn.dsn avoiding password leakage in logs. Fixes #1433
2014-09-05[FIX] removed bad comments from previous commitDavid Monjoie
2014-09-05[ADD] website_sale_digitalDavid Monjoie
2014-08-25[FIX] allow `--log-db` to connect to another postgresql server than the one ↵Christophe Simonis
setted in config
2014-07-01[IMP] test display sql query counterAntony Lesuisse
2014-06-20[IMP] remove usage of psycopg1.cursor, implement dictfetch* on openerp cursorXavier Morel
2014-04-15[MERGE] forward port of branch 7.0 up to revid 5281 ↵Christophe Simonis
launchpad_translations_on_behalf_of_openerp-20140412094159-mhy3v2prb3ctx32k bzr revid: jke@openerp.com-20140409153527-mic1a8afcvdhsd27 bzr revid: chs@openerp.com-20140410102422-fcwxhjk40z0oy8x5 bzr revid: chs@openerp.com-20140415133650-y46i0o3qkb2atbvi
2014-04-14[IMP] test cursor: code cleanup to make it more robust to concurrent accessesRaphael Collet
bzr revid: rco@openerp.com-20140414075906-2d0i4qhe4x7czsao
2014-04-10[FIX] sql_db: forgotten attribute renaming _pool -> __poolRaphael Collet
bzr revid: rco@openerp.com-20140410113950-71gcyz0t2rfuww57
2014-04-10[MERGE] forward port of branch saas-3 up to revid 5115 ↵Christophe Simonis
chs@openerp.com-20140410102422-fcwxhjk40z0oy8x5 bzr revid: chs@openerp.com-20140410105454-6utwgruj80h8wdss
2014-04-09[FIX] Allow missing opcodes, harden check for private attributes (dunder), ↵Kersten Jeremy
check inside embedded code objects. bzr revid: jke@openerp.com-20140409151659-xwttchbtbj02v1w7
2014-04-09[MERGE] test_cursor: implement a cursor mockup that never commits to ↵Raphael Collet
database, and use it for http tests bzr revid: rco@openerp.com-20140409145830-rop8esgic2y435kf
2014-04-09[IMP] sql_db: simplify TestCursor, given that method execute() does not need ↵Raphael Collet
overriding bzr revid: rco@openerp.com-20140409130825-rnc9hqh9t16hqcaq
2014-04-09[IMP] make TestCursor more robust, and remove some tests on ↵Raphael Collet
tools.config['test_enable'] bzr revid: rco@openerp.com-20140409103337-r0a1nx9h8nfg3cn3
2014-04-09[IMP] registry: now cursor() simply returns a cursor, which may itself be ↵Raphael Collet
used as a context manager bzr revid: rco@openerp.com-20140409095604-joh9dt0qkma12ykm
2014-04-08[IMP] http tests: implement a test cursor that keeps a transaction open ↵Raphael Collet
accross requests - TestCursor subclasses Cursor, and simulates commit and rollback with savepoints - the registry manages a test mode, in which it only uses the test cursor - a reentrant lock forces the serialization of parallel requests bzr revid: rco@openerp.com-20140408151736-j0guy68i2wjexy3d
2014-03-17[FIX] tests dont generate traceback on aborted test requestsAntony Lesuisse
bzr revid: al@openerp.com-20140317124343-kgesa5c215z19vpn
2014-02-20[IMP] Cursor.savepointXavier Morel
time.time doesn't guarantee sub-second precision. Use a uuid1 instead (lower anonymity but higher isolation than uuid4 especially in distributed systems, and we don't care about anonimity for savepoint names from application servers). Quote name so first character can be a digit. bzr revid: xmo@openerp.com-20140220103345-xistzxy17r8j87hf
2014-02-17[FIX] orm._auto_init: fallback to copy method when altering in-place varchar ↵Christophe Simonis
columns failed. When a varchar column has a dependence on a view, we cannot change the size in-place, we need to manually re-create the column with the correct type. bzr revid: chs@openerp.com-20140217182045-qor70r3gb0fch2ki
2014-01-22[FIX] multiprocess mode, empty the cursor pool before forkingAntony Lesuisse
bzr revid: al@openerp.com-20140122221525-hify023pk5i8d0jm
2013-04-04[MERGE] forward merge 7.0 until revision 4919.Vo Minh Thu
bzr revid: vmt@openerp.com-20130404130704-24vsmczw34cssytd