fix various issues
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
f5eebbb474
commit
7b549824f0
12 changed files with 33 additions and 50 deletions
7
src/global.cpp
Normal file
7
src/global.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include "ikarus/global.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
void ikarus_free(void * ptr) {
|
||||
std::free(ptr);
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
#include "ikarus/id.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <ikarus/objects/object_type.h>
|
||||
|
||||
constexpr uint64_t IKARUS_ID_OBJECT_TYPE_BITS = 8;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ 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`) VALUES(?, ?, ?)", IkarusObjectType_Blueprint, name));
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Blueprint, name, ""));
|
||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Blueprint);
|
||||
TRY(db->execute("INSERT INTO `blueprints`(`id`) VALUES(?)", id));
|
||||
return cppbase::ok(id);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ 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`, `name`) VALUES(?, ?, ?)", IkarusObjectType_Entity, name));
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Entity, name, ""));
|
||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Entity);
|
||||
TRY(db->execute("INSERT INTO `entities`(`id`) VALUES(?)", id));
|
||||
return cppbase::ok(id);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ T * create_property(
|
|||
"failed to create property: {}",
|
||||
IkarusErrorInfo_Database_QueryFailed,
|
||||
project->db->transact([name, property_source](auto * db) -> cppbase::Result<IkarusId, sqlitecpp::TransactionError> {
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`) VALUES(?, ?, ?)", IkarusObjectType_Property, name));
|
||||
TRY(db->execute("INSERT INTO `objects`(`type`, `name`, `information`) VALUES(?, ?, ?)", IkarusObjectType_Property, name, ""));
|
||||
auto id = ikarus_id_from_data_and_type(db->last_insert_rowid(), IkarusObjectType_Property);
|
||||
TRY(db->execute(
|
||||
"INSERT INTO `properties`(`id`, `type`, `source`) VALUES(?, ?, ?)",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <sqlitecpp/connection.hpp>
|
||||
|
||||
namespace ikarus {
|
||||
CPPBASE_ASSET(m1_initial_layout, "persistence/migrations/m1_initial_layout.sql");
|
||||
CPPBASE_ASSET(m0_initial_layout, "persistence/migrations/m0_initial_layout.sql");
|
||||
|
||||
class Migration : public sqlitecpp::Migration {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
CREATE TABLE `metadata`
|
||||
(
|
||||
`key` VARCHAR(255) NOT NULL,
|
||||
`value` VARCHAR(255) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`key`)
|
||||
)
|
||||
|
|
@ -1,27 +1,22 @@
|
|||
CREATE TABLE `objects`
|
||||
(
|
||||
`do_not_access_rowid_alias` INTEGER PRIMARY KEY,
|
||||
`object_type` INT NOT NULL,
|
||||
`id` INT GENERATED ALWAYS AS (`do_not_access_rowid_alias` | (`object_type` << 56)
|
||||
) VIRTUAL,
|
||||
`type` INT NOT NULL,
|
||||
`id` INT GENERATED ALWAYS AS (`do_not_access_rowid_alias` | (`type` << 56)) VIRTUAL,
|
||||
`name` TEXT NOT NULL,
|
||||
`information` TEXT NOT NULL
|
||||
) STRICT;
|
||||
|
||||
CREATE UNIQUE INDEX `object_id` ON `objects` (`id`);
|
||||
CREATE INDEX `object_type` ON `objects` (`object_type`);
|
||||
CREATE INDEX `object_type` ON `objects` (`type`);
|
||||
|
||||
CREATE
|
||||
VIRTUAL TABLE `objects_fts` USING fts5
|
||||
CREATE VIRTUAL TABLE `objects_fts` USING fts5
|
||||
(
|
||||
`name`,
|
||||
`information`,
|
||||
content=
|
||||
'objects',
|
||||
content_rowid=
|
||||
'id',
|
||||
tokenize=
|
||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
content='objects',
|
||||
content_rowid='id',
|
||||
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
);
|
||||
|
||||
CREATE TABLE `entities`
|
||||
|
|
@ -73,24 +68,18 @@ CREATE
|
|||
VIRTUAL TABLE `property_default_value_fts` USING fts5
|
||||
(
|
||||
`default_value`,
|
||||
content=
|
||||
'properties',
|
||||
content_rowid=
|
||||
'object_id',
|
||||
tokenize=
|
||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
content='properties',
|
||||
content_rowid='object_id',
|
||||
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
);
|
||||
|
||||
CREATE
|
||||
VIRTUAL TABLE `property_settings_fts` USING fts5
|
||||
(
|
||||
`settings`,
|
||||
content=
|
||||
'properties',
|
||||
content_rowid=
|
||||
'object_id',
|
||||
tokenize=
|
||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
content='properties',
|
||||
content_rowid='object_id',
|
||||
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
);
|
||||
|
||||
CREATE TABLE `values`
|
||||
|
|
@ -108,8 +97,6 @@ CREATE
|
|||
VIRTUAL TABLE `values_fts` USING fts5
|
||||
(
|
||||
`value`,
|
||||
content=
|
||||
'values',
|
||||
tokenize=
|
||||
"unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
)
|
||||
content='values',
|
||||
tokenize="unicode61 remove_diacritics 2 tokenchars '-_'"
|
||||
);
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
#include "project.hpp"
|
||||
|
||||
#include "migrations.hpp"
|
||||
#include "ikarus/persistence/project.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <cppbase/strings.hpp>
|
||||
|
||||
#include <ikarus/persistence/project.h>
|
||||
|
||||
#include <objects/blueprint.hpp>
|
||||
#include <objects/entity.hpp>
|
||||
#include <objects/properties/number_property.hpp>
|
||||
#include <objects/properties/property.hpp>
|
||||
#include <objects/properties/text_property.hpp>
|
||||
#include <objects/properties/toggle_property.hpp>
|
||||
#include <persistence/migrations.hpp>
|
||||
#include <persistence/project.hpp>
|
||||
|
||||
IkarusProject::IkarusProject(std::string_view name, std::string_view path, std::unique_ptr<sqlitecpp::Connection> && db):
|
||||
name{name},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue