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_TYPESbymap.insert("diff_to", DataType::Text); - Extending the
TABLES_FIELDS_NAMES("diffs") by"diff_to" - Modifying the
git_data_providerby:
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_towhile I'm having it in theWHEREclause, it raises an error: "Invalid column namediff_to". When i useWHERE to_ IS NULLthen 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
Hello @uberroot4,
The first point is valid and should be improved to work exactly like SQL
The Limit point is on TODO but it will require a more advanced QueryPlanner and Optimizer to make it work perfect
Hello @uberroot4,
This issue fixed on 0.22.0
You can now run select commit_count as cc from branches where commit_count > 1
https://github.com/AmrDeveloper/GQL/releases/tag/0.22.0