Fixed Model Generation for PostgreSQL Primary Keys (#471)
As per definition Drogon should return the last ID after an insert when “a table contains an auto-increasing primary key”, but the current detection mechanism isn’t enough to catch all cases. PostgreSQL has the concept of generated identity columns that act as primary key columns, but this information is held in the "is_identity" column that wasn’t checked before. This commit fixes #410, and also detects generated identity columns as auto incrementing columns, so that the model generation correctly appends " returning " statements.
This commit is contained in:
parent
e7b7618c37
commit
9e959397af
|
@ -194,6 +194,10 @@ void create_model::createModelClassFromPG(
|
|||
info.isAutoVal_ = true;
|
||||
}
|
||||
}
|
||||
auto isIdentity = row["is_identity"].as<std::string>();
|
||||
if (isIdentity == "YES") {
|
||||
info.isAutoVal_ = true;
|
||||
}
|
||||
cols.push_back(std::move(info));
|
||||
}
|
||||
} >>
|
||||
|
|
Loading…
Reference in New Issue