neo4j 8.0.0.rc.2 → 8.0.0.rc.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec796ebdd559718bc9e676e1d7e6b9d6a3d61a75
4
- data.tar.gz: 79205b437861d5d425d03a459c64f569c7eb5d8f
3
+ metadata.gz: 31ce9e5bebd684174609471aad17082021face51
4
+ data.tar.gz: d54842495024cd8df255e9b9a2abcb061ffa03e5
5
5
  SHA512:
6
- metadata.gz: 9d72b20484dbaf7d9f92acf28937f9d6566bb7f0ebfd296304c537361db791059e47be94c5eeeb5b76b7fcc6add715d9cae0243e23f8d5aca36dcafbcf22ad83
7
- data.tar.gz: 49cd9a0371d427292e52a4781b309b05964ed002213775ffce8a2ee749379bce61d9d71cdd2b29613b96d6f56cfdf07f1fedd0c433d86d59c486cac08328f846
6
+ metadata.gz: bdaf705709a16d870e42f31dcebd664c33bcd4810341975eaa2ea3d1d1e6ab4b0ec05cba3d9716d54dde200b3400a3a34312d9dc26067ad1d353b0e0e56a240d
7
+ data.tar.gz: 0bdee81e2b4e35f3abc1087d778ee01bffed4be0495dd0fda0f3fb23ca4090bdb2d908d514b904c2016002161d286d302fd3f1e83a28fae389cf789ef30d498f
data/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.
3
3
  This file should follow the standards specified on [http://keepachangelog.com/]
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [Unreleased]
7
+
8
+ ## [8.0.0.rc.3] 2016-10-12
9
+
10
+ # Added
11
+
12
+ - `distinct` method for QueryProxy (thanks @ProGM / see #1305)
13
+ - Added `update_node_property` / `update_node_properties` (aliased as `update_column` / `update_columns`)
14
+
6
15
  ## [8.0.0.rc.2] 2016-10-07
7
16
 
8
17
  ### Fixed
@@ -18,6 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
27
  ### Added
19
28
 
20
29
  - Add support for undeclared properties on specific models (see #1294 / thanks @klobuczek)
30
+ - Add `update_node_property` and `update_node_properties` methods, aliased as `update_column` and `update_columns`, to persist changes without triggering validations, callbacks, timestamps, etc,...
21
31
 
22
32
  ## [8.0.0.alpha.12] 2016-09-29
23
33
 
@@ -20,7 +20,7 @@ module Neo4j
20
20
  return result_cache_for(node, rel) if result_cache?(node, rel)
21
21
 
22
22
  pluck_vars = []
23
- pluck_vars << identity if node
23
+ pluck_vars << ensure_distinct(identity) if node
24
24
  pluck_vars << @rel_var if rel
25
25
 
26
26
  result = pluck(*pluck_vars)
@@ -87,6 +87,12 @@ module Neo4j
87
87
 
88
88
  self.query.pluck(*arg_list)
89
89
  end
90
+
91
+ protected
92
+
93
+ def ensure_distinct(node, force = false)
94
+ @distinct || force ? "DISTINCT(#{node})" : node
95
+ end
90
96
  end
91
97
  end
92
98
  end
@@ -41,12 +41,18 @@ module Neo4j
41
41
  model ? model.id_property_name : nil
42
42
  end
43
43
 
44
+ def distinct
45
+ new_link.tap do |e|
46
+ e.instance_variable_set(:@distinct, true)
47
+ end
48
+ end
49
+
44
50
  # @return [Integer] number of nodes of this class
45
51
  def count(distinct = nil, target = nil)
46
52
  return 0 if unpersisted_start_object?
47
53
  fail(Neo4j::InvalidParameterError, ':count accepts `distinct` or nil as a parameter') unless distinct.nil? || distinct == :distinct
48
54
  query_with_target(target) do |var|
49
- q = distinct.nil? ? var : "DISTINCT #{var}"
55
+ q = ensure_distinct(var, !distinct.nil?)
50
56
  limited_query = self.query.clause?(:limit) ? self.query.break.with(var) : self.query.reorder
51
57
  limited_query.pluck("count(#{q}) AS #{var}").first
52
58
  end
@@ -189,6 +189,25 @@ module Neo4j::Shared
189
189
  end
190
190
  alias update_attributes update
191
191
 
192
+ def update_db_property(field, value)
193
+ update_db_properties(field => value)
194
+ true
195
+ end
196
+ alias update_column update_db_property
197
+
198
+ def update_db_properties(hash)
199
+ fail ::Neo4j::Error, 'can not update on a new record object' unless persisted?
200
+ self.class.run_transaction do
201
+ db_values = props_for_db(hash)
202
+ neo4j_query(query_as(:n).set(n: db_values))
203
+ db_values.each_pair { |k, v| self.public_send(:"#{k}=", v) }
204
+ _persisted_obj.props.merge!(db_values)
205
+ db_values.each_key { |k| changed_attributes.delete(k) }
206
+ true
207
+ end
208
+ end
209
+ alias update_columns update_db_properties
210
+
192
211
  # Same as {#update_attributes}, but raises an exception if saving fails.
193
212
  def update!(attributes)
194
213
  self.class.run_transaction do
data/lib/neo4j/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = '8.0.0.rc.2'
2
+ VERSION = '8.0.0.rc.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0.rc.2
4
+ version: 8.0.0.rc.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orm_adapter
@@ -372,3 +372,4 @@ signing_key:
372
372
  specification_version: 4
373
373
  summary: A graph database for Ruby
374
374
  test_files: []
375
+ has_rdoc: true