ext/duckdb/prepared_statement.c in duckdb-1.1.3.0 vs ext/duckdb/prepared_statement.c in duckdb-1.1.3.1
- old
+ new
@@ -70,11 +70,12 @@
obj = allocate(cDuckDBPreparedStatement);
TypedData_Get_Struct(obj, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
if (duckdb_prepare_extracted_statement(con, extracted_statements, index, &(ctx->prepared_statement)) == DuckDBError) {
- rb_raise(eDuckDBError, "Failed to create DuckDB::PreparedStatement object.");
+ const char *error = duckdb_prepare_error(ctx->prepared_statement);
+ rb_raise(eDuckDBError, "%s", error ? error : "Failed to create DuckDB::PreparedStatement object.");
}
return obj;
}
static VALUE duckdb_prepared_statement_initialize(VALUE self, VALUE con, VALUE query) {
@@ -88,10 +89,10 @@
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
ctxcon = get_struct_connection(con);
if (duckdb_prepare(ctxcon->con, StringValuePtr(query), &(ctx->prepared_statement)) == DuckDBError) {
const char *error = duckdb_prepare_error(ctx->prepared_statement);
- rb_raise(eDuckDBError, "%s", error);
+ rb_raise(eDuckDBError, "%s", error ? error : "Failed to prepare statement(Database connection closed?).");
}
return self;
}
static VALUE duckdb_prepared_statement_nparams(VALUE self) {