mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
Only support extracting JSON fields when the SDK supports it (#3717)
* Added preprocessor defined to detect support for JSON * Only support extracting JSON fields when the SDK supports it * Fix version comparison
This commit is contained in:
@@ -128,12 +128,16 @@ bool Extractor::extract(std::size_t pos, std::string& val)
|
||||
|
||||
//mysql reports TEXT types as FDT_BLOB when being extracted
|
||||
MetaColumn::ColumnDataType columnType = _metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type();
|
||||
#ifdef POCO_MYSQL_JSON
|
||||
if (columnType != Poco::Data::MetaColumn::FDT_STRING && columnType != Poco::Data::MetaColumn::FDT_BLOB && columnType != Poco::Data::MetaColumn::FDT_JSON)
|
||||
#else
|
||||
if (columnType != Poco::Data::MetaColumn::FDT_STRING && columnType != Poco::Data::MetaColumn::FDT_BLOB)
|
||||
#endif
|
||||
throw MySQLException("Extractor: not a string");
|
||||
|
||||
#ifdef POCO_MYSQL_JSON
|
||||
if (columnType == Poco::Data::MetaColumn::FDT_JSON && !extractJSON(pos))
|
||||
return false;
|
||||
|
||||
#endif
|
||||
if (columnType == Poco::Data::MetaColumn::FDT_BLOB && !extractLongLOB(pos))
|
||||
return false;
|
||||
|
||||
@@ -291,6 +295,7 @@ bool Extractor::extractLongLOB(std::size_t pos)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef POCO_MYSQL_JSON
|
||||
bool Extractor::extractJSON(std::size_t pos)
|
||||
{
|
||||
// JSON columns are fetched with a zero-length
|
||||
@@ -306,6 +311,7 @@ bool Extractor::extractJSON(std::size_t pos)
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////
|
||||
// Not implemented
|
||||
|
||||
@@ -72,7 +72,9 @@ namespace
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
#ifdef POCO_MYSQL_JSON
|
||||
case MYSQL_TYPE_JSON:
|
||||
#endif
|
||||
return field.length;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user