67 Commits

Author SHA1 Message Date
rldhont
4bc06b18e9 [Feature][PostgreSQL] Tests: Compile expression functions 2017-01-02 16:25:33 +01:00
rldhont
735b1c359a [Feature][PostgreSQL] Compile expression functions 2017-01-02 16:25:32 +01:00
Nyall Dawson
9c6883711b Enable edit tests for Postgres provider 2016-12-27 13:06:07 +10:00
Matthias Kuhn
2f0f6a98c6 Use assertIsInstance instead of assertTrue(isinstance()) 2016-12-20 16:32:50 +01:00
Denis Rouzaud
2ffe1a764b spelling fixes 2016-12-15 15:26:36 +01:00
Nyall Dawson
60bbd09339 Avoid double-evaluating postgres default values 2016-11-16 14:19:24 +01:00
Nyall Dawson
b5864cd432 [FEATURE] Improve handling of defaults (inc provider default clauses,
literal defaults, and qgis expression defaults) and automatically
handle unique value constraints on layers

Add a new method QgsVectorLayerUtils::createFeature which returns
a new feature which includes all relevant defaults. Any fields
with unique value constraints will be guaranteed to have a value
which is unique for the field.

Currently only in use by the split feature tool.

Sponsored by Canton of Zug and the QGEP project
2016-11-16 14:19:24 +01:00
Nyall Dawson
e40d64f9d5 Make provider default value clauses exempt from unique constraint checks
Otherwise the check fails when the provider has a default value clause
like 'nextval(...)' even though the actual committed value will be
unique.
2016-11-08 12:54:31 +10:00
Nyall Dawson
1fea20de50 Split handling of literal default values from provider side
default value SQL clauses

QgsVectorDataProvider now has two methods:

- defaultValueClause: returns SQL fragment which must be evaluated
by the provider to obtain the default value, eg sequence values
- defaultValue: returns the literal constant default value
for a field
2016-11-08 08:18:16 +10:00
Nyall Dawson
e3a608365f fix test 2016-11-02 13:42:22 +10:00
Nyall Dawson
cb94b68d88 Move constraint handling to QgsFieldConstraints
Avoids cluttering QgsField API
2016-11-02 11:07:07 +10:00
Nyall Dawson
f99ea26bdf Refactor constraint handling
- store constraint origin in QgsField
- move handling of constraint expressions to QgsField
2016-11-02 11:07:07 +10:00
Nyall Dawson
bd9f672aa7 Allow constraints to be added at a QgsVectorLayer level 2016-11-02 11:07:07 +10:00
Nyall Dawson
4efad04bd8 Move constraints to QgsField 2016-11-02 11:07:07 +10:00
Nyall Dawson
d1fd588499 Add method to fetch constraints from a vector data provider
Implemented for unique and not null constraints for postgres
provider
2016-11-02 11:07:07 +10:00
Martin Dobias
5e4bb00fa3 Fix import of shapefiles to postgres - regression introduced in 5abdfcb (#3652)
(cherry picked from commit a965a132c52df9308b5a58be92c04a285826485a)
2016-11-01 11:41:23 +08:00
Sandro Santilli
ada9348e2b Fix PostgreSQL import of layers with multi-column or quoted-column keys
Fixes #15226 (drag & drop of postgresql views)
Includes test
2016-10-14 10:43:41 +02:00
Sandro Santilli
0f4cba5c2d Fix bogus precision/scale in PostgreSQL for double values
This reverts commit 92f71b696ca93c792ae5602ed82863fcef0e5006,
which broke import of legit shapefiles by assuming wrong
semantic for the non-constraining QgsField length/precision
attributes.

Closes #15188

Includes test
2016-10-12 20:48:35 +02:00
Matthias Kuhn
4a7a8ff263 Update python code 2016-10-01 15:39:03 +02:00
Nyall Dawson
d49b656055 Permantly convert python tests to python 3 2016-09-21 09:12:54 +10:00
Patrick Valsecchi
abc55f4c42 Add support for arrays in PostgresQL
Fix parsing of PostgresQL hstore. Had problems when the key or values were
containing comas.
2016-09-12 10:33:00 +02:00
Patrick Valsecchi
3d6e7c8bdb Add hstore support to the postgres provider 2016-09-08 09:51:46 +02:00
Patrick Valsecchi
7169079f91 Smarter default edit widgets with plugins to pick them
Now the widgets factories can give a score on how good they could handle
a widget.

Additionaly, plugins can be added to choose a widget factory in function
of an external information. One of them uses a table in PostgresQL to
allow specification of the widget type and configuration.

I took the opportunity to remove a few deprecated method in relation to
this.
2016-09-05 14:22:17 +02:00
Matthias Kuhn
a529b448e7 Revert "Merge pull request #3338 from pvalsecc/editor_widgets_selection"
This reverts commit bbafbf48872eda48a2be8876cc89a0770552c6ad, reversing
changes made to 13ac0434e10fc7edd1eca665ea7c8b6cb5fd212d.
2016-08-29 19:22:04 +02:00
Patrick Valsecchi
24bde35ce6 Smarter default edit widgets with plugins to pick them
Now the widgets factories can give a score on how good they could handle
a widget.

Additionaly, plugins can be added to choose a widget factory in function
of an external information. One of them uses a table in PostgresQL to
allow specification of the widget type and configuration.

I took the opportunity to remove a few deprecated method in relation to
this.
2016-08-29 07:42:50 +02:00
Nyall Dawson
c2a232848c Add provider test for postgres with compound key 2016-08-15 10:48:33 +02:00
Sandro Santilli
d1cac842d3 Reach the proper lower negative value bound
This was tricky, due to
https://www.postgresql.org/message-id/20160608160800.GB13838%40localhost
2016-06-09 11:48:32 +02:00
Sandro Santilli
0f0d6c09a4 Add more tests to cover full signed int ranges 2016-06-09 11:48:31 +02:00
Sandro Santilli
3accda6dab Also test the estimatedmetadata code path for signedInts 2016-06-09 11:48:31 +02:00
Sandro Santilli
8b9a03536a Fix handling of int64 primary keys to use a FidMap
There was a code duplication where only one path did the right
thing. This commit also removes the duplication.
2016-06-09 11:48:30 +02:00
Sandro Santilli
8bd6ffcfae Fix expected test results for negative int4 and int2 FIDs
int8 negative identifier is still not handled correctly
2016-06-09 11:48:30 +02:00
Sandro Santilli
9a96414444 Fix storing attribute of feature with negative identifier and test
The test was also bogus in that it expected an inappropriate FID.
2016-06-09 11:48:30 +02:00
Nyall Dawson
ccc67ef7a5 Rename attributes support for postgres provider 2016-06-02 17:09:45 +10:00
Nyall Dawson
858914eef5 Ensure that providers fetch geometry for a QgsFeatureRequest
with an expression filter which requires geometry
2016-05-16 23:09:18 +10:00
Matthias Kuhn
af1de6e3e0 Migrate more tests to Python3 2016-05-14 00:02:20 +02:00
Denis Rouzaud
8071acd064 move PyQt compat folder to python/qgis 2016-04-29 14:10:26 +02:00
Nyall Dawson
fdd68963c7 [postgres] Improved handling of DOMAIN type fields
- show correct domain type as field type name
- correctly determine length and precision of domain types
- expose bpchar field type as 'character' to users, as postgres only
uses 'bpchar' internally and refers to bpchar as character in the
front end
2016-04-22 17:37:51 +10:00
Matthias Kuhn
c268f7e996 Run next_call fixer on tests 2016-04-15 09:20:39 +02:00
Nyall Dawson
92a18087b3 Add safeguard tests to ensure no regressions in expression compilation
(ie check that expressions are successfully compiled where expected)

Add compilation support for "NOT..." type expressions
2016-04-15 07:52:02 +10:00
Matthias Kuhn
07fcf2430b [postgres] Test for deadlocks with transactions 2016-04-14 09:39:51 +02:00
Matthias Kuhn
5cd2319c3f Also retrieve generated values for pktInt 2016-04-07 21:26:43 +02:00
Matthias Kuhn
eecd77a324 Fix postgres unit test 2016-04-07 21:24:01 +02:00
Matthias Kuhn
e98e16f1b2 Unit test for 4ec97c33 2016-04-07 15:59:22 +02:00
Matthias Kuhn
18cdad9956 Convert print function to py3 style in tests 2016-03-31 17:20:53 +02:00
Juergen E. Fischer
f41304637c switch tests to pyqt wrappers 2016-03-21 17:00:26 +01:00
Juergen E. Fischer
c6d921729e python fixes:
* issues identified by pyflakes (star and unused imports)
* pyqtwrapper: add QtSvg
* some exceptions e.message => unicode(e)
* some translations tr("..." % foo) => tr("...") % foo
* TODO:
  python/console/console_sci.py:547 QsciScintillaCompat?
  python/plugins/db_manager/dlg_query_builder.py:304 pop_up_error?
2016-03-15 17:25:23 +01:00
Sandro Santilli
2bd7f446b4 Fix signed 32bit integer overflow in PostgreSQL provider
Fixes #13958
Includes test for signed integer attributes
2016-02-16 17:40:34 +01:00
Juergen E. Fischer
42bc938700 add QgsCredentialsNone to not return any credentials and make it default instead of QgsCredentialsConsole (fixes #14269; reverts f8d2091) 2016-02-16 10:45:58 +01:00
Juergen E. Fischer
f8d2091255 avoid credentials requests in PyQgsPostgresProvider 2016-02-16 00:34:14 +01:00
Sandro Santilli
ab580fbd0e Do not hard-code database connection parameters
Rely on libpq defaults instead (overridable via environment)
2016-02-15 18:17:34 +01:00