neo4j_bolt 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +161 -113
- data/bin/neo4j_bolt +14 -7
- data/lib/neo4j_bolt/version.rb +1 -1
- data/lib/neo4j_bolt.rb +796 -1025
- metadata +29 -29
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -6
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -43
- data/Rakefile +0 -6
- data/bin/setup +0 -8
- data/movie_graph.svg +0 -259
- data/neo4j_bolt.gemspec +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c587989e6936680692675035dada5d220122cc81655f2607b97e72b4725b23b
|
|
4
|
+
data.tar.gz: 6bedef9539b66644474e2d657b1e4454918a7bfe4a7db73cdfc626fb9b150426
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9640636068e101464e9a92e0ca38e465bc3c847863b457d90ae3e5361c37960359e7fd9c24ec8915f1ad27f90311b0867b95973801e28a17939f2bf70b3bad75
|
|
7
|
+
data.tar.gz: ed3142cd503626d3ba4d04ea86a708426178a070513c14325e46bac405bfa384250f8978d12cf6eb72920bb35ec7170cbb3ecd90500de121f6c650279387313e
|
data/README.md
CHANGED
|
@@ -1,196 +1,244 @@
|
|
|
1
1
|
# Neo4jBolt
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
- data types:
|
|
9
|
-
- supported: Null, Boolean, Integer, Float, String, List, Dictionary, Structure
|
|
10
|
-
- not supported: Bytes
|
|
11
|
-
- structures:
|
|
12
|
-
- supported: Node, Relationship
|
|
13
|
-
- not supported: UnboundRelationship, Path, Date, Time, LocalTime, DateTime, DateTimeZoneId, LocalDateTime, Duration, Point2D, Point3D
|
|
14
|
-
- Bolt Protocol:
|
|
15
|
-
- supported: transactions
|
|
16
|
-
- not supported:
|
|
17
|
-
- auto transactions (all transactions are explicit in Neo4jBolt)
|
|
18
|
-
- routing
|
|
19
|
-
- interrupt
|
|
3
|
+
Neo4jBolt 0.4 is a small compatibility and convenience layer for Ruby applications, backed by [neo4j-ruby-driver](https://github.com/neo4jrb/neo4j-ruby-driver). It preserves the straightforward `Neo4jBolt` application API while delegating connections, pooling, Bolt negotiation, protocol state, PackStream, reconnects, and modern Neo4j value support to the upstream driver.
|
|
4
|
+
|
|
5
|
+
Neo4jBolt no longer implements the Bolt wire protocol itself.
|
|
6
|
+
|
|
7
|
+
`0.4.0` requires Ruby 3.4 or newer and pins `neo4j-ruby-driver` to `6.2.1.beta.4`. Applications on older Rubies can remain on the Neo4jBolt 0.3.x line; this prerelease is intentionally not an automatic upgrade for them.
|
|
20
8
|
|
|
21
9
|
## Installation
|
|
22
10
|
|
|
23
|
-
|
|
11
|
+
For this prerelease, specify the version explicitly:
|
|
24
12
|
|
|
25
13
|
```ruby
|
|
26
|
-
gem
|
|
14
|
+
gem "neo4j_bolt", "0.4.0"
|
|
27
15
|
```
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
$ bundle install
|
|
17
|
+
Then run `bundle install`. A running Neo4j database is required.
|
|
32
18
|
|
|
33
|
-
|
|
19
|
+
## Connecting
|
|
34
20
|
|
|
35
|
-
|
|
21
|
+
The existing host, port, and verbosity settings remain available:
|
|
36
22
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
```ruby
|
|
24
|
+
Neo4jBolt.bolt_host = "localhost"
|
|
25
|
+
Neo4jBolt.bolt_port = 7687
|
|
26
|
+
Neo4jBolt.bolt_verbosity = 0
|
|
41
27
|
```
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
## Connecting to a Neo4j database
|
|
46
|
-
|
|
47
|
-
Specify your Bolt host and port (if you omit this it will be localhost:7687 by default):
|
|
29
|
+
Applications can include the module as before:
|
|
48
30
|
|
|
49
31
|
```ruby
|
|
50
|
-
Neo4jBolt
|
|
51
|
-
Neo4jBolt.bolt_port = 7687
|
|
32
|
+
include Neo4jBolt
|
|
52
33
|
```
|
|
53
34
|
|
|
54
|
-
|
|
35
|
+
They can also extend another object or call the convenience methods directly on `Neo4jBolt`.
|
|
36
|
+
|
|
37
|
+
One lazily initialized upstream driver owns a thread-safe connection pool. Each standalone query uses a short-lived session and returns its connection to that pool after its result has been consumed. Queries from several Puma threads are not globally serialized.
|
|
38
|
+
|
|
39
|
+
`cleanup_neo4j` safely retires the driver and its pool after active operations finish. A later query creates a new driver. Do not call cleanup from inside an active query or transaction on the same thread.
|
|
55
40
|
|
|
56
41
|
## Running queries
|
|
57
42
|
|
|
58
|
-
|
|
43
|
+
Materialize all result rows:
|
|
59
44
|
|
|
60
45
|
```ruby
|
|
61
|
-
|
|
46
|
+
rows = neo4j_query("MATCH (person:Person) RETURN person.name AS name")
|
|
47
|
+
puts rows.first["name"]
|
|
62
48
|
```
|
|
63
|
-
|
|
49
|
+
|
|
50
|
+
Or process records incrementally without first materializing the complete result:
|
|
64
51
|
|
|
65
52
|
```ruby
|
|
66
|
-
neo4j_query("MATCH (
|
|
67
|
-
|
|
53
|
+
neo4j_query("MATCH (person:Person) RETURN person") do |row|
|
|
54
|
+
puts row["person"][:name]
|
|
68
55
|
end
|
|
69
56
|
```
|
|
70
57
|
|
|
71
|
-
|
|
58
|
+
The block form returns `nil`. Its upstream session, result, and pooled connection remain alive for the duration of iteration.
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
- `Neo4jBolt::Relationship` attributes: `id`, `start_node_id`, `end_node_id`, `type`
|
|
60
|
+
Parameters stay separate from Cypher:
|
|
75
61
|
|
|
76
62
|
```ruby
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
puts node.id
|
|
82
|
-
puts node.labels
|
|
83
|
-
puts node.keys
|
|
84
|
-
node.each_pair { |k, v| puts "#{k}: #{v}" }
|
|
85
|
-
puts node.to_json
|
|
86
|
-
puts "a: #{node[:a]}"
|
|
63
|
+
row = neo4j_query_expect_one(
|
|
64
|
+
"MATCH (person:Person {email: $email}) RETURN person",
|
|
65
|
+
email: "ada@example.test"
|
|
66
|
+
)
|
|
87
67
|
```
|
|
88
68
|
|
|
89
|
-
|
|
69
|
+
`neo4j_query_expect_one` raises `Neo4jBolt::ExpectedOneResultError` unless the query produces exactly one row.
|
|
70
|
+
|
|
71
|
+
### Result compatibility
|
|
72
|
+
|
|
73
|
+
Result-row keys are strings:
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
row["person"]
|
|
77
|
+
```
|
|
90
78
|
|
|
91
|
-
|
|
79
|
+
Nodes and relationships remain Hash subclasses whose property keys are symbols:
|
|
92
80
|
|
|
93
81
|
```ruby
|
|
94
|
-
node =
|
|
82
|
+
node = row["person"]
|
|
83
|
+
node[:name]
|
|
84
|
+
node.id
|
|
85
|
+
node.labels
|
|
86
|
+
node.element_id
|
|
95
87
|
```
|
|
96
88
|
|
|
97
|
-
|
|
89
|
+
`Neo4jBolt::Node` preserves `id` and `labels` and additively exposes `element_id`.
|
|
90
|
+
|
|
91
|
+
`Neo4jBolt::Relationship` preserves `id`, `start_node_id`, `end_node_id`, and `type`, and additively exposes `element_id`, `start_node_element_id`, and `end_node_element_id`.
|
|
92
|
+
|
|
93
|
+
Arrays and maps are adapted recursively. Map/property keys inside values are symbols, matching Neo4jBolt 0.3 behavior. Modern upstream values that 0.3 could not represent—such as temporal, spatial, path, byte, duration, and UUID values—pass through as upstream value objects. This is additive support.
|
|
94
|
+
|
|
95
|
+
Signed 64-bit integer limits are checked before transport. Out-of-range integers raise `Neo4jBolt::IntegerOutOfRangeError`.
|
|
98
96
|
|
|
99
|
-
##
|
|
97
|
+
## Transactions
|
|
100
98
|
|
|
101
|
-
|
|
99
|
+
The convenient compatibility API is unchanged:
|
|
102
100
|
|
|
103
101
|
```ruby
|
|
104
102
|
transaction do
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
neo4j_query("CREATE (:Person {name: 'Ada'})")
|
|
104
|
+
neo4j_query("CREATE (:Person {name: 'Grace'})")
|
|
107
105
|
end
|
|
108
106
|
```
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
Nested `transaction` blocks reuse one actual upstream session and transaction. Applications do not receive or pass an upstream transaction object.
|
|
111
109
|
|
|
112
|
-
|
|
110
|
+
Transaction context is isolated by calling thread and by the object using `Neo4jBolt`. Two threads using the same object receive independent upstream transactions and pooled connections.
|
|
113
111
|
|
|
114
|
-
|
|
112
|
+
Transactions are rollback-only after any nested operation raises, even if application code rescues the exception later. This includes database failures and `ExpectedOneResultError`:
|
|
115
113
|
|
|
116
114
|
```ruby
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
transaction do
|
|
116
|
+
neo4j_query("CREATE (:Marker)")
|
|
117
|
+
|
|
118
|
+
begin
|
|
119
|
+
neo4j_query("invalid cypher")
|
|
120
|
+
rescue Neo4jBolt::SyntaxError
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
# Nothing is committed.
|
|
120
124
|
```
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
- the `email` property of all nodes with label `User` must be unique
|
|
124
|
-
- the `sid` property of all nodes with label `Session` must be unique
|
|
125
|
-
- the `expires` property of all nodes with label `Session` gets indexed for faster lookup
|
|
126
|
+
Calling `rollback` inside a transaction marks that outer transaction rollback-only and returns `nil`. Calling it outside a transaction raises `Neo4jBolt::Error`; the old 0.3 implementation exposed the method but accidentally delegated to a nonexistent private implementation.
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
Upstream server/driver failures are translated to `Neo4jBolt::Error`. Syntax and uniqueness-constraint failures are translated narrowly to `Neo4jBolt::SyntaxError` and `Neo4jBolt::ConstraintValidationFailedError`. The upstream exception remains available as `error.cause`.
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
## Constraints and indexes
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
The existing setup format remains supported:
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
```ruby
|
|
135
|
+
setup_constraints_and_indexes(
|
|
136
|
+
["User/email", "Session/sid"],
|
|
137
|
+
["Session/expires"]
|
|
138
|
+
)
|
|
139
|
+
```
|
|
134
140
|
|
|
135
|
-
|
|
136
|
-
| ------- | ----------- |
|
|
137
|
-
| `neo4j_bolt console` | launch Pry console with Neo4jBolt |
|
|
138
|
-
| `neo4j_bolt clear` | remove all nodes and relationships, needs `--srsly` argument |
|
|
139
|
-
| `neo4j_bolt dump` | dump database contents |
|
|
140
|
-
| `neo4j_bolt load` | load database dump |
|
|
141
|
-
| `neo4j_bolt index ls` | list all database constraints and indexes |
|
|
142
|
-
| `neo4j_bolt index rm` | remove all constraints and indexes, needs `-f` |
|
|
143
|
-
| `neo4j_bolt visualize` | generates a visual representation of the current datbase contents |
|
|
141
|
+
Managed entries retain the `neo4j_bolt_` prefix. Setup removes obsolete entries with that prefix only; it does not remove arbitrary application-defined indexes or constraints.
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
## Dump and load
|
|
146
144
|
|
|
147
|
-
|
|
145
|
+
The textual format is unchanged:
|
|
148
146
|
|
|
149
|
-
|
|
147
|
+
```text
|
|
148
|
+
n {"id":0,"labels":["Person"],"properties":{"name":"Ada"}}
|
|
149
|
+
n {"id":1,"labels":["Person"],"properties":{"name":"Grace"}}
|
|
150
|
+
r {"from":0,"to":1,"type":"KNOWS","properties":{"since":2024}}
|
|
151
|
+
```
|
|
150
152
|
|
|
151
|
-
|
|
153
|
+
```ruby
|
|
154
|
+
File.open("database.dump", "w") { |io| dump_database(io, progress_io: $stderr) }
|
|
155
|
+
File.open("database.dump", "r") do |io|
|
|
156
|
+
load_database_dump(io, progress_io: $stderr)
|
|
157
|
+
end
|
|
158
|
+
```
|
|
152
159
|
|
|
153
|
-
|
|
160
|
+
Passing `progress_io:` is optional for the Ruby API. The CLI always reports dump/load progress on stderr, so dump data written to stdout remains safe to redirect or pipe. Terminal progress is updated in place; redirected stderr receives periodic progress lines.
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
The `0, 1, 2, ...` IDs are synthetic dump-local IDs. Database-internal IDs and element IDs are never written to the persistent format. Dumping keeps the count, node, and relationship reads in one transaction, so the driver-provided entity identity used to connect the two streamed result sets stays within Neo4j's transaction-scoped identity guarantee. To keep dump numbering deterministic, ordering uses `elementId()` on modern Neo4j and an internal `id()` fallback only on Neo4j 4.4, where `elementId()` does not exist. Old Neo4jBolt dumps remain loadable.
|
|
156
163
|
|
|
157
|
-
|
|
164
|
+
For relational loads, the adapter assigns a random temporary label and dump-ID property to imported nodes. After the nodes are committed it builds a temporary `neo4j_bolt_` index on that property, uses indexed lookups while creating relationships, drops the index, and removes the temporary metadata in batches. No database-internal identity is carried from one load transaction to another. Loading a relational dump therefore requires permission to create and drop an index.
|
|
158
165
|
|
|
159
|
-
|
|
166
|
+
Loads start with batches of 5,000 records by default. This is an initial ceiling rather than a claimed optimum: if Neo4j returns a transaction-memory/resource error whose server semantics guarantee rollback, the loader halves the failed batch and retries it, then keeps the smaller size for the rest of that phase. Node and relationship phases adapt independently. Other errors are not retried, because a generic connection failure cannot safely prove that a `CREATE` transaction did not commit. Callers can change the initial ceiling with `initial_batch_size:`; the CLI exposes the same setting as `--batch-size`.
|
|
160
167
|
|
|
161
|
-
|
|
168
|
+
Loading requires an empty database unless `force_append: true` is passed. `load_database_dump` owns its batch transactions and therefore rejects being called from inside `transaction`.
|
|
162
169
|
|
|
163
|
-
|
|
170
|
+
## CLI
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
The `neo4j_bolt` executable retains these commands:
|
|
166
173
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
| Command | Purpose |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| `neo4j_bolt console` | Open an IRB console with Neo4jBolt loaded |
|
|
177
|
+
| `neo4j_bolt clear --srsly` | Delete all nodes and relationships |
|
|
178
|
+
| `neo4j_bolt dump` | Write the textual database dump |
|
|
179
|
+
| `neo4j_bolt load [--force] [--batch-size N] PATH` | Load a textual dump |
|
|
180
|
+
| `neo4j_bolt index ls` | List constraints and indexes |
|
|
181
|
+
| `neo4j_bolt index rm --force` | Remove all constraints and indexes |
|
|
182
|
+
| `neo4j_bolt visualize` | Generate a GraphViz document |
|
|
170
183
|
|
|
171
|
-
|
|
184
|
+
Use `--host HOST:PORT` to select a server. `gli` remains a runtime dependency for the CLI, and `pry` remains for the separate `bin/console` executable.
|
|
172
185
|
|
|
173
|
-
|
|
174
|
-
./bin/neo4j_bolt visualize | docker run --rm -i nshine/dot dot -Tsvg > graph.svg
|
|
175
|
-
```
|
|
186
|
+
## Tested Neo4j versions
|
|
176
187
|
|
|
177
|
-
The
|
|
188
|
+
The same complete integration suite is run against these exact Community images:
|
|
178
189
|
|
|
179
|
-
|
|
190
|
+
- `neo4j:4.4.48-community`
|
|
191
|
+
- `neo4j:5.26.28-community`
|
|
192
|
+
- `neo4j:2026.06.0-community`
|
|
180
193
|
|
|
181
|
-
|
|
194
|
+
No compatibility beyond this matrix is claimed for `0.4.0`.
|
|
182
195
|
|
|
183
|
-
|
|
196
|
+
Run one modern LTS target:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
bundle exec rake spec
|
|
200
|
+
```
|
|
184
201
|
|
|
185
|
-
|
|
202
|
+
Run the complete sequential matrix:
|
|
186
203
|
|
|
187
|
-
|
|
204
|
+
```bash
|
|
205
|
+
bundle exec rake spec:matrix
|
|
206
|
+
```
|
|
188
207
|
|
|
189
|
-
|
|
208
|
+
The harness creates uniquely named disposable containers with `NEO4J_AUTH=none`, dynamically publishes Bolt ports, waits by establishing a real driver/query connection, and cleans every container through shell traps. A developer does not need to start Neo4j manually.
|
|
209
|
+
|
|
210
|
+
To point RSpec itself at an already disposable database, set `NEO4J_BOLT_TEST_HOST` and `NEO4J_BOLT_TEST_PORT`. The explicit port requirement protects real databases from the destructive integration suite.
|
|
211
|
+
|
|
212
|
+
## Compatibility inventory for 0.4
|
|
213
|
+
|
|
214
|
+
| API | Status |
|
|
215
|
+
| --- | --- |
|
|
216
|
+
| `bolt_host`, `bolt_port`, `bolt_verbosity` | Preserved |
|
|
217
|
+
| Included/extended/module-style use | Preserved |
|
|
218
|
+
| `neo4j_query`, including incremental block form | Preserved via adapter |
|
|
219
|
+
| `neo4j_query_expect_one` | Preserved via adapter |
|
|
220
|
+
| `transaction`, nesting, rollback-only behavior | Preserved via thread-local adapter |
|
|
221
|
+
| `rollback` | Preserved and repaired as rollback-only |
|
|
222
|
+
| `cleanup_neo4j`, `wait_for_neo4j` | Preserved via pooled driver lifecycle |
|
|
223
|
+
| `setup_constraints_and_indexes` | Preserved with current Cypher |
|
|
224
|
+
| `dump_database`, `load_database_dump` | Preserved; relationship reconstruction modernized |
|
|
225
|
+
| Named error classes | Preserved with narrow upstream translation |
|
|
226
|
+
| `Node` and `Relationship` Hash behavior | Preserved via recursive value adapter |
|
|
227
|
+
| Element identity and modern values | Additive behavior |
|
|
228
|
+
| CLI commands | Preserved |
|
|
229
|
+
| `BoltSocket`, `BoltBuffer`, protocol markers/state/parser/packer | Intentionally removed private implementation details |
|
|
230
|
+
|
|
231
|
+
## 0.4.0 migration notes
|
|
232
|
+
|
|
233
|
+
- Ruby 3.4 or newer is required; Ruby 2.x/3.0–3.3 applications should stay on 0.3.x until upgraded.
|
|
234
|
+
- The exact prerelease upstream dependency is pinned while no stable `neo4j-ruby-driver` 6.2.x exists.
|
|
235
|
+
- Connections are pooled and safe for concurrent use instead of one mutable socket per including object.
|
|
236
|
+
- TLS, routing, authentication, database selection, and other upstream-driver configuration are not newly exposed through the legacy three-setting API in this compatibility prerelease.
|
|
237
|
+
- `BoltSocket`, `BoltBuffer`, `ServerState`, `BoltMarker`, `UnexpectedServerResponse`, `State`, and `CypherError` were undocumented wire internals and are removed.
|
|
190
238
|
|
|
191
|
-
|
|
239
|
+
## Development
|
|
192
240
|
|
|
193
|
-
|
|
241
|
+
Run `bin/setup`, then `bundle exec rake spec` or `bundle exec rake spec:matrix`. Build without publishing with `bundle exec rake build`.
|
|
194
242
|
|
|
195
|
-
Bug reports and pull requests are welcome
|
|
243
|
+
Bug reports and pull requests are welcome at <https://github.com/specht/neo4j_bolt>.
|
|
196
244
|
|
data/bin/neo4j_bolt
CHANGED
|
@@ -49,7 +49,7 @@ class App
|
|
|
49
49
|
c.flag [:o, 'out-file'.to_sym], :default_value => '/dev/stdout'
|
|
50
50
|
c.action do |global_options, options|
|
|
51
51
|
File.open(options['out-file'.to_sym], 'w') do |f|
|
|
52
|
-
dump_database(f)
|
|
52
|
+
dump_database(f, progress_io: $stderr)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -61,11 +61,18 @@ class App
|
|
|
61
61
|
command :load do |c|
|
|
62
62
|
# c.flag [:i, :in_file], :desc => 'input path', :required => true
|
|
63
63
|
c.switch [:f, :force], :default_value => false, :desc => 'force appending nodes even if the database is not empty'
|
|
64
|
+
c.flag [:b, 'batch-size'.to_sym], :default_value => Neo4jBolt::LOAD_INITIAL_BATCH_SIZE,
|
|
65
|
+
:desc => 'initial batch size; automatically reduced on transaction-memory errors'
|
|
64
66
|
c.action do |global_options, options, args|
|
|
65
67
|
help_now!('input path is required') if args.empty?
|
|
66
68
|
path = args.shift
|
|
67
69
|
File.open(path, 'r') do |f|
|
|
68
|
-
load_database_dump(
|
|
70
|
+
load_database_dump(
|
|
71
|
+
f,
|
|
72
|
+
force_append: options[:force],
|
|
73
|
+
progress_io: $stderr,
|
|
74
|
+
initial_batch_size: options['batch-size'.to_sym]
|
|
75
|
+
)
|
|
69
76
|
end
|
|
70
77
|
end
|
|
71
78
|
end
|
|
@@ -92,10 +99,10 @@ class App
|
|
|
92
99
|
command :index do |c|
|
|
93
100
|
c.command :ls do |c2|
|
|
94
101
|
c2.action do |global_options, options, args|
|
|
95
|
-
neo4j_query("SHOW
|
|
102
|
+
neo4j_query("SHOW CONSTRAINTS") do |row|
|
|
96
103
|
puts "#{row['type']} #{row['name']} #{(row['labelsOrTypes'] || []).join('/')}/#{(row['properties'] || []).join('/')}"
|
|
97
104
|
end
|
|
98
|
-
neo4j_query("SHOW
|
|
105
|
+
neo4j_query("SHOW INDEXES") do |row|
|
|
99
106
|
puts "#{row['uniqueness']} #{row['entityType']} #{row['state']} #{row['populationPercent']}% #{row['name']} #{(row['labelsOrTypes'] || []).join('/')}/#{(row['properties'] || []).join('/')}"
|
|
100
107
|
end
|
|
101
108
|
end
|
|
@@ -106,10 +113,10 @@ class App
|
|
|
106
113
|
if options[:force]
|
|
107
114
|
all_constraints = []
|
|
108
115
|
all_indexes = []
|
|
109
|
-
neo4j_query("SHOW
|
|
116
|
+
neo4j_query("SHOW CONSTRAINTS") do |row|
|
|
110
117
|
all_constraints << row['name']
|
|
111
118
|
end
|
|
112
|
-
neo4j_query("SHOW
|
|
119
|
+
neo4j_query("SHOW INDEXES") do |row|
|
|
113
120
|
all_indexes << row['name']
|
|
114
121
|
end
|
|
115
122
|
transaction do
|
|
@@ -242,7 +249,7 @@ class App
|
|
|
242
249
|
'BTREE' => 'indexed',
|
|
243
250
|
}
|
|
244
251
|
|
|
245
|
-
['SHOW
|
|
252
|
+
['SHOW CONSTRAINTS', 'SHOW INDEXES'].each do |query|
|
|
246
253
|
neo4j_query(query) do |row|
|
|
247
254
|
# STDERR.puts row.to_json
|
|
248
255
|
labels_or_types = row['labelsOrTypes'] || []
|
data/lib/neo4j_bolt/version.rb
CHANGED