You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`;
406
402
----
407
403
408
404
When not quoted individually, a database alias with the full name `my alias with.dots and spaces` gets created instead:
409
405
410
406
.Query
411
407
[source, cypher]
412
408
----
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`;
414
410
----
415
411
416
412
==== Handling multiple dots
@@ -423,13 +419,13 @@ Though these always need to be quoted in order to avoid ambiguity with the compo
423
419
.Query
424
420
[source, cypher, role=test-skip]
425
421
----
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`;
427
423
----
428
424
429
425
.Query
430
426
[source, cypher, role=test-skip]
431
427
----
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`;
433
429
----
434
430
435
431
==== Single dots and local database aliases
@@ -445,13 +441,19 @@ If no such database exists, however, the same query will instead create a databa
445
441
.Query
446
442
[source, cypher]
447
443
----
448
-
CYPHER 5 CREATE ALIAS some.alias FOR DATABASE `northwind-graph`
444
+
CYPHER 5 CREATE ALIAS some.alias FOR DATABASE `northwind-graph`;
449
445
----
450
446
451
447
==== Handling parameters
452
448
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
+
453
455
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.
455
457
456
458
Consider the query with parameter:
457
459
@@ -466,13 +468,15 @@ Consider the query with parameter:
466
468
.Query
467
469
[source, cypher]
468
470
----
469
-
CYPHER 5 CREATE ALIAS $aliasname FOR DATABASE `northwind-graph`
471
+
CYPHER 5 CREATE ALIAS $aliasname FOR DATABASE `northwind-graph`;
470
472
----
471
473
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.
474
476
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.
476
480
Consider the same query but with the following parameter:
477
481
478
482
.Parameters
@@ -488,22 +492,20 @@ If `mycompositedatabase` does not exist, the command will create a database alia
488
492
489
493
In these cases, it is recommended to avoid parameters and explicitly quote the composite database name and alias name separately to avoid ambiguity.
490
494
491
-
==== Handling parameters
495
+
==== Avoiding ambiguity when using parameters
492
496
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.
494
498
495
499
Consider the setup:
496
500
497
501
.Query
498
502
[source, cypher, role="noheader test-skip"]
499
503
----
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`;
502
506
----
503
507
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:
507
509
508
510
.Parameters
509
511
[source, javascript]
@@ -516,17 +518,18 @@ Dropping this alias using parameters fails with an error about a missing alias:
516
518
.Query
517
519
[source, cypher, role=test-fail]
518
520
----
519
-
CYPHER 5 DROP ALIAS $aliasname FOR DATABASE
521
+
CYPHER 5 DROP ALIAS $aliasname FOR DATABASE;
520
522
----
521
523
522
-
.Error message
524
+
.Error
523
525
[source, output, role="noheader"]
524
526
----
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.
42001: Syntax error or access rule violation - invalid syntax
526
530
----
527
531
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.
532
535
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