Updating rows kinda works.
Blocking calls are still used.
This commit is contained in:
parent
99d738ee65
commit
628c16e2f4
10 changed files with 179 additions and 81 deletions
|
|
@ -16,9 +16,12 @@ namespace Pgsql {
|
|||
*/
|
||||
class Value {
|
||||
public:
|
||||
const char *empty_str = "";
|
||||
Value(const char *val, Oid typ);
|
||||
QString asQString() const;
|
||||
const char* c_str() const { return m_val; }
|
||||
|
||||
bool null() const { return m_val == nullptr; }
|
||||
const char* c_str() const { return m_val == nullptr ? empty_str : m_val; }
|
||||
|
||||
operator QString() const;
|
||||
operator QDateTime() const;
|
||||
|
|
@ -42,25 +45,31 @@ namespace Pgsql {
|
|||
template <typename E, typename I>
|
||||
void getAsArray(I insert_iter, NullHandling nullhandling = NullHandling::Throw) const
|
||||
{
|
||||
using value_type = E;
|
||||
ArrayParser parser(m_val);
|
||||
for (;;) {
|
||||
auto res = parser.GetNextElem();
|
||||
if (res.ok) {
|
||||
if (res.value) {
|
||||
std::string str(res.value->data(), res.value->length());
|
||||
Value val(str.c_str(), OidFor<E>::elem());
|
||||
value_type v;
|
||||
v << val;
|
||||
insert_iter = v;
|
||||
}
|
||||
else {
|
||||
if (nullhandling == NullHandling::Throw)
|
||||
throw std::runtime_error("Unexpected NULL value in array");
|
||||
if (m_val == nullptr) {
|
||||
if (nullhandling == NullHandling::Throw)
|
||||
throw std::runtime_error("Unexpected NULL value in array");
|
||||
}
|
||||
else {
|
||||
using value_type = E;
|
||||
ArrayParser parser(m_val);
|
||||
for (;;) {
|
||||
auto res = parser.GetNextElem();
|
||||
if (res.ok) {
|
||||
if (res.value) {
|
||||
std::string str(res.value->data(), res.value->length());
|
||||
Value val(str.c_str(), OidFor<E>::elem());
|
||||
value_type v;
|
||||
v << val;
|
||||
insert_iter = v;
|
||||
}
|
||||
else {
|
||||
if (nullhandling == NullHandling::Throw)
|
||||
throw std::runtime_error("Unexpected NULL value in array");
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue