Skip to content

Not recognize utils::datetime::Date as PostgreSQL date #886

@onpat

Description

@onpat

Hi, I am using userver with PostgreSQL.

I made a table which consist of two fields, username(string) and birthday(date).
and tried this line:

auto res = transaction.Execute(kInsertRecord, "uname", userver::utils::datetime::Date(2000, 02, 03));

but I got this error at compile time:

/home/user/pg_service_template/src/test/user-register.cpp:364:35: required from here
/home/user/pg_service_template/third_party/userver/postgresql/include/userver/storages/postgres/detail/query_parameters.hpp:64:52: error: static assertion failed: Type doesn't have mapping to Postgres type.
64 | static_assert(io::traits::kIsMappedToPg || std::is_enum_v, "Type doesn't have mapping to Postgres type.");

/home/user/pg_service_template/third_party/userver/postgresql/include/userver/storages/postgres/detail/query_parameters.hpp:64:52: note: ‘(((bool)userver::v2_7_rc::storages::postgres::io::traits::kIsMappedToPguserver::v2_7_rc::utils::datetime::Date) || ((bool)std::is_enum_vuserver::v2_7_rc::utils::datetime::Date))’ evaluates to false
ninja: build stopped: subcommand failed.
make: *** [Makefile:32: build-debug] Error 1`

However, this document states utils::datetime::Date as date type.
https://userver.tech/dd/dad/md_en_2userver_2pg__types.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions