Skip to content

Commit

Permalink
Check if the keys are not null
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Sep 6, 2024
1 parent f601a43 commit 342af0b
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/parser/transform/statement/transform_create_property_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,41 @@ Transformer::TransformPropertyGraphTable(duckdb_libpgquery::PGPropertyGraphTable
pg_table->destination_reference = possible_dst_alias->second;
}

for (auto &src_key = graph_table->src_pk->head; src_key != nullptr; src_key = lnext(src_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(src_key->data.ptr_value);
pg_table->source_pk.emplace_back(key->val.str);
if (graph_table->src_pk) {
for (auto &src_key = graph_table->src_pk->head; src_key != nullptr; src_key = lnext(src_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(src_key->data.ptr_value);
pg_table->source_pk.emplace_back(key->val.str);
}
} else {
pg_table->source_pk.emplace_back(string());
}

for (auto &dst_key = graph_table->dst_pk->head; dst_key != nullptr; dst_key = lnext(dst_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(dst_key->data.ptr_value);
pg_table->destination_pk.emplace_back(key->val.str);
if (graph_table->dst_pk) {
for (auto &dst_key = graph_table->dst_pk->head; dst_key != nullptr; dst_key = lnext(dst_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(dst_key->data.ptr_value);
pg_table->destination_pk.emplace_back(key->val.str);
}
} else {
pg_table->destination_pk.emplace_back(string());
}

for (auto &src_key = graph_table->src_fk->head; src_key != nullptr; src_key = lnext(src_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(src_key->data.ptr_value);
pg_table->source_fk.emplace_back(key->val.str);

if (graph_table->src_fk) {
for (auto &src_key = graph_table->src_fk->head; src_key != nullptr; src_key = lnext(src_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(src_key->data.ptr_value);
pg_table->source_fk.emplace_back(key->val.str);
}
} else {
pg_table->source_fk.emplace_back(string());
}

for (auto &dst_key = graph_table->dst_fk->head; dst_key != nullptr; dst_key = lnext(dst_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(dst_key->data.ptr_value);
pg_table->destination_fk.emplace_back(key->val.str);
if (graph_table->dst_fk) {
for (auto &dst_key = graph_table->dst_fk->head; dst_key != nullptr; dst_key = lnext(dst_key)) {
auto key = reinterpret_cast<duckdb_libpgquery::PGValue *>(dst_key->data.ptr_value);
pg_table->destination_fk.emplace_back(key->val.str);
}
} else {
pg_table->destination_fk.emplace_back(string());
}
}
return pg_table;
Expand Down

0 comments on commit 342af0b

Please sign in to comment.