Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "../NitroSQLiteLogs.hpp"
#include "../NitroSQLiteMacros.hpp"
#include "../NitroSQLiteOperations.hpp"
#include "HybridNitroSQLitePreparedStatement.hpp"
#include "HybridPreparedStatement.hpp"
#include <exception>
#include <filesystem>
#include <iostream>
Expand Down Expand Up @@ -234,8 +234,8 @@ Promise<NitroSQLiteQueryResult> HybridNitroSQLite::executeAsync(const std::strin
});
};

std::shared_ptr<HybridNitroSQLitePreparedStatementSpec> HybridNitroSQLite::prepare(const std::string& dbName, const std::string& query) {
return std::make_shared<HybridNitroSQLitePreparedStatement>(sqlitePrepare(_connections.get(dbName), query));
std::shared_ptr<HybridPreparedStatementSpec> HybridNitroSQLite::prepare(const std::string& dbName, const std::string& query) {
return std::make_shared<HybridPreparedStatement>(sqlitePrepare(_connections.get(dbName), query));
}

BatchQueryResult HybridNitroSQLite::executeBatch(const std::string& dbName, const std::vector<BatchQueryCommand>& batchParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "../NitroSQLiteDatabaseConnections.hpp"
#include "../NitroSQLiteTypes.hpp"
#include <RNNitroSQLite/HybridNitroSQLitePreparedStatementSpec.hpp>
#include <RNNitroSQLite/HybridNitroSQLiteSpec.hpp>
#include <RNNitroSQLite/HybridPreparedStatementSpec.hpp>

namespace margelo::nitro::rnnitrosqlite {

Expand Down Expand Up @@ -74,7 +74,7 @@ class HybridNitroSQLite : public HybridNitroSQLiteSpec {
const std::optional<Callback<void(SQLiteQueryResults)>>& onRows) override;

/** Prepare one SQL statement for repeated execution on an open connection. */
std::shared_ptr<HybridNitroSQLitePreparedStatementSpec> prepare(const std::string& dbName, const std::string& query) override;
std::shared_ptr<HybridPreparedStatementSpec> prepare(const std::string& dbName, const std::string& query) override;

/** Run a nonempty batch in one exclusive transaction on the calling thread.
* A failed command rolls back the batch.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "HybridNitroSQLitePreparedStatement.hpp"
#include "HybridPreparedStatement.hpp"
#include <NitroModules/ArrayBuffer.hpp>

namespace margelo::nitro::rnnitrosqlite {
Expand Down Expand Up @@ -26,30 +26,29 @@ namespace {

} // namespace

HybridNitroSQLitePreparedStatement::HybridNitroSQLitePreparedStatement(std::shared_ptr<SQLitePreparedStatement> statement)
: _statement(std::move(statement)) {}
HybridPreparedStatement::HybridPreparedStatement(std::shared_ptr<SQLitePreparedStatement> statement) : _statement(std::move(statement)) {}

NitroSQLiteQueryResult HybridNitroSQLitePreparedStatement::execute(const std::optional<SQLiteQueryParams>& params) {
NitroSQLiteQueryResult HybridPreparedStatement::execute(const std::optional<SQLiteQueryParams>& params) {
return _statement->execute(params);
}

Promise<NitroSQLiteQueryResult> HybridNitroSQLitePreparedStatement::executeAsync(const std::optional<SQLiteQueryParams>& params) {
Promise<NitroSQLiteQueryResult> HybridPreparedStatement::executeAsync(const std::optional<SQLiteQueryParams>& params) {
const auto copiedParams = copyArrayBufferParamsForBackground(params);
const auto statement = _statement;

return Promise<NitroSQLiteQueryResult>::async(
[statement, copiedParams]() -> NitroSQLiteQueryResult { return statement->execute(copiedParams); });
}

void HybridNitroSQLitePreparedStatement::finalize() {
void HybridPreparedStatement::finalize() {
_statement->finalize();
}

bool HybridNitroSQLitePreparedStatement::getIsFinalized() {
bool HybridPreparedStatement::getIsFinalized() {
return _statement->isFinalized();
}

size_t HybridNitroSQLitePreparedStatement::getExternalMemorySize() noexcept {
size_t HybridPreparedStatement::getExternalMemorySize() noexcept {
return sizeof(*this) + _statement->getExternalMemorySize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

#include "../NitroSQLiteOperations.hpp"
#include "../NitroSQLiteTypes.hpp"
#include <RNNitroSQLite/HybridNitroSQLitePreparedStatementSpec.hpp>
#include <RNNitroSQLite/HybridPreparedStatementSpec.hpp>
#include <memory>

namespace margelo::nitro::rnnitrosqlite {

/** Nitro hybrid object for a reusable native SQLite statement. */
class HybridNitroSQLitePreparedStatement : public HybridNitroSQLitePreparedStatementSpec {
class HybridPreparedStatement : public HybridPreparedStatementSpec {
public:
/** Wrap a prepared statement for calls from JavaScript. */
explicit HybridNitroSQLitePreparedStatement(std::shared_ptr<SQLitePreparedStatement> statement);
explicit HybridPreparedStatement(std::shared_ptr<SQLitePreparedStatement> statement);

/** Execute with new bindings on the calling thread. */
NitroSQLiteQueryResult execute(const std::optional<SQLiteQueryParams>& params) override;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading