Skip to content

PG: Fix updating numeric array #5251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 18, 2018
Merged

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Dec 18, 2018

Closes: #5239

@dplewis dplewis requested a review from flovilmart December 18, 2018 16:46
@codecov
Copy link

codecov bot commented Dec 18, 2018

Codecov Report

Merging #5251 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5251      +/-   ##
==========================================
- Coverage   93.88%   93.86%   -0.03%     
==========================================
  Files         123      123              
  Lines        8950     8953       +3     
==========================================
+ Hits         8403     8404       +1     
- Misses        547      549       +2
Impacted Files Coverage Δ
...dapters/Storage/Postgres/PostgresStorageAdapter.js 97.11% <100%> (-0.08%) ⬇️
src/RestWrite.js 93.06% <0%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c762ee4...8a5894b. Read the comment docs.

@flovilmart
Copy link
Contributor

@dplewis can you add tests for mixing text, object and numeric on updating objects?

@dplewis
Copy link
Member Author

dplewis commented Dec 18, 2018

I don't think that is supported in Postgres unless we add something like Composite Types

@vitaly-t Is it possible to have an array of multiple types in PG? I wrote a test case for it locally and it fails

@flovilmart
Copy link
Contributor

I wanted to check the failure indeed :)

@dplewis dplewis merged commit 7b3da8b into parse-community:master Dec 18, 2018
@dplewis dplewis deleted the pg-array-fix branch December 18, 2018 18:11
@vitaly-t
Copy link
Contributor

@dplewis From pg-promise side, it supports arrays with mixed types. When you use filter :csv, each value is formatted according to its JavaScript type. And the filter also respects Custom Type Formatting.

@dplewis
Copy link
Member Author

dplewis commented Dec 18, 2018

@vitaly-t Thanks, thats really helpful.

I tried to do something like

$${index}:name = json_build_array($${index + 1}:csv)

But objects are stored as text instead of json

{foo: 'bar'} => '{"foo": "bar"}'

Also is that filter recursive. Like if I have an array of array of mixed types?

@vitaly-t
Copy link
Contributor

vitaly-t commented Dec 18, 2018

But objects are stored as text instead of json

If you give me an example of what you are trying to achieve, I could come up with a usable example.

if I have an array of array of mixed types?

For an array of mixed types, each value that's a mixed type needs to implement Custom Type Formatting. And then it can be recursive also, via the same :csv filter.

UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
* PG: Fix updating numeric array

* lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants