neo4j 8.0.0.alpha.12 → 8.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -2
- data/lib/neo4j.rb +1 -0
- data/lib/neo4j/migrations.rb +1 -0
- data/lib/neo4j/migrations/check_pending.rb +19 -0
- data/lib/neo4j/migrations/runner.rb +27 -17
- data/lib/neo4j/railtie.rb +2 -2
- data/lib/neo4j/shared/mass_assignment.rb +7 -1
- data/lib/neo4j/shared/persistence.rb +10 -4
- data/lib/neo4j/shared/property.rb +3 -0
- data/lib/neo4j/tasks/migration.rake +2 -2
- data/lib/neo4j/undeclared_properties.rb +53 -0
- data/lib/neo4j/version.rb +1 -1
- data/neo4j.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f958f5ab64ca55f0c33a3bcd9680773a604c54
|
4
|
+
data.tar.gz: 6d61a3310ec123a99703b1958072d97a57c279be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 946355cd23bf4c589dbaa651d73896ebc7a87fb9717d8827a4f3f4c0e801fb67ba2299875f2f3c5edc970bd3f1183e52c8573cce5eb2405d73c2b8d87760625c
|
7
|
+
data.tar.gz: f9e7e33a203f1f32e85f4ff3eab979e216b2a8b09b8901c7be9378e8f2d5cadc2f8385abe7d648f90dd898e52870305047083d65378ad5d73c00b07c4a95c218
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +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
|
-
## [
|
6
|
+
## [8.0.0.rc.1] 2016-10-04
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
|
10
|
+
- Pending migrations check, now using a Rack Middleware instead of failing on startup (thanks @ProGM / see #1300)
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Add support for undeclared properties on specific models (see #1294 / thanks @klobuczek)
|
7
15
|
|
8
16
|
## [8.0.0.alpha.12] 2016-09-29
|
9
17
|
|
@@ -22,7 +30,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
22
30
|
- `update` was not rolling-back association changes when validations fail
|
23
31
|
- Broken Rails `neo4j:migrate_v8` generator
|
24
32
|
|
25
|
-
|
33
|
+
### Changed
|
26
34
|
- `count` method in associations, now always fire the database like AR does
|
27
35
|
- Neo4j now passes all association validations specs, taken from AR (thanks @klobuczek)
|
28
36
|
|
data/lib/neo4j.rb
CHANGED
data/lib/neo4j/migrations.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Neo4j
|
2
|
+
module Migrations
|
3
|
+
class CheckPending
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
@last_check = 0
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
mtime = Neo4j::Migrations::Runner.latest_migration.version.to_i
|
11
|
+
if @last_check < mtime
|
12
|
+
Neo4j::Migrations.check_for_pending_migrations!
|
13
|
+
@last_check = mtime
|
14
|
+
end
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -141,31 +141,41 @@ MSG
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def all_migrations
|
144
|
-
@up_versions +
|
145
|
-
end
|
146
|
-
|
147
|
-
def files_versions
|
148
|
-
migration_files.map(&:version)
|
149
|
-
end
|
150
|
-
|
151
|
-
def migration_files
|
152
|
-
files.map { |file_path| MigrationFile.new(file_path) }
|
144
|
+
@up_versions + migration_files_versions
|
153
145
|
end
|
154
146
|
|
155
147
|
def incomplete_states
|
156
148
|
@incomplete_states ||= SortedSet.new(@schema_migrations.select(&:incomplete?))
|
157
149
|
end
|
158
150
|
|
159
|
-
|
160
|
-
Dir[files_path].sort
|
161
|
-
end
|
151
|
+
delegate :migration_files, :migration_files_versions, to: :class
|
162
152
|
|
163
|
-
|
164
|
-
|
165
|
-
|
153
|
+
class <<self
|
154
|
+
def migration_files_versions
|
155
|
+
migration_files.map!(&:version)
|
156
|
+
end
|
157
|
+
|
158
|
+
def migration_files
|
159
|
+
files.map! { |file_path| MigrationFile.new(file_path) }
|
160
|
+
end
|
166
161
|
|
167
|
-
|
168
|
-
|
162
|
+
def latest_migration
|
163
|
+
migration_files.last
|
164
|
+
end
|
165
|
+
|
166
|
+
def files
|
167
|
+
Dir[files_path].sort
|
168
|
+
end
|
169
|
+
|
170
|
+
private
|
171
|
+
|
172
|
+
def files_path
|
173
|
+
app_root.join('db', 'neo4j', 'migrate', '*.rb')
|
174
|
+
end
|
175
|
+
|
176
|
+
def app_root
|
177
|
+
defined?(Rails) ? Rails.root : Pathname.new('.')
|
178
|
+
end
|
169
179
|
end
|
170
180
|
end
|
171
181
|
end
|
data/lib/neo4j/railtie.rb
CHANGED
@@ -56,8 +56,8 @@ module Neo4j
|
|
56
56
|
|
57
57
|
Neo4j::Config[:logger] ||= Rails.logger
|
58
58
|
|
59
|
-
if
|
60
|
-
Neo4j::Migrations
|
59
|
+
if Neo4j::Config.fail_on_pending_migrations
|
60
|
+
config.app_middleware.insert_after ::ActionDispatch::Callbacks, Neo4j::Migrations::CheckPending
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -26,10 +26,16 @@ module Neo4j::Shared
|
|
26
26
|
return unless new_attributes.present?
|
27
27
|
new_attributes.each do |name, value|
|
28
28
|
writer = :"#{name}="
|
29
|
-
|
29
|
+
if respond_to?(writer)
|
30
|
+
send(writer, value)
|
31
|
+
else
|
32
|
+
add_undeclared_property(name, value)
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
37
|
+
def add_undeclared_property(_, _); end
|
38
|
+
|
33
39
|
# Mass update a model's attributes
|
34
40
|
#
|
35
41
|
# @example Assigning a hash
|
@@ -10,11 +10,17 @@ module Neo4j::Shared
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def update_model
|
13
|
-
return if
|
14
|
-
|
13
|
+
return if skip_update?
|
14
|
+
props = props_for_update
|
15
|
+
neo4j_query(query_as(:n).set(n: props))
|
16
|
+
_persisted_obj.props.merge!(props)
|
15
17
|
changed_attributes.clear
|
16
18
|
end
|
17
19
|
|
20
|
+
def skip_update?
|
21
|
+
changed_attributes.blank?
|
22
|
+
end
|
23
|
+
|
18
24
|
# Returns a hash containing:
|
19
25
|
# * All properties and values for insertion in the database
|
20
26
|
# * A `uuid` (or equivalent) key and value
|
@@ -66,7 +72,7 @@ module Neo4j::Shared
|
|
66
72
|
# @param [Symbol, String] attribute of the attribute to update
|
67
73
|
# @param [Object] value to set
|
68
74
|
def update_attribute(attribute, value)
|
69
|
-
|
75
|
+
write_attribute(attribute, value)
|
70
76
|
self.save
|
71
77
|
end
|
72
78
|
|
@@ -74,7 +80,7 @@ module Neo4j::Shared
|
|
74
80
|
# @param [Symbol, String] attribute of the attribute to update
|
75
81
|
# @param [Object] value to set
|
76
82
|
def update_attribute!(attribute, value)
|
77
|
-
|
83
|
+
write_attribute(attribute, value)
|
78
84
|
self.save!
|
79
85
|
end
|
80
86
|
|
@@ -26,9 +26,12 @@ module Neo4j::Shared
|
|
26
26
|
validate_attributes!(modded_attributes)
|
27
27
|
writer_method_props = extract_writer_methods!(modded_attributes)
|
28
28
|
send_props(writer_method_props)
|
29
|
+
self.undeclared_properties = attributes
|
29
30
|
@_persisted_obj = nil
|
30
31
|
end
|
31
32
|
|
33
|
+
def undeclared_properties=(_); end
|
34
|
+
|
32
35
|
def inject_defaults!(starting_props)
|
33
36
|
return starting_props if self.class.declared_properties.declared_property_defaults.empty?
|
34
37
|
self.class.declared_properties.inject_defaults!(self, starting_props || {})
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'active_support/concern'
|
2
2
|
require 'neo4j/migration'
|
3
3
|
|
4
|
-
|
4
|
+
if !defined?(Rails) && !Rake::Task.task_defined?('environment')
|
5
5
|
desc 'Run a script against the database to perform system-wide changes'
|
6
6
|
task :environment do
|
7
7
|
require 'neo4j/session_manager'
|
@@ -84,7 +84,7 @@ namespace :neo4j do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
desc 'Rollbacks migrations given a STEP number'
|
87
|
-
task :
|
87
|
+
task rollback: [:allow_migrations, :environment] do
|
88
88
|
steps = (ENV['STEP'] || 1).to_i
|
89
89
|
runner = Neo4j::Migrations::Runner.new
|
90
90
|
runner.rollback(steps)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Neo4j
|
2
|
+
# This mixin allows storage and update of undeclared properties in the included class
|
3
|
+
module UndeclaredProperties
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attr_accessor :undeclared_properties
|
8
|
+
end
|
9
|
+
|
10
|
+
def validate_attributes!(_)
|
11
|
+
end
|
12
|
+
|
13
|
+
def read_attribute(name)
|
14
|
+
respond_to?(name) ? super(name) : read_undeclared_property(name.to_sym)
|
15
|
+
end
|
16
|
+
alias [] read_attribute
|
17
|
+
|
18
|
+
def read_undeclared_property(name)
|
19
|
+
_persisted_obj ? _persisted_obj.props[name] : (undeclared_properties && undeclared_properties[name])
|
20
|
+
end
|
21
|
+
|
22
|
+
def write_attribute(name, value)
|
23
|
+
if respond_to? "#{name}="
|
24
|
+
super(name, value)
|
25
|
+
else
|
26
|
+
add_undeclared_property(name, value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
alias []= write_attribute
|
30
|
+
|
31
|
+
def skip_update?
|
32
|
+
super && undeclared_properties.blank?
|
33
|
+
end
|
34
|
+
|
35
|
+
def props_for_create
|
36
|
+
super.merge(undeclared_properties!)
|
37
|
+
end
|
38
|
+
|
39
|
+
def props_for_update
|
40
|
+
super.merge(undeclared_properties!)
|
41
|
+
end
|
42
|
+
|
43
|
+
def undeclared_properties!
|
44
|
+
undeclared_properties || {}
|
45
|
+
ensure
|
46
|
+
self.undeclared_properties = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_undeclared_property(name, value)
|
50
|
+
(self.undeclared_properties ||= {})[name] = value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/neo4j/version.rb
CHANGED
data/neo4j.gemspec
CHANGED
@@ -30,7 +30,7 @@ A Neo4j OGM (Object-Graph-Mapper) for use in Ruby on Rails and Rack frameworks h
|
|
30
30
|
s.add_dependency('orm_adapter', '~> 0.5.0')
|
31
31
|
s.add_dependency('activemodel', '>= 4.0', '< 5.1')
|
32
32
|
s.add_dependency('activesupport', '>= 4.0', '< 5.1')
|
33
|
-
s.add_dependency('neo4j-core', '>= 7.0.0.
|
33
|
+
s.add_dependency('neo4j-core', '>= 7.0.0.rc.1')
|
34
34
|
s.add_dependency('neo4j-community', '~> 2.0') if RUBY_PLATFORM =~ /java/
|
35
35
|
s.add_development_dependency('railties', '>= 4.0', '< 5.1')
|
36
36
|
s.add_development_dependency('pry')
|
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.
|
4
|
+
version: 8.0.0.rc.1
|
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-
|
11
|
+
date: 2016-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: orm_adapter
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 7.0.0.
|
73
|
+
version: 7.0.0.rc.1
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: 7.0.0.
|
80
|
+
version: 7.0.0.rc.1
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: railties
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- lib/neo4j/migration.rb
|
288
288
|
- lib/neo4j/migrations.rb
|
289
289
|
- lib/neo4j/migrations/base.rb
|
290
|
+
- lib/neo4j/migrations/check_pending.rb
|
290
291
|
- lib/neo4j/migrations/helpers.rb
|
291
292
|
- lib/neo4j/migrations/helpers/id_property.rb
|
292
293
|
- lib/neo4j/migrations/helpers/relationships.rb
|
@@ -327,6 +328,7 @@ files:
|
|
327
328
|
- lib/neo4j/timestamps/created.rb
|
328
329
|
- lib/neo4j/timestamps/updated.rb
|
329
330
|
- lib/neo4j/type_converters.rb
|
331
|
+
- lib/neo4j/undeclared_properties.rb
|
330
332
|
- lib/neo4j/version.rb
|
331
333
|
- lib/neo4j/wrapper.rb
|
332
334
|
- lib/rails/generators/neo4j/migration/migration_generator.rb
|