Wolfgang Walther
425ab70ec7
fix: Make UPSERT work with PostgreSQL 15
...
Signed-off-by: Wolfgang Walther <walther@technowledgy.de >
2022-10-28 16:18:42 +02:00
Wolfgang Walther and Wolfgang Walther
2289defe4b
refactor: Use stronger typing for SelectItem parser
...
Signed-off-by: Wolfgang Walther <walther@technowledgy.de >
2022-10-27 21:54:44 +02:00
steve-chavez
5d126bf0a3
refactor: all aliasing in addRels
2022-10-27 13:49:53 -05:00
steve-chavez
c8b39c6cde
refactor: aliasing logic to addRels
...
* also shorten query builder alias logic
2022-10-19 19:49:43 -05:00
steve-chavez
5f5a0c7764
refactor: simplify join conditions logic
2022-10-19 19:49:43 -05:00
steve-chavez
922da4520f
refactor: clarify ReadPlan fields
2022-10-19 19:49:43 -05:00
Steve Chavez and GitHub
0fbb116dd2
add basic ARCHITECTURE.md ( #2503 )
...
* refactor: move ApiRequest a top-level module
* refactor: rename DbStructure to SchemaCache
* refactor: GucHeader inside Response
* refactor: admin app to Workers
2022-10-10 11:24:45 -05:00
steve-chavez
e4b98d51be
fix: resource embedding opens empty transaction
...
This required untangling logic from App.hs.
Building/rejecting a plan no longer consumes a pool connection.
* Added io test for failed resource embedding not consuming connection
* optionalrollback to Query.hs and Response.hs
* delete Middleware module
* remove plan logic from App.hs
* remove RequestContext
* remove pkCols logic from App.hs
* remove proc logic from App.hs
* remove config logic from handleRequest
2022-10-07 18:52:57 -05:00
steve-chavez
6398dd2b32
refactor: add plan module
...
* rename/add plan dirs
* add read plan func/data
* add call plan func/data
* add mutate plan func/data
2022-10-04 16:13:34 -05:00
steve-chavez
11385bbd9f
refactor: move binaryField to ApiRequest
2022-10-01 11:05:49 -05:00
steve-chavez
f54dc2e20e
refactor: runPgLocals to Query.hs
...
* unmmiddleware runPgLocals
2022-09-26 17:28:08 -05:00
steve-chavez
92e28bd902
refactor: untangle query logic from response logic
...
* untangle failNotSingular
* untangle failsChangesOffLimits
* untangle readTotal
2022-09-25 13:53:11 -05:00
steve-chavez
c27e7be028
refactor: move guc headers/status decoding to App
2022-09-25 13:53:11 -05:00
Robert Vollmert
38ecaa44db
encode json body in binary, using modified hasql dep
...
- switch from "unknown" parameter in text format to a "json" parameter in
binary format (no dependency update required)
- use a lazy bytestring "json" encoder (via updated hasql)
2022-09-19 20:49:11 +02:00
steve-chavez
c45e85c5a6
feat: add one to one relationship for embedding
...
BREAKING CHANGE: For the cases where one to one relationships are
detected, json objects will be returned instead of json arrays of length
1.
If you wish to override this behavior, you can use computed
relationships to return arrays again.
2022-08-18 22:36:47 -05:00
steve-chavez
d6ec171bcb
feat: add computed relationships
...
* work for select, mutations, rpc
* overrides detected relationships
2022-08-17 22:50:06 -05:00
steve-chavez
06c9e246f4
refactor: simplify addJoinConditions
...
* remove unnecessary Either
* remove implicitJoins from ReadQuery
* remove unnecessary foldr in addJoinConditions
* move aliasing to addRels
2022-08-17 22:50:06 -05:00
Laurence Isla and GitHub
7de8d5446a
Revert bulk update patch
...
- Revert patch #2311
- Keep the refactor done to qsFiltersRoot
- Keep the refactor done to the items tables
- Add tests that now work with pg-safeupdate as a result
2022-08-12 10:00:33 -05:00
steve-chavez
3648986aa8
refactor: correlated subquery for o2m query
...
Improves the query costs a bit as shown in the tests and reduces code.
2022-08-06 21:42:53 -05:00
steve-chavez
fd7c23f7a1
Add "for" param for the vnd.pgrst.plan media type
2022-08-01 17:41:23 -05:00
Steve Chavez and GitHub
8911afd079
feat: Allow getting the EXPLAIN plan of a request
2022-07-27 19:33:34 -05:00
steve-chavez
c445105d55
correct query on rpc count=exact
...
corrects bad logic on e4006da(perf: remove toSourceRel)
2022-07-16 17:18:25 -05:00
Laurence Isla and GitHub
bdf1cbe111
fix: inaccurate result count when an inner embed is selected after a normal embed in the query string
2022-07-12 22:29:42 -05:00
steve-chavez
0708f46df3
refactor: pass media type to Statements module
2022-07-06 13:47:59 -05:00
Laurence Isla and GitHub
169547aee6
Return Location header only when using Prefer: return=header-only
2022-06-24 12:53:27 -05:00
Laurence Isla and GitHub
f7745e1569
fix: Allow schema names with special characters in the search path
...
Fixes regression where the search path did not recognize schemas with uppercase, spaces and other special characters in their names.
2022-06-23 18:54:43 -05:00
steve-chavez
870f7a39b0
Add PostGIS GeoJSON support
...
Works for GET, POST, PATCH, PUT, DELETE, RPC.
2022-06-22 22:16:44 -05:00
Robert Vollmert
f582798276
ReadQuery: split out to fix record field warning
...
The use of `where_` in DbRequestBuilder issues a warning since
GHC 9.2 as per
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0366-no-ambiguous-field-access.rst
To disambiguate that, move the type to a separate module and use
the record field names qualified. For symmetry, MutateQuery also
gets its own module.
2022-06-16 10:38:59 +02:00
Steve Chavez and GitHub
86574c89a8
Bulk update ( #2311 )
...
* refactor: remove EmbedPath type from qsFiltersRoot
* Rename reset items function for reusability
2022-06-15 20:30:31 -05:00
Franz-Josef Färber and Steve Chavez
5a3fbd7111
Allow returning XML from single-column queries
2022-05-04 10:27:28 -05:00
steve-chavez
e90391b7ac
limited update/delete requires explicit order
...
* limited update/delete now works on views with explicit order
* no default order, enforce order presence
* apply row count to ensure limited mutations
* move requiring order to ApiRequest
2022-05-02 11:12:02 -05:00
Franz-Josef Färber and Steve Chavez
d2aa50be52
Allow returning XML from RPCs
2022-04-26 17:37:59 -05:00
steve-chavez
e4006da9bc
perf: remove toSourceRel
...
toSourceRel is an expensive operation since it iterates over all the
relationships detected. We now use an alias on the CTE so embedding can
work without toSourceRel.
2022-04-25 21:41:51 -05:00
steve-chavez
d2719420f4
refactor: PKcols in table, ViewKeyDependency type
...
* Get PKcols inside tables - done with SQL for tables and
with an additional step in Haskell for views.
This fixes an fk column being considered as a pk column on views
and corrects the test added on
https://github.com/PostgREST/postgrest/pull/1875/files/1d549768580310e18aac4ffa6dbd01c5b77934a7#r853674126
* classify view key dependencies in SQL
* remove Column from Relationship
* Merge cols/fcols in Relationship and
ensure allM2ORels and allViewsKeyDependencies fk columns
are ordered - done by attnum in SQL
* Cardinality now contains relColumns instead of Relationship -
this simplifies getJoinConditions.
2022-04-21 14:44:45 -05:00
steve-chavez
7f1507b9fb
refactor: remove Table from Relationship
...
Just having the QualifiedIdentifier gets us closer to having
Relationship as a Table attribute since it avoids a cyclic dependency
* remove unnecessary findTable
* modify RootSpec test
2022-04-18 15:48:03 -05:00
Michael Kane Juncker and Wolfgang Walther
007f49a8bc
feat(query): add basic regular expression operator support - refs #2236
2022-04-11 08:33:16 +02:00
steve-chavez
331e88ea39
feat: add limited delete
2022-03-26 15:29:13 +01:00
steve-chavez
f4becf99ad
feat: add limited update
2022-03-26 15:29:13 +01:00
Wolfgang Walther and Wolfgang Walther
9f1b5c0a81
feat: Support accessing array items and fields of composite types through json operators
...
This is supported in select=, in filters and in order=.
Resolves #1543
Resolves #2075
Signed-off-by: Wolfgang Walther <walther@technowledgy.de >
2022-02-03 08:13:38 +01:00
Wolfgang Walther and Wolfgang Walther
8a722e2cfe
refactor: Replace elem with pattern matching to highlight missing code coverage
...
Signed-off-by: Wolfgang Walther <walther@technowledgy.de >
2022-01-28 19:26:33 +01:00
monacoremo and Wolfgang Walther
bfbec8fa36
refactor: Carve out QueryParams module
2022-01-07 09:32:33 +01:00
Wolfgang Walther and Wolfgang Walther
c581148f1b
refactor: Make asJsonSingleF "safe", by accessing only the first element of a json_agg result
2021-12-01 09:19:47 +01:00
steve-chavez
132ecd8d74
Correct count query when doing inner joins
2021-11-26 10:39:19 -05:00
Wolfgang Walther and Wolfgang Walther
a65ac9b0f6
feat: drop support for pg 9.5
2021-11-24 19:42:53 +01:00
steve-chavez
1b48531369
remove the db-embed-default-join config
2021-11-23 12:32:51 -05:00
steve-chavez
bf58a3600a
refactor: remove pgFmtLit
2021-11-18 17:01:58 -05:00
steve-chavez
bae5afbad6
feat: allow unknown on the is operator
...
Also make the IS values strict at the Parser level since IS cannot be
parametrized.
2021-11-18 17:01:58 -05:00
monacoremo
3820590649
refactor: Remove Protolude.Conv from SqlFragment
2021-11-12 20:25:22 +01:00
monacoremo
ebe66cb985
refactor: Remove Protolude.Conv from Statements
2021-11-12 20:25:22 +01:00
monacoremo
cd3013569e
refactor: Remove GHC.Show instances from QualifiedIdentifier and Config
2021-11-09 19:13:52 +01:00