age icon indicating copy to clipboard operation
age copied to clipboard

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

Open MironAtHome opened this issue 1 year ago • 2 comments

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 avatar Jun 27 '24 21:06 MironAtHome

@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 avatar Jun 28 '24 19:06 rafsun42

See if function age_graph_exists here helps

MironAtHome avatar Jun 30 '24 17:06 MironAtHome

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

MironAtHome avatar Jul 06 '24 23:07 MironAtHome

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

rafsun42 avatar Jul 08 '24 19:07 rafsun42

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

MironAtHome avatar Jul 09 '24 09:07 MironAtHome

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

MironAtHome avatar Jul 10 '24 17:07 MironAtHome

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

MironAtHome avatar Jul 17 '24 21:07 MironAtHome