Skip to content
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

Deserilization to type String #4

Open
quijos12 opened this issue Feb 7, 2022 · 1 comment
Open

Deserilization to type String #4

quijos12 opened this issue Feb 7, 2022 · 1 comment

Comments

@quijos12
Copy link

quijos12 commented Feb 7, 2022

I have added the column 'created' to the table 'AppUser' in the example-postgresql

CREATE TABLE IF NOT EXISTS AppUser (
    id                      varchar (256) PRIMARY KEY,
    username                varchar (256) NOT NULL,
    email                   varchar (256) NOT NULL,
    password                varchar (256) NOT NULL,
    role                    varchar (256) NULL,
    created                 timestamp DEFAULT now(), -- NEW COLUMN --
    CONSTRAINT              UK_APPUSER_USERNAME UNIQUE (username),
    CONSTRAINT              UK_APPUSER_EMAIL UNIQUE (email)
);

I have modified 'UserDto.hpp' to add the field as String DTO_FIELD(String, created, "created");

but when I try to test the endpoint of getUserById to select some user, I get the following error

{
  "status": "ERROR",
  "code": 500,
  "message": "[oatpp::postgresql::mapping::Deserializer::deserializeString()]: Error. Unknown OID."
}

as I understand from the error message I have to perform a conversion type to take the timestamp value to string

How can I do this?

@lganzzzo
Copy link
Member

lganzzzo commented Feb 7, 2022

Hello @quijos12 ,

You have to cast timestamp to string on PostgreSQL side, before returning DB result.

Please see this StackOverflow answer - https://stackoverflow.com/questions/15990344/select-date-timestamp-from-postgresql-as-string-char-beware-of-null-value

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

No branches or pull requests

2 participants