fixup object creation queries
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
0e54ec12ba
commit
12411f4299
3 changed files with 8 additions and 7 deletions
|
|
@ -25,9 +25,9 @@ IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project, char c
|
|||
"failed to create blueprint: {}",
|
||||
IkarusErrorInfo_Database_QueryFailed,
|
||||
project->db->transact([name](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Blueprint, name, ""));
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`) VALUES(?)", IkarusObjectType_Blueprint));
|
||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Blueprint);
|
||||
TRY(db->execute("INSERT INTO `blueprints`(`id`) VALUES(?)", id));
|
||||
TRY(db->execute("INSERT INTO `blueprints`(`id`, `name`) VALUES(?, ?)", id, name));
|
||||
return cppbase::ok(id);
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char const *
|
|||
"failed to create entity: {}",
|
||||
IkarusErrorInfo_Database_QueryFailed,
|
||||
project->db->transact([name](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`) VALUES(?, ?, ?)", IkarusObjectType_Entity));
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`) VALUES(?)", IkarusObjectType_Entity));
|
||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Entity);
|
||||
TRY(db->execute("INSERT INTO `entities`(`id`, `name`) VALUES(?)", id, name));
|
||||
TRY(db->execute("INSERT INTO `entities`(`id`, `name`) VALUES(?, ?)", id, name));
|
||||
return cppbase::ok(id);
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -31,11 +31,12 @@ T * create_property(
|
|||
"failed to create property: {}",
|
||||
IkarusErrorInfo_Database_QueryFailed,
|
||||
project->db->transact([name, property_scope](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Property, name, ""));
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`) VALUES(?)", IkarusObjectType_Property));
|
||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Property);
|
||||
TRY(db->execute(
|
||||
"INSERT INTO `properties`(`id`, `type`, `source`) VALUES(?, ?, ?)",
|
||||
"INSERT INTO `properties`(`id`, `name`, `type`, `source`) VALUES(?, ?, ?, ?)",
|
||||
id,
|
||||
name,
|
||||
T::PropertyType,
|
||||
property_scope->get_id()
|
||||
));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue