-
Notifications
You must be signed in to change notification settings - Fork 4
Eng 898 create database query functions for base dg queries #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maparent
merged 15 commits into
main
from
eng-898-create-database-query-functions-for-base-dg-queries
Oct 12, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4be4817
WIP: allow relation queries, add author filter, add tests
maparent ddb3751
wip: More query cases
maparent b948aef
filter on connected node author
maparent af940b4
filter on list of nodes or collected nodes
maparent 803d553
coderabbit corrections
maparent e2a9a87
make lint happier
maparent 4fb0768
prettier
maparent 97f5577
better TS
maparent 6a24a37
comment, rename, clarify
maparent 5ad8c6e
correction, limit offset
maparent 333c734
correction: relation defs in cache
maparent 8b549c6
correction
maparent 71e4ccf
some more comments
maparent 1aca01b
Document cucumber table syntax
maparent d5ee24d
apply prettier
maparent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Designing cucumber tests | ||
|
|
||
| Cucumber is a harness for the gherkin language, allowing to make tests more legible. The steps are defined as regexp in `features/step-definitions/stepdefs.ts`. Currently, we assume the database is running with `turbo dev` in another terminal. | ||
|
|
||
| Some of test steps were defined to clear the database (`Given the database is blank`) or to put arbitrary data in the tables (`{word} are added to the database:`) which expects the name of a table as argument, and a markdown table for the table data. | ||
|
|
||
| The latter step requires some further explanations: | ||
|
|
||
| A lot of database objects use foreign keys, so we need to refer to numeric database identifiers. Those are defined by the database. To allow this to work, we have a pseudo-column called `$id`, which is a string alias that corresponds to the database numeric `id`. Make sure each value in that column is unique. We keep a dictionary of those aliases to the database numeric `id` in cucumber. When interpreting the table, if any other column is prefixed by a `_`, we will recursively search for strings and from the alias set and replace them with the appropriate database ids. Note that inserts are made in bulk, so you may need to break up your inserts according to dependencies. For example: | ||
|
|
||
| - Adding a schema first | ||
| `And Concept are added to the database:` | ||
|
|
||
| | $id | name | @is_schema | | ||
| | alias1 | Claim | true | | ||
|
|
||
| - Then a concept referring to the schema | ||
| `And Concept are added to the database:` | ||
| | $id | name | @is_schema | \_schema_id | | ||
| | alias2 | claim 1 | false | alias1 | | ||
|
|
||
| Also, cucumber treats all columns as strings; if they contain a non-string literal (essentially number, boolean or JSON) you can use the `@` prefix in the column name so the cell value will be parsed as json before sending to the database. (`@` comes before `_` if both are used.) | ||
|
|
||
| Other steps that require explanation: | ||
|
|
||
| - `a user logged in space {word} and calling getConcepts with these parameters: {string}` | ||
| - `Then query results should look like this` | ||
|
|
||
| This comes in pairs: The results from the query (whose parameters are defined as json) are checked against a table, using the same syntax as above. Only the columns defined are checked for equivalence. | ||
|
|
||
| - `the user {word} opens the {word} plugin in space {word}`. | ||
|
|
||
| This both creates the space and an account tied to that space. Because tying spaces and accounts goes through an edge function, it is the only good way to do both. | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following files still add changes when they are saved:
Can you confirm this is the same for you?

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... Somehow, Zed's enforced prettier settings don't agree with our prettier settings. Sigh.
Did apply prettier, will have to dig deeper into settings.