GQL icon indicating copy to clipboard operation
GQL copied to clipboard

Application of `WHERE` clause and renaming columns

Open uberroot4 opened this issue 3 months ago • 1 comments

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:

  1. Extending the TABLES_FIELDS_TYPES by map.insert("diff_to", DataType::Text);
  2. Extending the TABLES_FIELDS_NAMES ("diffs") by "diff_to"
  3. 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;
}
  1. 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;
  1. However, when I execute it like this (i.e. renaming the diff_to while I'm having it in the WHERE clause, it raises an error: "Invalid column name diff_to". When i use WHERE 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

uberroot4 avatar Mar 27 '24 14:03 uberroot4