Skip to content

Commit 9b3092f

Browse files
committed
feat: add null support in cpp code
1 parent 5d66167 commit 9b3092f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

package/cpp/operations.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ void bindStatement(sqlite3_stmt* statement, const SQLiteQueryParams& values) {
102102
for (int valueIndex = 0; valueIndex < values.size(); valueIndex++) {
103103
int sqliteIndex = valueIndex+1;
104104
SQLiteValue value = values.at(valueIndex);
105-
// if (std::holds_alternative<std::monostate>(value))
106-
// {
107-
// sqlite3_bind_null(statement, sqliteIndex);
108-
// }
109-
if (std::holds_alternative<bool>(value)) {
105+
if (std::holds_alternative<NativeSQLiteNullValue>(value)) {
106+
sqlite3_bind_null(statement, sqliteIndex);
107+
} else if (std::holds_alternative<bool>(value)) {
110108
sqlite3_bind_int(statement, sqliteIndex, std::get<bool>(value));
111109
} else if (std::holds_alternative<double>(value)) {
112110
sqlite3_bind_double(statement, sqliteIndex, std::get<double>(value));
@@ -191,7 +189,7 @@ SQLiteExecuteQueryResult sqliteExecute(const std::string& dbName, const std::str
191189
case SQLITE_NULL:
192190
// Intentionally left blank to switch to default case
193191
default:
194-
// row[column_name] = std::monostate();
192+
row[column_name] = NativeSQLiteNullValue(true);
195193
break;
196194
}
197195
i++;

package/cpp/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using namespace margelo::nitro::rnnitrosqlite;
1212
namespace margelo::rnnitrosqlite {
1313

1414
// using SQLiteValue = std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>, std::monostate>;
15-
using SQLiteValue = std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>, NativeSqliteNullValue>;
15+
using SQLiteValue = std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>, NativeSQLiteNullValue>;
1616
using SQLiteQueryParams = std::vector<SQLiteValue>;
1717
using SQLiteQueryResultRow = std::unordered_map<std::string, SQLiteValue>;
1818
using SQLiteQueryResults = std::vector<SQLiteQueryResultRow>;

0 commit comments

Comments
 (0)