GQL
GQL copied to clipboard
Application of `WHERE` clause and renaming columns
Hello, I've encountered your project and tried to implement some (imo) missing columns for some types. When it comes to the diffs
table, I am missing a reference to where the diff was made to. Checking the code I found it and decided to simply add it to the possible columns:
- Extending the
TABLES_FIELDS_TYPES
bymap.insert("diff_to", DataType::Text);
- Extending the
TABLES_FIELDS_NAMES
("diffs"
) by"diff_to"
- Modifying the
git_data_provider
by:
if field_name == "diff_to" {
let diff_to_cid = commit_info
.parent_ids()
.next()
.map(|p| p.object().unwrap().id.to_string());
match diff_to_cid {
Some(value) => values.push(Value::Text(value)),
None => values.push(Value::Text("".to_string())),
};
continue;
}
- Pretty straight forward all together, also it works when I execute the query like this:
SELECT commit_id AS from_,diff_to AS to_,name FROM diffs LIMIT 10;
- However, when I execute it like this (i.e. renaming the
diff_to
while I'm having it in theWHERE
clause, it raises an error: "Invalid column namediff_to
". When i useWHERE to_ IS NULL
then it wirks fine.
SELECT commit_id AS from_,diff_to AS to_,name AS b FROM diffs WHERE diff_to IS NULL LIMIT 10;
Expected behavior
As far as I am aware of SQL, renaming a column and using it in a WHERE
clause is exact the opposite as in GQL
.
So I think the renamig part in the rust Code should be applied after the consolidation of all columns.
Another remark
When investigating the problem (at first I thought the problem lies somewhere else), I encountered that the LIMIT X
clause is applied after the SELECT
statement -- respectively I just tried a simple println
for debugging. For the sake of resource management, shouldn't it be applied before? Meaning that GQL
could abort the revwalk
section after X
iterations?
GQL:
- Version 0.16.0
Best, Manuel