mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
- Implement core DatabaseSync and StatementSync classes - Add support for all Node.js sqlite constructor options - Implement advanced statement features: * sourceSQL and expandedSQL properties * setReturnArrays() for array-based results * setReadBigInts() and setAllowBareNamedParameters() - Support all parameter binding types (positional, named, object) - Add comprehensive test suite with 10+ test files - Fix memory issues in location() method with proper CString handling - Add missing sqlite3_local.h include for compilation - Achieve 85-90% Node.js API compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "root.h"
|
|
#include <JavaScriptCore/JSDestructibleObject.h>
|
|
#include <JavaScriptCore/JSGlobalObject.h>
|
|
#include <JavaScriptCore/Structure.h>
|
|
#include <JavaScriptCore/WriteBarrier.h>
|
|
#include <wtf/text/WTFString.h>
|
|
#ifndef LAZY_LOAD_SQLITE
|
|
#define LAZY_LOAD_SQLITE 0
|
|
#endif
|
|
|
|
#if LAZY_LOAD_SQLITE
|
|
#include "lazy_sqlite3.h"
|
|
#else
|
|
#include "sqlite3_local.h"
|
|
#endif
|
|
|
|
namespace Bun {
|
|
|
|
class JSNodeSQLiteDatabaseSync;
|
|
|
|
class JSNodeSQLiteStatementSync final : public JSC::JSDestructibleObject {
|
|
public:
|
|
using Base = JSC::JSDestructibleObject;
|
|
static constexpr unsigned StructureFlags = Base::StructureFlags;
|
|
|
|
static JSNodeSQLiteStatementSync* create(JSC::VM& vm, JSC::Structure* structure, JSNodeSQLiteDatabaseSync* database, const String& sql);
|
|
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype);
|
|
|
|
DECLARE_EXPORT_INFO;
|
|
DECLARE_VISIT_CHILDREN;
|
|
|
|
template<typename MyClassT, JSC::SubspaceAccess mode>
|
|
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm);
|
|
|
|
static void destroy(JSC::JSCell* cell);
|
|
|
|
sqlite3_stmt* statement() const { return m_stmt; }
|
|
JSNodeSQLiteDatabaseSync* database() const { return m_database.get(); }
|
|
void finalizeStatement();
|
|
const String& sourceSQL() const { return m_sourceSQL; }
|
|
bool returnArrays() const { return m_returnArrays; }
|
|
void setReturnArrays(bool value) { m_returnArrays = value; }
|
|
|
|
private:
|
|
JSNodeSQLiteStatementSync(JSC::VM& vm, JSC::Structure* structure, JSNodeSQLiteDatabaseSync* database);
|
|
~JSNodeSQLiteStatementSync();
|
|
void finishCreation(JSC::VM& vm);
|
|
|
|
sqlite3_stmt* m_stmt;
|
|
JSC::WriteBarrier<JSNodeSQLiteDatabaseSync> m_database;
|
|
String m_sourceSQL;
|
|
bool m_returnArrays { false };
|
|
|
|
public:
|
|
};
|
|
|
|
void setupJSNodeSQLiteStatementSyncClassStructure(JSC::LazyClassStructure::Initializer&);
|
|
|
|
} // namespace Bun
|