Repository navigation
docs: use USE GRAPH to switch subgraphs - #38
Merged
adsharma merged 1 commit intoDec 2, 2026
Merged
Conversation
USE <name> switches to an attached database, so USE my_graph on the CREATE GRAPH page fails with 'No database named my_graph'. Use USE GRAPH my_graph in the examples, show USE GRAPH main for returning to the default graph, and update the Cypher differences page, which still said that switching graphs is not supported. Fixes LadybugDB/ladybug#1542
Contributor
|
Looks right to me. Some historical notes: Neo4j Cypher: Neo4j introduced USE (starting in Neo4j 4.0) to direct a query or schema command to a specific database or composite constituent graph. It acts as a query prefix rather than a persistent session switch like in SQL, meaning you must include it at the top of each query or subquery.cypher In LadybugDB, we also support |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes issue #1542.
Problem
The CREATE GRAPH page uses
USE my_graph;to switch into a subgraph, both in the two creation examples and in "Switch between subgraphs". That statement fails, becauseUSE <name>switches to an attached database:Change
cypher/data-definition/create-graph.md: the threeUSE my_graph;lines becomeUSE GRAPH my_graph;, the form used by the repository's own test (test/test_files/graph/typed_subgraph.test). "Switch between subgraphs" now showsUSE GRAPH main;for returning to the default graph, and says thatUSEwithoutGRAPHswitches to an attached database.cypher/difference.md: theUSEsection said "USEgraph is not supported. For Ladybug, each graph is a database", which contradicts the CREATE GRAPH page. It now says thatUSEas a clause at the start of a query is not supported, and points toUSE GRAPH <name>/USE GRAPH mainas separate statements and toUSE <name>for attached databases.The issue also suggests noting that the current graph is shared by every connection on a
Database. That behaviour is reported as a bug in LadybugDB/ladybug#1543, so this PR leaves it out rather than documenting it as intended.Validation
Python package
ladybug0.23.1 (Python 3.13, macOS arm64), in-memory database:cypherblock on the CREATE GRAPH page, run statement by statement (blocks 1 and 2 each on a fresh database, since both createmy_graph), succeeds:USE GRAPH my_graph->Used graph successfully.,USE GRAPH main->Used graph successfully.,CALL SHOW_GRAPHS()listsmy_graph,DROP GRAPH my_graphdrops it.USE my_graph->Runtime exception: No database named my_graph.USE GRAPH main, a table created insidemy_graphis no longer visible (Table User does not exist), somainis the default graph.ATTACH '<file>.lbug' AS other (dbtype lbug)thenUSE other->Used database successfully., and a query reads the attached data, which backs the new sentence about plainUSE.USE g MATCH (u:U) RETURN u.idandUSE GRAPH g MATCH ...both fail with a parser exception, which backs the wording on the differences page.CHECK_LINKS=true astro build(the PR job ofbuild-and-check-links.yml): 155 pages built,All internal links are valid., exit 0 (the existingtablehighlighting warnings come from other pages).Fixes LadybugDB/ladybug#1542