Commit Graph

128 Commits

Author SHA1 Message Date
Jack Wearden
559096f1c2 Allow disabling workaround for since-fixed MongoDB bug (#5617)
* Allow disabling workaround for fixed MongoDB bug

* skipMongoDBServer13732Workaround description fix

* flip test boolean

* Remove CLI flag, use databaseVersion & engine

* Revert "Remove CLI flag, use databaseVersion & engine"

This reverts commit 042d1ba19f636fe0da06074168c6fd5db37ea048.

* clean up
2019-06-19 17:30:08 -05:00
Diamond Lewis
7590ee9799 Fix #5678 (#5681)
* Fix #5678

* Revert "Fix #5678"

This reverts commit 106b6ddd9535da6ec323226c1b9ad649022aeb1e.

* revert #5627
2019-06-13 13:40:58 -05:00
Olivier Allouch
7fc0d45b89 Database version in features (#5627)
* adding database.version in the serverInfo (only MongoDB, it gives undefined when using Postgres)

* . correction of old 'features' tests
. adding engine and database in the StorageAdapter interface and implementations

* . version retrieval done in performInitialization
. PostgreSQL version

* performInitialization now returns a Promise
2019-06-03 16:58:21 -05:00
Diamond Lewis
005fd78275 PG: Fix updating mixed array (#5552)
* PG: Fix updating mixed array

* Revert "PG: Fix updating mixed array"

This reverts commit 5a441413c083747d9e51767be7b2e9298bd4f8ba.

* simple fix
2019-05-02 12:44:17 -05:00
Diamond Lewis
057fc40c1d Postgres: Query notEqualTo GeoPoint (#5549)
* Postgres: Query notEqualTo GeoPoint

* remove templated strings
2019-04-30 23:29:44 -05:00
CoderickLamar
c7eb7daeae Fix for count being very slow on large Parse Classes' collections (Postgres) (#5330)
* Changed count to be approximate. Should help with postgres slowness

* refactored last commit to only fall back to estimate if no complex query

* handlign variables correctly

* Trying again because it was casting to lowercase table names which doesnt work for us/

* syntax error

* Adding quotations to pg query

* hopefully final pg fix

* Postgres will now use an approximate count unless there is a more complex query specified

* handling edge case

* Fix for count being very slow on large Parse Classes' collections in Postgres. Replicating fix for Mongo in issue 5264

* Fixed silly spelling error resulting from copying over notes

* Lint fixes

* limiting results to 1 on approximation

* suppress test that we can no longer run for postgres

* removed tests from Postgres that no longer apply

* made changes requested by dplewis

* fixed count errors

* updated package.json

* removed test exclude for pg

* removed object types from method

* test disabled for postgres

* returned type

* add estimate count test

* fix mongo test
2019-04-08 17:59:15 -05:00
awgeorge
b343de0c70 Set default protectedFields and remove previous filter logic 2019-02-23 07:28:39 -08:00
Steve Clay
038d7bd727 postgres: Refuse to build unsafe JSON lists for contains in Postgres (#5337) 2019-01-31 12:23:40 -05:00
dependabot[bot]
3851641b5a Bump flow-bin from 0.83.0 to 0.91.0 (#5302)
* Bump flow-bin from 0.83.0 to 0.91.0

Bumps [flow-bin](https://github.com/flowtype/flow-bin) from 0.83.0 to 0.91.0.
- [Release notes](https://github.com/flowtype/flow-bin/releases)
- [Commits](https://github.com/flowtype/flow-bin/compare/v0.83.0...v0.91.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* fix flow issue
2019-01-19 13:08:42 -05:00
Diamond Lewis
ab32dbc9a2 PG: Fix containedIn query on empty array (#5254)
* PG: Fix containedIn query on empty array

* improve logic
2018-12-19 17:57:55 -06:00
Diamond Lewis
631b1684e2 PG: Updating mixed array test (#5252)
* PG: Updating mixed array test

Currently we can save a mixed array but not update

* build array instead of casting

* fix test

* add recursion
2018-12-18 17:38:05 -06:00
Diamond Lewis
7b3da8b744 PG: Fix updating numeric array (#5251)
* PG: Fix updating numeric array

* lint
2018-12-18 12:11:24 -06:00
Diamond Lewis
d478e001b5 PG: Support multiple global config (#5242)
* PG: Support Multiple Configs

* rename test

* refactor
2018-12-14 17:39:07 -06:00
Ben Briggs
45ff23bde2 postgres: Ensure that setting a value to undefined is a no-op on writes. (#5065) (#5069) 2018-09-26 16:42:06 -04:00
Florent Vilmart
d83a0b6808 Use Prettier JS (#5017)
* Adds prettier

* Run lint before tests
2018-09-01 13:58:06 -04:00
Florent Vilmart
bf9fdb41ed Ensure the ACL is always part of the payload when using select (#4967)
* Ensure the ACL is always part of the payload when using select

* Update changelog

* fix for PG
2018-08-15 09:48:32 -04:00
Florent Vilmart
960431b92d Even faster tests (#4868)
* Various improvements in test name / de-duplications

* Reverts to class by class deletion, introduced fast mode that just delete data for mongo

- Speeds up are incredible Executed 1695 of 1713 specs INCOMPLETE (18 PENDING) in 4 mins 19 secs.

* Adds documentation about the deleteEverything
2018-07-03 11:13:08 -04:00
Florent Vilmart
585938ca2c improves test performance on mongodb (#4862)
* improves test performance on mongodb

* Removes unused methdos
2018-06-29 17:09:51 -04:00
Manuel
1e29d0299b add support for geoWithin.centerSphere queries via withJSON (#4825)
* add support for geoWithin.centerSphere queries via withJSON

* added test for passing array of lat, lng instead of Parse.GeoPoint

* added postgres support

* added more tests

* improved tests and validation

* added more tests
2018-06-12 12:41:02 -04:00
Arthur Cinader
e06471603f Don't error when attempting to sort on an object field (#4806)
* add failing test to demonstrate that you can't sort on a
field in an object.

* Only validate the base of the field name.

* fix test name

* Only test sort for mongo.

* pg order by nested object

* level 2 test

* Factor out operation to get a field's base name.  Add comment.

* tweak comment wording so it wont make my grammar teacher angry.
2018-06-07 18:47:18 -04:00
Jaeger
cf3a872e67 Don't merge JSON fields after save() when using Postgres to keep same behaviour as MongoDB (#4808) (#4815) 2018-06-07 12:43:54 -04:00
Mads Bjerre
57da2def1d Adds withinPolygon support for Polygon object (#4067)
* Whitespace

* Add Polygon type to $polygon query

* Add tests

Polygon object in $polygon query
$geoIntersects queries

* Refactor

* Postgres support

* More tests

* Remove duplicate test

* Missing semicolon

* fix tests
2018-05-22 12:06:43 -04:00
Jérémy Piednoel
77ed10f57b Adding $nor operator support (#4768)
* adding nor to specialQuerykeys

* adding nor suport

* adding test

* CRLF

* adding postgres NOR

* adding nor validation

* adding NOR test

* adding test amd fixing NOR cases

* revert the nor logic
2018-05-18 14:26:33 -05:00
Jérémy Piednoel
c0f86ae1d1 Adding Mongodb element to add arrayMatches the #4762 (#4766)
* Adding elemMatch and nor

* lint

* adding test

* adding edge test

* postgres support

* clean up

* empty test
2018-05-18 08:35:50 -05:00
Eduard Bosch Bertran
c0e3672e32 New query condition support to match all strings that starts with some other given strings (#3864)
* feat: Convert $regex value to RegExp object

* feat: Add lib folder

* Revert "feat: Add lib folder"

This reverts commit c9dfbcbf699ff220baeb2df5586a944d19808e5e.

* feat: Add $regex test in $all array

* test: Test regex with $all only in MongoDB

* Revert "test: Test regex with $all only in MongoDB"

This reverts commit d7194c7869dee98d924fbc2502593a198385dba1.

* feat: Add tests for containsAllStartingWith

* feat: Add postgres support

Thanks to @dplewis

* feat: Check that all values in $all must be regex or none

* test: Check that $all vaules must be regex or none

* feat: Update tests to use only REST API

* refactor: Move $all regex check to adapter

* feat: Check for valid $all values in progres

* refactor: Update function name

* fix:  Postgres $all values regex checking

* fix: Check starts with as string

* fix: Define contains all regex sql function

* fix: Wrong value check

* fix: Check valid data

* fix: Check regex when there is only one value

* fix: Constains all starting with string returns empty with bad params

* fix: Pass correct regex value

* feat: Add missing tests

* feat: Add missing tests

* feat: Add more tests

* fix: Unify MongoDB and PostgreSQL functionality

* fix: Lint checks

* fix: Test broken

$regex in $all list must be { $regex: "string" }

* test for empty $all
2018-05-15 20:42:32 -05:00
Florent Vilmart
fad7b46c65 chore: Fixes issue related to flow types (#4724)
* Fixes issue related to flow types

* Improves type inference on where clause, index

* run parse-server start on liveQueryServer only on mongo, state leaks on postgres
2018-05-01 07:37:38 -04:00
Diamond Lewis
710848938f PG: Fixes issues comparing to zero or false (#4667)
* initial test

* more test

* clean up

* added correct errors

* test fix

* $eq null test

* type check
2018-03-24 17:45:34 -05:00
Diamond Lewis
143b0f01cf PG: Add dates to group aggregate (#4549)
* PG: Add dates to group aggregate

* returns dates as UTC
2018-02-16 12:41:02 -06:00
Diamond Lewis
848a6cf7ae Distinct support for null (#4559)
* distinct support for null

* better testing
2018-02-16 10:44:42 -05:00
Tyson Andre
83a0d7b685 Fix "undefined property '__op'" in postgres update (#4541)
* Fix "undefined property '__op'" in postgres update

This causes a TypeError which becomes a regular Error,
before the update can be issued. (I think)

This happens when there is an object schema,
and there is also an unrelated field in originalUpdate
which is null or undefined.

e.g. when 'location' is a mandatory object in postgres,
and 'middleName' is an optional string,
PostgresStorageAdapter would throw when a query similar
to the below was performed:
(Object.keys(originalUpdate) would include "middleName" as a value of `k`)

    query.set('location', {'country': 'US'})
    query.set('middleName', undefined);

* Fix lint error
2018-02-07 08:16:54 -05:00
Diamond Lewis
64e568d000 Improved match aggregate (#4495)
* Improve aggregate queries

* using pg-promise query formatting

* match multiple comparison

* $or and complex match
2018-01-20 08:00:36 -06:00
Diamond Lewis
8ec07b83d0 Support pointer in aggregate query (#4493) 2018-01-08 20:42:08 -06:00
Paulo Reis
cb8f038ca8 #4338 pg schema upgrade (#4375)
* Method to upgrade schemas in Postgres;

Adds:
  - schemaUpgrade method which check the fields to add and delete from old schema;

* Remove the columns delete in schemaUpgrade method;

* ESLint fix and PostgresStorageAdapter.schemaUpgrade spec test

Adds:
  - Add PostgresStorageAdapter.schemaUpgrade spec tests: creates a table,
    simulates the addition of a new field and checks if its present in the database
Chores:
  - ESLint eol-last fix;

* Add check columns before and after schema upgrade, and remove the unnecessary piece of code

Add:
  - Check the right columns is present before schema upgrade and the new field is not,
    then check if the right columns is present and the new field;
Remove:
  - Piece of code unnecessary because it not need to remove diff columns;

* Optimize the schemaUpgrade method following @vitaly-t instructions, and more tests;

* If the class does not have any columns and needs an upgrade the code would
return without doing so. Fixed this.

Chore:
  - Allows class with no column to be upgraded;
  - Test for class with no columns being upgraded;

* Update PostgresStorageAdapter.js

rewriting method schemaUpgrade

* Update PostgresStorageAdapter.spec.js

* Update PostgresStorageAdapter.spec.js
2018-01-03 03:23:05 +00:00
Vitaly Tomilov
fc6a2fddc4 New Year cosmetics :) (#4475)
* cosmetics

* making nicer promise pattern + if->else blocks
* removing return if unwanted data from an `UPDATE`

* Update PostgresStorageAdapter.js

* Update PostgresStorageAdapter.js

* Update PostgresStorageAdapter.js

Restoring the `UPDATE` result, as apparently it is in fact used. Ouch! 😄

* Update PostgresStorageAdapter.js
2018-01-01 20:33:41 +00:00
Florent Vilmart
10631371e6 Introduces flow types for storage (#4349)
* Introduces flow types for storage

* Better typing of QueryOptions

* Adds flow types to SchemaCOntroller,

- runs flow on pre tests
- fixes flow

* Adds ClassLevelPermissions type

* Moves Controller types into a single file

* Changes import styles

* Changes import styles

* fixing method setIndexesWithSchemaFormat (#4454)

Fixing invalid database code in method `setIndexesWithSchemaFormat`:

* It must be a transaction, not a task, as it executes multiple database changes
* It should contain the initial queries inside the transaction, providing the context, not outside it;
* Replaced the code with the ES6 Generator notation
* Removing the use of batch, as the value of the result promise is irrelevant, only success/failure that matters

* nits

* Fixes tests, improves flow typing
2017-12-30 20:44:18 -05:00
Diamond Lewis
6143988a82 Support pointer in distinct query (#4471)
* Support pointer in distinct query

* extract transform pointer string
2017-12-29 21:32:40 -06:00
Diamond Lewis
04f8673edd PG: Support for multiple projection in aggregate (#4469) 2017-12-29 17:39:16 +00:00
Vitaly Tomilov
6ba939994d consistent error throwing (#4470)
should use `throw` inside `.catch`.
2017-12-29 17:06:55 +00:00
Vitaly Tomilov
bb053301e5 refactoring method createClass (#4465)
* refactoring method createClass

Removing error-analysis conditions that are irrelevant, i.e. since we are only returning the batch, the error will always have `data` set to the size of the input array, as per [the library's API](http://vitaly-t.github.io/spex/errors.BatchError.html).

* Update PostgresStorageAdapter.js

removing the use of the default separator.
2017-12-28 01:43:34 +00:00
Vitaly Tomilov
7bb9c6da59 refactoring deleteAllClasses (#4464)
* refactoring deleteAllClasses

...to re-use the connection.

* Update PostgresStorageAdapter.js

removing extra spaces.
2017-12-27 22:41:50 +00:00
Vitaly Tomilov
b4aca8afc9 Reuse connection in getAllClasses (#4463)
as per the title.
2017-12-27 20:44:11 +00:00
Vitaly Tomilov
5681b3f902 Refactoring method addFieldIfNotExists (#4461)
* Refactoring method `addFieldIfNotExists`

* Using ES6 Generators syntax
* Passing in the context into method `createClass`, to reuse the connection
* Extending method `createClass` to reuse connections

* Update PostgresStorageAdapter.js

forgot: extending method `createClass` to reuse the connection.

* Update PostgresStorageAdapter.js

fixing the re-throw logic.
2017-12-27 18:14:15 +00:00
Vitaly Tomilov
820ae2b894 Better connection use in setClassLevelPermissions (#4460)
Method `setClassLevelPermissions` should use `.task` to share the connection for the two consecutive operations. It doesn't need a transaction, because the first operation does not need to roll back when the second one fails.
2017-12-27 00:30:50 +00:00
Vitaly Tomilov
a868beda93 Refactoring method createTable (#4456)
* Refactoring method createTable

Replacing the weird task + transaction chain, by replacing it with just one transaction that encapsulates the complete logic.

* Update PostgresStorageAdapter.js

correcting the sequence to match the original exactly.

* Update PostgresStorageAdapter.js

Nesting the transaction inside a task, so it can execute successfully no matter if the containing task succeeds or fails.

* Update PostgresStorageAdapter.js

adding the missing bracket.
2017-12-26 00:14:16 +00:00
Vitaly Tomilov
34453bff46 PostgreSQL performance optimization (#4457)
Performance-optimizing transactions to execute all non-result queries as a single operation.
2017-12-25 21:08:04 +00:00
Vitaly Tomilov
415ee3a1fd fixing method setIndexesWithSchemaFormat (#4454)
Fixing invalid database code in method `setIndexesWithSchemaFormat`:

* It must be a transaction, not a task, as it executes multiple database changes
* It should contain the initial queries inside the transaction, providing the context, not outside it;
* Replaced the code with the ES6 Generator notation
* Removing the use of batch, as the value of the result promise is irrelevant, only success/failure that matters
2017-12-24 19:03:35 +00:00
Vitaly Tomilov
a2b2f18927 db connection context fix (#4453)
fixing use of the wrong connection context inside a task
2017-12-24 17:56:23 +00:00
Vitaly Tomilov
e0a31d2aeb improving database logic. (#4451)
improving database logic.
2017-12-24 16:34:01 +00:00
Vitaly Tomilov
08ba738227 refactoring database code (#4448)
* refactoring database code

Starting to refactor the database code for better use of promises + ES6 generators, to prepare for ES7 await/async.

* Update PostgresStorageAdapter.js

* Update PostgresStorageAdapter.js

naming the transaction.
2017-12-24 15:58:20 +00:00
Vitaly Tomilov
9d1d8515fc pg-promise refactoring (#4401)
initial refactoring of `pg-promise` code.
2017-11-30 08:30:15 +07:00