`db.constraints` should have backticks around labels and properties #7634

Closed
cheerfulstoic opened this Issue Jul 25, 2016 · 3 comments

Projects

None yet

2 participants

@cheerfulstoic

If I create a constraint like so:

CREATE CONSTRAINT ON (n:`Foo:Bar`) ASSERT n.`blah.baz` IS UNIQUE

And then get a list of constraints:

CALL db.constraints()

The relevant row that I get is:

CONSTRAINT ON ( foo:bar:Foo:Bar ) ASSERT foo:bar.blah.baz IS UNIQUE

I would expect this to be:

CONSTRAINT ON ( `foo:bar`:`Foo:Bar` ) ASSERT `foo:bar`.`blah.baz` IS UNIQUE

Or even:

CONSTRAINT ON ( foo_bar:`Foo:Bar` ) ASSERT foo_bar.`blah.baz` IS UNIQUE

I'm currently working on the Bolt driver for the neo4j gem and the gem needs to be able to look for indexes and constraints. The gem sometimes creates labels which match a Ruby namespaced class (like Module1::Module2::ModelClass). I won't be able to reliably parse the results of db.constraints() and db.indexes() without sometime to indicate where the label and property start/end.

  • Neo4j version: Tested on 3.0.1 and 3.0.3
  • Operating system: OS X, tar.gz version
  • API/Driver: Web console
@cheerfulstoic

Sorry, I didn't actually test db.indexes, but I see that it has multiple columns and so I think it would be possible to parse out the label / property / type from that. Does the node_unique_property in the type column of db.indexes always mean that the index comes from a unique constraint?

@cheerfulstoic cheerfulstoic changed the title from `db.constraints` and `db.indexes` should have backticks around labels and properties to `db.constraints` should have backticks around labels and properties Jul 25, 2016
@spacecowboy
Member

Yes, I believe that it does mean that.

@pontusmelke pontusmelke added a commit to pontusmelke/neo4j that referenced this issue Aug 22, 2016
@pontusmelke pontusmelke Escape when listing constraints containing `:`
Whenever listing constraints on labels containing a `:` the bound identifier
 and the label name needs to be escaped to avoid disambiguity, e.g.

 ```
 CREATE CONSTRAINT ON (n:`Foo:Bar`) ASSERT n.`blah.baz` IS UNIQUE
CALL db.constraints()
```

the results need to be

```
CONSTRAINT ON ( `foo:bar`:`Foo:Bar` ) ASSERT `foo:bar`.`blah.baz` IS UNIQUE
```

instead of

```
CONSTRAINT ON ( foo:bar:Foo:Bar ) ASSERT foo:bar.blah.baz IS UNIQUE
```

fixes #7634
70ed0b9
@systay systay pushed a commit that closed this issue Aug 30, 2016
@pontusmelke pontusmelke Escape when listing constraints containing `:`
Whenever listing constraints on labels containing a `:` the bound identifier
 and the label name needs to be escaped to avoid disambiguity, e.g.

 ```
 CREATE CONSTRAINT ON (n:`Foo:Bar`) ASSERT n.`blah.baz` IS UNIQUE
CALL db.constraints()
```

the results need to be

```
CONSTRAINT ON ( `foo:bar`:`Foo:Bar` ) ASSERT `foo:bar`.`blah.baz` IS UNIQUE
```

instead of

```
CONSTRAINT ON ( foo:bar:Foo:Bar ) ASSERT foo:bar.blah.baz IS UNIQUE
```

fixes #7634
f62115d
@systay systay closed this in f62115d Aug 30, 2016
@cheerfulstoic

Aren't there other characters which should be escaped? Would it make sense to just always have quotes?

@spacecowboy spacecowboy referenced this issue in neo4j/cypher-shell Sep 14, 2016
Merged

Simple output #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment