Skip to content

Commit 01bcae6

Browse files
authored
Update the Handling parameters section (#3132)
1 parent 1b17cc0 commit 01bcae6

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

modules/ROOT/pages/database-administration/aliases/manage-aliases-composite-databases.adoc

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ The exception has GQLSTATUS code link:{neo4j-docs-base-uri}/status-codes/current
328328
======
329329
=====
330330

331-
332-
333331
[role=label--new-2025.06]
334332
=== Cypher 25 specific behaviour
335333
==== Accessing an existing alias with dots
@@ -376,8 +374,6 @@ The query attempts to create the following aliases in the given order:
376374

377375
When it finds the composite database `my.garden`, it creates the constituent alias `beautiful.flowers` within that composite.
378376

379-
380-
381377
=== Cypher 5 specific behaviour
382378

383379
==== Quoting database alias and composite database names
@@ -402,15 +398,15 @@ CREATE DATABASE `northwind-graph`;
402398
.Query
403399
[source, cypher]
404400
----
405-
CYPHER 5 CREATE ALIAS `my-composite-database-with-dashes`.`my alias with spaces` FOR DATABASE `northwind-graph`
401+
CYPHER 5 CREATE ALIAS `my-composite-database-with-dashes`.`my alias with spaces` FOR DATABASE `northwind-graph`;
406402
----
407403

408404
When not quoted individually, a database alias with the full name `my alias with.dots and spaces` gets created instead:
409405

410406
.Query
411407
[source, cypher]
412408
----
413-
CYPHER 5 CREATE ALIAS `my alias with.dots and spaces` FOR DATABASE `northwind-graph`
409+
CYPHER 5 CREATE ALIAS `my alias with.dots and spaces` FOR DATABASE `northwind-graph`;
414410
----
415411

416412
==== Handling multiple dots
@@ -423,13 +419,13 @@ Though these always need to be quoted in order to avoid ambiguity with the compo
423419
.Query
424420
[source, cypher, role=test-skip]
425421
----
426-
CYPHER 5 CREATE ALIAS `my.alias.with.dots` FOR DATABASE `northwind-graph`
422+
CYPHER 5 CREATE ALIAS `my.alias.with.dots` FOR DATABASE `northwind-graph`;
427423
----
428424

429425
.Query
430426
[source, cypher, role=test-skip]
431427
----
432-
CYPHER 5 CREATE ALIAS `my.composite.database.with.dots`.`my.other.alias.with.dots` FOR DATABASE `northwind-graph`
428+
CYPHER 5 CREATE ALIAS `my.composite.database.with.dots`.`my.other.alias.with.dots` FOR DATABASE `northwind-graph`;
433429
----
434430

435431
==== Single dots and local database aliases
@@ -445,13 +441,19 @@ If no such database exists, however, the same query will instead create a databa
445441
.Query
446442
[source, cypher]
447443
----
448-
CYPHER 5 CREATE ALIAS some.alias FOR DATABASE `northwind-graph`
444+
CYPHER 5 CREATE ALIAS some.alias FOR DATABASE `northwind-graph`;
449445
----
450446

451447
==== Handling parameters
452448

449+
When using parameters to specify database alias names, the same rules apply as when using literal strings.
450+
However, since parameters cannot be quoted, it is not possible to specify the composite database name and the alias name separately when using parameters.
451+
This means that the first dot in the parameter value will always be considered as the separator between the composite database name and the alias name, which can lead to unexpected results if the parameter value contains dots.
452+
453+
===== Parameters with dots
454+
453455
When using parameters, names cannot be quoted.
454-
When the given parameter includes dots, the first dot will be considered the divider for the composite database.
456+
When the given parameter includes dots, the first dot is considered the divider for the composite database.
455457

456458
Consider the query with parameter:
457459

@@ -466,13 +468,15 @@ Consider the query with parameter:
466468
.Query
467469
[source, cypher]
468470
----
469-
CYPHER 5 CREATE ALIAS $aliasname FOR DATABASE `northwind-graph`
471+
CYPHER 5 CREATE ALIAS $aliasname FOR DATABASE `northwind-graph`;
470472
----
471473

472-
If the composite database `mysimplecompositedatabase` exists, then a database alias `myalias` will be created in that composite database.
473-
If no such composite database exists, then a database alias `mysimplecompositedatabase.myalias` will be created.
474+
If the composite database `mySimpleCompositeDatabase` exists, then a database alias `myAlias` will be created in that composite database.
475+
If no such composite database exists, then a database alias `mySimpleCompositeDatabase.myAlias` will be created.
474476

475-
On the contrary, a database alias `myalias` cannot be created in composite `mycompositedatabase.withdot` using parameters.
477+
===== Parameters with multiple dots
478+
479+
On the contrary, a database alias `myAlias` cannot be created in composite `myCompositeDatabase.withDot` using parameters.
476480
Consider the same query but with the following parameter:
477481

478482
.Parameters
@@ -488,22 +492,20 @@ If `mycompositedatabase` does not exist, the command will create a database alia
488492

489493
In these cases, it is recommended to avoid parameters and explicitly quote the composite database name and alias name separately to avoid ambiguity.
490494

491-
==== Handling parameters
495+
==== Avoiding ambiguity when using parameters
492496

493-
Further special handling with parameters is needed for database aliases and similarly named composite databases.
497+
Database aliases and similarly named composite databases require further special handling with parameters.
494498

495499
Consider the setup:
496500

497501
.Query
498502
[source, cypher, role="noheader test-skip"]
499503
----
500-
CYPHER 5 CREATE COMPOSITE DATABASE foo
501-
CYPHER 5 CREATE ALIAS `foo.bar` FOR DATABASE `northwind-graph`
504+
CYPHER 5 CREATE COMPOSITE DATABASE foo;
505+
CYPHER 5 CREATE ALIAS `foo.bar` FOR DATABASE `northwind-graph`;
502506
----
503507

504-
The alias `foo.bar` does not belong to the composite database `foo`.
505-
506-
Dropping this alias using parameters fails with an error about a missing alias:
508+
Because the alias `foo.bar` does not belong to the composite database `foo`, dropping this alias using a parameter will fail with a chain of errors about a missing alias:
507509

508510
.Parameters
509511
[source, javascript]
@@ -516,17 +518,18 @@ Dropping this alias using parameters fails with an error about a missing alias:
516518
.Query
517519
[source, cypher, role=test-fail]
518520
----
519-
CYPHER 5 DROP ALIAS $aliasname FOR DATABASE
521+
CYPHER 5 DROP ALIAS $aliasname FOR DATABASE;
520522
----
521523

522-
.Error message
524+
.Error
523525
[source, output, role="noheader"]
524526
----
525-
Failed to delete the specified database alias 'foo.bar': Database alias does not exist.
527+
42N00: Syntax error or access rule violation - graph reference not found. A graph reference with the name `foo.bar` was not found. Verify that the spelling is correct.
528+
42N51: Syntax error or access rule violation - invalid parameter. Invalid parameter $`aliasname`.
529+
42001: Syntax error or access rule violation - invalid syntax
526530
----
527531

528-
//From 5.26 onwards, the error message also contains the GQLSTATUS code `50N00` and the status description `error: general processing exception - internal error. Internal exception raised { $msgTitle }: Failed to create the specified database alias 'foo.bar'. Database alias does not exist.`
529-
530-
Had the composite database `foo` not existed, the database alias `foo.bar` would have been dropped.
531-
532+
In this example, Neo4j looks for the alias `bar` within the composite database `foo`.
533+
Since no such alias exists, the operation cannot be completed.
534+
If the composite database `foo` did not exist, the alias `foo.bar` would be resolved as a standalone alias and could be dropped successfully.
532535
In these cases, it is recommended to avoid parameters and explicitly quote the composite database name and alias name separately to avoid ambiguity.

0 commit comments

Comments
 (0)