|
ImagingTools Core SDK
|
Database-specific JSON field extraction abstraction. More...
#include <ISqlJsonXPathExtractor.h>
Inherits istd::IPolymorphic.
Inherited by imtdb::CPostgresXPathExtractorComp [virtual], and imtdb::CSqliteXPathExtractorComp [virtual].
Public Member Functions | |
| virtual QString | ExtractXPath (const QString &jsonKey, const QString &fieldId, QMetaType::Type metaType=QMetaType::QString, const QString &tableAlias=QString()) const =0 |
| Extracts a JSON field using database-specific syntax. | |
Database-specific JSON field extraction abstraction.
ISqlJsonXPathExtractor provides a database-agnostic interface for extracting values from JSON/JSONB columns in SQL databases. Different databases use different syntax for JSON operations (PostgreSQL uses operators, SQLite uses functions), and this interface abstracts those differences.
Enables consistent JSON field access across database backends:
->, ->>, #> operators for JSONB columnsjson_extract(), json_type() functionsThe extractor is used internally by delegates to generate database-specific JSON queries in WHERE clauses and SELECT statements:
The fieldId parameter uses dot notation for nested fields:
"userName""address.city""tags[0]""user.address.coordinates.latitude"Definition at line 62 of file ISqlJsonXPathExtractor.h.
|
pure virtual |
Extracts a JSON field using database-specific syntax.
Generates the appropriate SQL expression to extract a value from a JSON column based on the target database's syntax.
| jsonKey | The name of the JSON/JSONB column in the table (e.g., "metadata", "dataMetaInfo") |
| fieldId | The path to the field within the JSON (e.g., "userName", "address.city", "tags[0]") |
| metaType | Expected Qt type of the extracted value (for type casting) |
| tableAlias | Optional table alias prefix (e.g., "t1" for "t1.metadata") |
Examples:
PostgreSQL:
SQLite: