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

Update database #339

Open
AlexIskander opened this Issue Oct 22, 2018 · 8 comments

Comments

4 participants
@AlexIskander

AlexIskander commented Oct 22, 2018

Good day.

Is it possible to make it so that when executing a PATCH query, the field is not overwritten in the database, but added to the end?

...

@felipeweb

This comment has been minimized.

Member

felipeweb commented Oct 22, 2018

@AlexIskander

This comment has been minimized.

AlexIskander commented Oct 23, 2018

For example, I have a table "test"

CREATE TABLE test (
test_id bigserial primary key,
test_name varchar(20) NOT NULL,
test_desc text NOT NULL,
date_added timestamp default NULL
);

Suppose in the field "test_desc" there is an entry "example", so here I want that when executing the query

curl -s -X PATCH -H "Content-type: application/json" -d '{"test_desc": "new text" }' 'http://127.0.0.1:8000/test_db/public/test?id=104'

in the "test_desc" field, the value of "example new text" has become

as does this sql query
UPDATE test SET test_desc = CONCAT(test_desc, ' ', 'some_new_str') WHERE id =104 ;

@felipeweb

This comment has been minimized.

Member

felipeweb commented Oct 23, 2018

@AlexIskander

This comment has been minimized.

AlexIskander commented Oct 23, 2018

not COUNT bat CONCAT

@felipeweb

This comment has been minimized.

Member

felipeweb commented Oct 23, 2018

sorry support COUNT, but not CONCAT

@avelino

This comment has been minimized.

Member

avelino commented Oct 23, 2018

@AlexIskander you propose some REST signature for CONCAT?
COUNT example:
https://postgres.rest/query-statements/#select-get

@AlexIskander

This comment has been minimized.

AlexIskander commented Oct 23, 2018

Are you understand difference between COUNT and CONCAT?

@fabriziomello

This comment has been minimized.

Contributor

fabriziomello commented Oct 23, 2018

@AlexIskander unfortunately we don't have the behavior you want, but you can use sql scripts instead. Look at https://postgres.rest/executing-sql-scripts/

Thinking more about your doubt I don't know if it's feasible to implement it because in your example you're consjuder just string datatypes, but what if we need to "concat" numeric, date, time, interval, or others datatypes ?? If so we'll need to implement a "concat" behavior for each kind of target datatype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment