}
}
+void
+PgSqlExchange::getColumnValue(const PgSqlResult& r, const int row,
+ const size_t col, boost::posix_time::ptime& value) {
+ std::string db_time_val;
+ PgSqlExchange::getColumnValue(r, row, col, db_time_val );
+ PgSqlExchange::convertFromDatabaseTime(db_time_val, value);
+}
+
isc::asiolink::IOAddress
PgSqlExchange::getIPv6Value(const PgSqlResult& r, const int row,
const size_t col) {
-// Copyright (C) 2016-2018,2021 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
}
}
+ /// @brief Fetches a timestamp column as a ptime.
+ ///
+ /// @param r the result set containing the query results
+ /// @param row the row number within the result set
+ /// @param col the column number within the row
+ /// @param[out] value ptime parameter to receive the converted timestamp
+ ///
+ /// @throw DbOperationError if the value cannot be fetched or is
+ /// invalid.
+ static void getColumnValue(const PgSqlResult& r, const int row,
+ const size_t col, boost::posix_time::ptime& value);
+
/// @brief Converts a column in a row in a result set to a binary bytes
///
/// Method is used to convert columns stored as BYTEA into a buffer of
// Verify we cannot add a v6 address.
Optional<asiolink::IOAddress> not_v4(asiolink::IOAddress("3001::1"));
- ASSERT_THROW_MSG(b.addOptionalIPv4Address(not_v4), BadValue,
+ ASSERT_THROW_MSG(b.addOptionalIPv4Address(not_v4), BadValue,
"unable to add address to PsqlBindAray"
" '3001::1' is not an IPv4 address");
// Fetch the newly inserted row.
FETCH_ROWS(r, 1);
- // Fetch the timestamp column
+ // Timestamp column should not be null.
ASSERT_FALSE(PgSqlExchange::isColumnNull(*r, 0, TIMESTAMP_COL));
- std::string timestamp_str = "";
- ASSERT_NO_THROW(PgSqlExchange::getColumnValue(*r, 0, TIMESTAMP_COL,
- timestamp_str));
- // Convert fetched values into a ptime.
+ // Convert fetched value into a ptime.
ptime fetched_time;
- ASSERT_NO_THROW(PgSqlExchange::convertFromDatabaseTime(timestamp_str, fetched_time));
+ ASSERT_NO_THROW_LOG(PgSqlExchange::getColumnValue(*r, 0, TIMESTAMP_COL,
ASSERT_EQ(fetched_time, nice_day);
}