Skip to content

docs: use USE GRAPH to switch subgraphs - #38

Merged
adsharma merged 1 commit into
LadybugDB:mainfrom
leninworld:docs-use-graph-subgraph-issue-1542
Dec 2, 2026
Merged

adsharma merged 1 commit into
LadybugDB:mainfrom
leninworld:docs-use-graph-subgraph-issue-1542

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

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, because USE <name> switches to an attached database:

CREATE GRAPH my_graph   -> Created graph successfully.
USE my_graph            -> Runtime exception: No database named my_graph.
USE GRAPH my_graph      -> Used graph successfully.

Change

  • cypher/data-definition/create-graph.md: the three USE my_graph; lines become USE GRAPH my_graph;, the form used by the repository's own test (test/test_files/graph/typed_subgraph.test). "Switch between subgraphs" now shows USE GRAPH main; for returning to the default graph, and says that USE without GRAPH switches to an attached database.
  • cypher/difference.md: the USE section said "USE graph is not supported. For Ladybug, each graph is a database", which contradicts the CREATE GRAPH page. It now says that USE as a clause at the start of a query is not supported, and points to USE GRAPH <name> / USE GRAPH main as separate statements and to USE <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 ladybug 0.23.1 (Python 3.13, macOS arm64), in-memory database:

  • Every cypher block on the CREATE GRAPH page, run statement by statement (blocks 1 and 2 each on a fresh database, since both create my_graph), succeeds: USE GRAPH my_graph -> Used graph successfully., USE GRAPH main -> Used graph successfully., CALL SHOW_GRAPHS() lists my_graph, DROP GRAPH my_graph drops it.
  • The old line still fails: USE my_graph -> Runtime exception: No database named my_graph.
  • After USE GRAPH main, a table created inside my_graph is no longer visible (Table User does not exist), so main is the default graph.
  • ATTACH '<file>.lbug' AS other (dbtype lbug) then USE other -> Used database successfully., and a query reads the attached data, which backs the new sentence about plain USE.
  • USE g MATCH (u:U) RETURN u.id and USE 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 of build-and-check-links.yml): 155 pages built, All internal links are valid., exit 0 (the existing table highlighting warnings come from other pages).

Fixes LadybugDB/ladybug#1542

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
@adsharma

adsharma commented Dec 2, 2026

Copy link
Copy Markdown
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

USE my_database
MATCH (n:Person) RETURN n.name;

In LadybugDB, we also support ATTACH and DETACH statements over supported foreign databases, including dbtype lbug. In those cases users need to use the right dbName prefix to refer to a table in the attached database. USE is not supported.

@adsharma
adsharma merged commit fd0414b into LadybugDB:main Dec 2, 2026
1 check passed
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.

Docs: CREATE GRAPH page says USE my_graph, but the working statement is USE GRAPH my_graph

2 participants