diff --git a/include/sqlgen/sqlite/Connection.hpp b/include/sqlgen/sqlite/Connection.hpp index c8f5d6d..53f9e57 100644 --- a/include/sqlgen/sqlite/Connection.hpp +++ b/include/sqlgen/sqlite/Connection.hpp @@ -18,14 +18,12 @@ namespace sqlgen::sqlite { class Connection : public sqlgen::Connection { - using ConnPtr = std::unique_ptr; - using StmtPtr = std::unique_ptr; + using ConnPtr = Ref; + using StmtPtr = std::shared_ptr; public: Connection(const std::string& _fname) - : stmt_(StmtPtr(nullptr, &sqlite3_finalize)), conn_(make_conn(_fname)) {} - - Connection(const Connection& _other) = delete; + : stmt_(nullptr), conn_(make_conn(_fname)) {} static rfl::Result> make( const std::string& _fname) noexcept; @@ -36,8 +34,6 @@ class Connection : public sqlgen::Connection { Result execute(const std::string& _sql) noexcept final; - Connection& operator=(const Connection& _other) = delete; - Result> read(const dynamic::SelectFrom& _query) final { return error("TODO"); } diff --git a/src/sqlgen/sqlite/Connection.cpp b/src/sqlgen/sqlite/Connection.cpp index 94686f5..efe5da0 100644 --- a/src/sqlgen/sqlite/Connection.cpp +++ b/src/sqlgen/sqlite/Connection.cpp @@ -103,7 +103,7 @@ typename Connection::ConnPtr Connection::make_conn(const std::string& _fname) { throw std::runtime_error("Can't open database: " + std::string(sqlite3_errmsg(conn))); } - return ConnPtr(conn, &sqlite3_close); + return ConnPtr::make(std::shared_ptr(conn, &sqlite3_close)).value(); } std::string Connection::properties_to_sql(