Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 27031df

Browse files
Merge pull request #29 from bwengert79/contribute
Issue #24 - insert DTO type ENUM as string
2 parents c175890 + cb2cb29 commit 27031df

30 files changed

+592
-289
lines changed

‎CMakeLists.txt‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.20)
22

33
###################################################################################################
44
## These variables are passed to oatpp-module-install.cmake script
55
## use these variables to configure module installation
66

77
set(OATPP_THIS_MODULE_NAME oatpp-postgresql) ## name of the module (also name of folders in installation dirs)
8-
set(OATPP_THIS_MODULE_VERSION "1.3.0") ## version of the module (also sufix of folders in installation dirs)
8+
set(OATPP_THIS_MODULE_VERSION "1.4.0") ## version of the module (also sufix of folders in installation dirs)
99
set(OATPP_THIS_MODULE_LIBRARIES oatpp-postgresql) ## list of libraries to find when find_package is called
1010
set(OATPP_THIS_MODULE_TARGETS oatpp-postgresql) ## list of targets to install
1111
set(OATPP_THIS_MODULE_DIRECTORIES oatpp-postgresql) ## list of directories to install
@@ -92,6 +92,8 @@ endif()
9292
message("\n############################################################################")
9393
message("## ${OATPP_THIS_MODULE_NAME} module. Resolving dependencies...\n")
9494

95+
set(PostgreSQL_ADDITIONAL_VERSIONS "17")
96+
9597
find_package(PostgreSQL REQUIRED)
9698

9799
message("PostgreSQL_INCLUDE_DIRS=${PostgreSQL_INCLUDE_DIRS}")

‎azure-pipelines.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
clean: all
1414
steps:
1515
- script: |
16-
docker-compose build
16+
dockercompose build
1717
displayName: 'Compose build'
1818
- script: |
19-
docker-compose run test
19+
dockercompose run test
2020
displayName: 'Compose run'

‎src/oatpp-postgresql/Connection.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#define oatpp_postgresql_Connection_hpp
2727

2828
#include "oatpp/orm/Connection.hpp"
29-
#include "oatpp/core/provider/Pool.hpp"
30-
#include "oatpp/core/Types.hpp"
29+
#include "oatpp/provider/Pool.hpp"
30+
#include "oatpp/Types.hpp"
3131

3232
#include <libpq-fe.h>
3333

‎src/oatpp-postgresql/ConnectionProvider.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
#include "Connection.hpp"
2929

30-
#include "oatpp/core/provider/Pool.hpp"
31-
#include "oatpp/core/Types.hpp"
30+
#include "oatpp/provider/Pool.hpp"
31+
#include "oatpp/Types.hpp"
3232

3333
namespace oatpp { namespace postgresql {
3434

‎src/oatpp-postgresql/Executor.cpp‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131

3232
#include "oatpp/orm/Transaction.hpp"
3333

34-
#include "oatpp/core/macro/codegen.hpp"
34+
#include "oatpp/macro/codegen.hpp"
35+
36+
#include "oatpp/base/Log.hpp"
3537

3638
#include <vector>
3739

@@ -152,7 +154,7 @@ std::shared_ptr<data::mapping::TypeResolver> Executor::createTypeResolver() {
152154

153155
Executor::QueryParameter Executor::parseQueryParameter(const oatpp::String& paramName) {
154156

155-
parser::Caret caret(paramName);
157+
utils::parser::Caret caret(paramName);
156158
auto nameLabel = caret.putLabel();
157159
if(caret.findChar('.') && caret.getPosition() < caret.getDataSize() - 1) {
158160

@@ -499,7 +501,7 @@ void Executor::migrateSchema(const oatpp::String& script,
499501
}
500502

501503
if(script->size() == 0) {
502-
OATPP_LOGW("[oatpp::postgresql::Executor::migrateSchema()]", "Warning. Executing empty script for version %d", newVersion);
504+
OATPP_LOGw("[oatpp::postgresql::Executor::migrateSchema()]", "Warning. Executing empty script for version {}", newVersion);
503505
}
504506

505507
{
@@ -510,16 +512,16 @@ void Executor::migrateSchema(const oatpp::String& script,
510512

511513
result = exec(script, connection);
512514
if(!result->isSuccess()) {
513-
OATPP_LOGE("[oatpp::postgresql::Executor::migrateSchema()]",
514-
"Error. Migration failed for version %d. %s", newVersion, result->getErrorMessage()->c_str());
515+
OATPP_LOGe("[oatpp::postgresql::Executor::migrateSchema()]",
516+
"Error. Migration failed for version {}. {}", newVersion, result->getErrorMessage()->c_str());
515517
throw std::runtime_error("[oatpp::postgresql::Executor::migrateSchema()]: "
516518
"Error. Migration failed. " + *result->getErrorMessage());
517519

518520
}
519521

520522
result = updateSchemaVersion(newVersion, suffix, connection);
521523

522-
if(!result->isSuccess() || result->hasMoreToFetch() > 0) {
524+
if(!result->isSuccess() || result->hasMoreToFetch()) {
523525
throw std::runtime_error("[oatpp::postgresql::Executor::migrateSchema()]: Error. Migration failed. Can't set new version.");
524526
}
525527

‎src/oatpp-postgresql/Executor.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "Types.hpp"
3434

3535
#include "oatpp/orm/Executor.hpp"
36-
#include "oatpp/core/parser/Caret.hpp"
36+
#include "oatpp/utils/parser/Caret.hpp"
3737

3838
#include <vector>
3939

‎src/oatpp-postgresql/Types.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace oatpp { namespace postgresql {
3232
/**
3333
* Uuid as oatpp primitive type.
3434
*/
35-
typedef oatpp::data::mapping::type::Primitive<mapping::type::UuidObject, mapping::type::__class::Uuid> Uuid;
35+
typedef oatpp::data::type::Primitive<mapping::type::UuidObject, mapping::type::__class::Uuid> Uuid;
3636

3737
}}
3838

‎src/oatpp-postgresql/mapping/Deserializer.cpp‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,44 +41,44 @@ Deserializer::InData::InData(PGresult* dbres, int row, int col, const std::share
4141

4242
Deserializer::Deserializer() {
4343

44-
m_methods.resize(data::mapping::type::ClassId::getClassCount(), nullptr);
44+
m_methods.resize(data::type::ClassId::getClassCount(), nullptr);
4545

46-
setDeserializerMethod(data::mapping::type::__class::String::CLASS_ID, &Deserializer::deserializeString);
47-
setDeserializerMethod(data::mapping::type::__class::Any::CLASS_ID, &Deserializer::deserializeAny);
46+
setDeserializerMethod(data::type::__class::String::CLASS_ID, &Deserializer::deserializeString);
47+
setDeserializerMethod(data::type::__class::Any::CLASS_ID, &Deserializer::deserializeAny);
4848

49-
setDeserializerMethod(data::mapping::type::__class::Int8::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int8>);
50-
setDeserializerMethod(data::mapping::type::__class::UInt8::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt8>);
49+
setDeserializerMethod(data::type::__class::Int8::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int8>);
50+
setDeserializerMethod(data::type::__class::UInt8::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt8>);
5151

52-
setDeserializerMethod(data::mapping::type::__class::Int16::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int16>);
53-
setDeserializerMethod(data::mapping::type::__class::UInt16::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt16>);
52+
setDeserializerMethod(data::type::__class::Int16::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int16>);
53+
setDeserializerMethod(data::type::__class::UInt16::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt16>);
5454

55-
setDeserializerMethod(data::mapping::type::__class::Int32::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int32>);
56-
setDeserializerMethod(data::mapping::type::__class::UInt32::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt32>);
55+
setDeserializerMethod(data::type::__class::Int32::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int32>);
56+
setDeserializerMethod(data::type::__class::UInt32::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt32>);
5757

58-
setDeserializerMethod(data::mapping::type::__class::Int64::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int64>);
59-
setDeserializerMethod(data::mapping::type::__class::UInt64::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt64>);
58+
setDeserializerMethod(data::type::__class::Int64::CLASS_ID, &Deserializer::deserializeInt<oatpp::Int64>);
59+
setDeserializerMethod(data::type::__class::UInt64::CLASS_ID, &Deserializer::deserializeInt<oatpp::UInt64>);
6060

61-
setDeserializerMethod(data::mapping::type::__class::Float32::CLASS_ID, &Deserializer::deserializeFloat32);
62-
setDeserializerMethod(data::mapping::type::__class::Float64::CLASS_ID, &Deserializer::deserializeFloat64);
63-
setDeserializerMethod(data::mapping::type::__class::Boolean::CLASS_ID, &Deserializer::deserializeBoolean);
61+
setDeserializerMethod(data::type::__class::Float32::CLASS_ID, &Deserializer::deserializeFloat32);
62+
setDeserializerMethod(data::type::__class::Float64::CLASS_ID, &Deserializer::deserializeFloat64);
63+
setDeserializerMethod(data::type::__class::Boolean::CLASS_ID, &Deserializer::deserializeBoolean);
6464

65-
setDeserializerMethod(data::mapping::type::__class::AbstractObject::CLASS_ID, nullptr);
66-
setDeserializerMethod(data::mapping::type::__class::AbstractEnum::CLASS_ID, &Deserializer::deserializeEnum);
65+
setDeserializerMethod(data::type::__class::AbstractObject::CLASS_ID, nullptr);
66+
setDeserializerMethod(data::type::__class::AbstractEnum::CLASS_ID, &Deserializer::deserializeEnum);
6767

68-
setDeserializerMethod(data::mapping::type::__class::AbstractVector::CLASS_ID, &Deserializer::deserializeArray);
69-
setDeserializerMethod(data::mapping::type::__class::AbstractList::CLASS_ID, &Deserializer::deserializeArray);
70-
setDeserializerMethod(data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID, &Deserializer::deserializeArray);
68+
setDeserializerMethod(data::type::__class::AbstractVector::CLASS_ID, &Deserializer::deserializeArray);
69+
setDeserializerMethod(data::type::__class::AbstractList::CLASS_ID, &Deserializer::deserializeArray);
70+
setDeserializerMethod(data::type::__class::AbstractUnorderedSet::CLASS_ID, &Deserializer::deserializeArray);
7171

72-
setDeserializerMethod(data::mapping::type::__class::AbstractPairList::CLASS_ID, nullptr);
73-
setDeserializerMethod(data::mapping::type::__class::AbstractUnorderedMap::CLASS_ID, nullptr);
72+
setDeserializerMethod(data::type::__class::AbstractPairList::CLASS_ID, nullptr);
73+
setDeserializerMethod(data::type::__class::AbstractUnorderedMap::CLASS_ID, nullptr);
7474

7575
////
7676

7777
setDeserializerMethod(postgresql::mapping::type::__class::Uuid::CLASS_ID, &Deserializer::deserializeUuid);
7878

7979
}
8080

81-
void Deserializer::setDeserializerMethod(const data::mapping::type::ClassId& classId, DeserializerMethod method) {
81+
void Deserializer::setDeserializerMethod(const data::type::ClassId& classId, DeserializerMethod method) {
8282
const v_uint32 id = classId.id;
8383
if(id >= m_methods.size()) {
8484
m_methods.resize(id + 1, nullptr);
@@ -235,21 +235,21 @@ oatpp::Void Deserializer::deserializeBoolean(const Deserializer* _this, const In
235235

236236
oatpp::Void Deserializer::deserializeEnum(const Deserializer* _this, const InData& data, const Type* type) {
237237

238-
auto polymorphicDispatcher = static_cast<const data::mapping::type::__class::AbstractEnum::PolymorphicDispatcher*>(
238+
auto polymorphicDispatcher = static_cast<const data::type::__class::AbstractEnum::PolymorphicDispatcher*>(
239239
type->polymorphicDispatcher
240240
);
241241

242-
data::mapping::type::EnumInterpreterError e = data::mapping::type::EnumInterpreterError::OK;
242+
data::type::EnumInterpreterError e = data::type::EnumInterpreterError::OK;
243243
const auto& value = _this->deserialize(data, polymorphicDispatcher->getInterpretationType());
244244

245-
const auto& result = polymorphicDispatcher->fromInterpretation(value, e);
245+
const auto& result = polymorphicDispatcher->fromInterpretation(value, false, e);
246246

247-
if(e == data::mapping::type::EnumInterpreterError::OK) {
247+
if(e == data::type::EnumInterpreterError::OK) {
248248
return result;
249249
}
250250

251251
switch(e) {
252-
case data::mapping::type::EnumInterpreterError::CONSTRAINT_NOT_NULL:
252+
case data::type::EnumInterpreterError::CONSTRAINT_NOT_NULL:
253253
throw std::runtime_error("[oatpp::postgresql::mapping::Deserializer::deserializeEnum()]: Error. Enum constraint violated - 'NotNull'.");
254254

255255
default:
@@ -315,7 +315,7 @@ oatpp::Void Deserializer::deserializeAny(const Deserializer* _this, const InData
315315
}
316316

317317
auto value = _this->deserialize(data, valueType);
318-
auto anyHandle = std::make_shared<data::mapping::type::AnyHandle>(value.getPtr(), value.getValueType());
318+
auto anyHandle = std::make_shared<data::type::AnyHandle>(value.getPtr(), value.getValueType());
319319

320320
return oatpp::Void(anyHandle, Any::Class::getType());
321321
}
@@ -343,7 +343,7 @@ oatpp::Void Deserializer::deserializeSubArray(const Type* type,
343343
"Error. Unknown collection type.");
344344
}
345345

346-
auto dispatcher = static_cast<const data::mapping::type::__class::Collection::PolymorphicDispatcher*>(type->polymorphicDispatcher);
346+
auto dispatcher = static_cast<const data::type::__class::Collection::PolymorphicDispatcher*>(type->polymorphicDispatcher);
347347
auto itemType = dispatcher->getItemType();
348348
auto collection = dispatcher->createObject();
349349

@@ -402,7 +402,7 @@ oatpp::Void Deserializer::deserializeArray(const Deserializer* _this, const InDa
402402

403403
auto ndim = (v_int32) ntohl(*((p_int32)data.data));
404404
if(ndim == 0) {
405-
auto dispatcher = static_cast<const data::mapping::type::__class::Collection::PolymorphicDispatcher*>(type->polymorphicDispatcher);
405+
auto dispatcher = static_cast<const data::type::__class::Collection::PolymorphicDispatcher*>(type->polymorphicDispatcher);
406406
return dispatcher->createObject(); // empty array
407407
}
408408

‎src/oatpp-postgresql/mapping/Deserializer.hpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
#include "PgArray.hpp"
3030

31-
#include "oatpp/core/data/stream/BufferStream.hpp"
32-
#include "oatpp/core/data/mapping/TypeResolver.hpp"
33-
#include "oatpp/core/Types.hpp"
31+
#include "oatpp/data/stream/BufferStream.hpp"
32+
#include "oatpp/data/mapping/TypeResolver.hpp"
33+
#include "oatpp/Types.hpp"
3434

3535
#include <libpq-fe.h>
3636

@@ -78,7 +78,7 @@ class Deserializer {
7878

7979
Deserializer();
8080

81-
void setDeserializerMethod(const data::mapping::type::ClassId& classId, DeserializerMethod method);
81+
void setDeserializerMethod(const data::type::ClassId& classId, DeserializerMethod method);
8282

8383
oatpp::Void deserialize(const InData& data, const Type* type) const;
8484

‎src/oatpp-postgresql/mapping/PgArray.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#ifndef oatpp_postgresql_mapping_PgArray_hpp
2727
#define oatpp_postgresql_mapping_PgArray_hpp
2828

29-
#include "oatpp/core/data/stream/Stream.hpp"
30-
#include "oatpp/core/Types.hpp"
29+
#include "oatpp/data/stream/Stream.hpp"
30+
#include "oatpp/Types.hpp"
3131

3232
#include <libpq-fe.h>
3333

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /