Skip to content
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

Age graph existance check function, something like "graph_exists" would be very nice #1936

Closed
MironAtHome opened this issue Jun 27, 2024 · 7 comments
Assignees
Labels
enhancement New request

Comments

@MironAtHome
Copy link

MironAtHome commented Jun 27, 2024

1 It would be very helpful to have an function that could report a boolean, whether graph with name "xyz" exists, true or false.
In addition, I am not sure, if an optional parameter to the same, or a separate function, that would produce something like "residual", that could potentially cause "create_graph" to fail.
One of the reasons, when "drop extension if exists age" is performed, existing graphs are forgotten.
To clean up those one need to run "drop schema <my_graph_name> cascade;"
Since internals of how graph is defined and stored in the database is really an private interface, it would be very nice to provide such a function, since details can potentially change from version to version, and it would be very helpful to graph user to have something like 'report_graph_residual(<graph_name>)' with all the database objects related to the graph name, whether the graph itself considered existing or not at the moment.
2 Thinking of an ideal solution / alternate approach, having an overload of function cypher, that does not require graph name as the first parameter, but could accept something like "create graph ..." command, would be absolutely awesome, but that should not be taken either / or. The #1 is essential, #2 is a very nice language wise, to have a very concise was to express same query. Being very fond of cypher I thought it would be nice to add this to the ask, at least as in reverence to all the cypher language community.

@MironAtHome MironAtHome added the enhancement New request label Jun 27, 2024
@rafsun42
Copy link
Member

@MironAtHome If I understand correctly, when the extension is dropped, graph schemas are not dropped. And, you are expecting the graphs to be dropped automatically?

@rafsun42 rafsun42 self-assigned this Jun 28, 2024
@MironAtHome
Copy link
Author

MironAtHome commented Jun 30, 2024

See if function age_graph_exists here helps

@MironAtHome
Copy link
Author

@rafsun42

If I understand correctly, when the extension is dropped, graph schemas are not dropped. And, you are expecting the graphs to be dropped automatically?

Not really.
All I am asking for is to expose as public function callable from Postgres database SQL layer the function that already exists in the Age code "graph_exists" so that I could put in my procedures, working with data loading an check
if not (age_graph_exists('<my_graph_name>')) then
select create_graph('<my_graph_name>');
end if;
rest is an attempt to gather simple and, potential, corner cases, to explain, as to why I feel this new function is justified.
Rest is additional considerations with lower priority.

@rafsun42
Copy link
Member

rafsun42 commented Jul 8, 2024

@MironAtHome I created PR #1958. Please let me know if that works for you.

@MironAtHome
Copy link
Author

Great thank you!
I have commented for code review. Please take a look.

@MironAtHome
Copy link
Author

I noted PR was merged into master.
Closing issue.
Please see if you still can make adjustments based on comments.

@MironAtHome
Copy link
Author

@rafsun42
Updated function.
Please see if changes in the code acceptable ( those are matching suggestions in the PR ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New request
Projects
None yet
Development

No branches or pull requests

2 participants