Use QueryLocation and GetParameterCount - #575
Merged
Merged
Conversation
Member
|
@evertlammerts i think we need a compile-time compatibility layer: diff --git a/src/pystatement.cpp b/src/pystatement.cpp
index 71d85de..77adea5 100644
--- a/src/pystatement.cpp
+++ b/src/pystatement.cpp
@@ -4,6 +4,25 @@ namespace duckdb {
enum class ExpectedResultType : uint8_t { QUERY_RESULT, NOTHING, CHANGED_ROWS, UNKNOWN };
+static idx_t StatementLocationOffset(idx_t location) {
+ return location;
+}
+
+template <class LOCATION>
+static auto StatementLocationOffset(const LOCATION &location) -> decltype(location.offset) {
+ return location.offset;
+}
+
+template <class STATEMENT>
+static auto StatementLength(const STATEMENT &statement, int) -> decltype(statement.stmt_length) {
+ return statement.stmt_length;
+}
+
+template <class STATEMENT>
+static auto StatementLength(const STATEMENT &statement, long) -> decltype(statement.stmt_location.length) {
+ return statement.stmt_location.length;
+}
+
static void InitializeReadOnlyProperties(nb::class_<DuckDBPyStatement> &m) {
m.def_prop_ro("type", &DuckDBPyStatement::Type, "Get the type of the statement.")
.def_prop_ro("query", &DuckDBPyStatement::Query, "Get the query equivalent to this statement.")
@@ -28,8 +47,7 @@ unique_ptr<SQLStatement> DuckDBPyStatement::GetStatement() {
}
string DuckDBPyStatement::Query() const {
- auto &loc = statement->stmt_location;
- return statement->query.substr(loc.offset, loc.length);
+ return statement->query.substr(StatementLocationOffset(statement->stmt_location), StatementLength(*statement, 0));
}
nb::set DuckDBPyStatement::NamedParameters() const {because /home/runner/work/_temp/setup-uv-cache/sdists-v9/path/c76f0a5a5d63061e/yeuNApnSr0b1lb94L9muS/src/src/pystatement.cpp:
In member function ‘std::string duckdb::DuckDBPyStatement::Query()
const’:
/home/runner/work/_temp/setup-uv-cache/sdists-v9/path/c76f0a5a5d63061e/yeuNApnSr0b1lb94L9muS/src/src/pystatement.cpp:32:44:
error: request for member ‘offset’ in ‘loc’, which is of non-class type
‘long unsigned int’
32 | return statement->query.substr(loc.offset, loc.length);
| ^~~~~~
/home/runner/work/_temp/setup-uv-cache/sdists-v9/path/c76f0a5a5d63061e/yeuNApnSr0b1lb94L9muS/src/src/pystatement.cpp:32:56:
error: request for member ‘length’ in ‘loc’, which is of non-class type
‘long unsigned int’
32 | return statement->query.substr(loc.offset, loc.length);
| ^~~~~~
unless we bump the duckdb submodule also in this PR (which I was not able to do)? I've added more context on discord in a DM. |
Member
Author
|
The submodule bump refusal is a bug I introduced last week in an attempt to prevent PRs from secretly including a submodule change, which I realize now is in the wrong place. For now we can just bump the submodule manually int hese cases (which I just did). I'll fix this when I'm back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes latest build issues introduced by duckdb/duckdb#24159 and duckdb/duckdb#24273.
Note that duckdb core's debug build is broken again due to missing imports.
Supersedes #573