Skip to content

Conversation

@flyingsilverfin
Copy link
Member

Goal

Add a little guide on moving between SQL and TypeQL.

Implementation

----
#!test[read, count=3]
match
$p isa person, has name $name, has email $email;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has email; (no variable) is closer to WHERE email IS NOT NULL in spirit.

Comment on lines +690 to +693
| `JOIN` | Relation patterns | Relations naturally connect entities
| `INNER JOIN` | Required relation patterns | Both sides must exist
| `LEFT JOIN` | Optional patterns with `try` | Use `try` for optional matches
| `RIGHT JOIN` | Optional patterns with `try` | Reverse pattern direction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing CROSS JOIN

| `LIMIT` | `limit` | Identical
| `OFFSET` | `offset` | Identical
| `DISTINCT` | `distinct` | Identical
| `COUNT/SUM/AVG/etc` | `reduce` with functions | `count`, `sum`, `mean`, etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `COUNT/SUM/AVG/etc` | `reduce` with functions | `count`, `sum`, `mean`, etc.
| `COUNT`/`SUM`/`AVG`/`etc. | `reduce` with `count`/`sum`/`mean`/etc. | Similar, assigned to a variable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall notes:

  • I thought we were using sentence case in section titles? Should be fixed if so.
  • Placing one sentence per line makes suggestions in a PR easier, and git diffs more meaningful. I suggest reformatting with that in mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed point 1 - point 2 isn't something i think we have an agreed upon style with! I agree with reviewing case, but I do think it's more awkward than being able to write a full paragraph in docs!

@flyingsilverfin
Copy link
Member Author

This repo for some reason also isn't being tested in factory... will merge it and fix anything else that comes up after!

@flyingsilverfin flyingsilverfin merged commit eb5a90f into typedb:3.x-development Nov 14, 2025
flyingsilverfin added a commit that referenced this pull request Nov 14, 2025
@flyingsilverfin flyingsilverfin deleted the sql-vs-typeql branch November 14, 2025 21:53
tag_source = deployment["artifact"]["release"]["download"],
commit_source = deployment["artifact"]["snapshot"]["download"],
tag = "3.4.4"
commit = "828fecc98675712b15e4f6a9b0b2e7ae54d19766"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need assertion bugfix

count_var_name = "automatic_test_count"
if counted:
queries[-1] = queries[-1] + f"\nreduce ${count_var_name} = count;"
def run_transaction(self, queries: List[str], type: TransactionType, rollback=False) -> Union[int, None]:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: removed parallel/optimized execution (shouldn't be needed in docs...)

Simplified with new ability to count fetch queries as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants