neo4j 7.2.3 → 8.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -46
  3. data/Gemfile +15 -14
  4. data/README.md +21 -14
  5. data/bin/neo4j-jars +1 -1
  6. data/lib/neo4j.rb +12 -1
  7. data/lib/neo4j/active_base.rb +68 -0
  8. data/lib/neo4j/active_base/session_registry.rb +12 -0
  9. data/lib/neo4j/active_node.rb +13 -21
  10. data/lib/neo4j/active_node/dependent/query_proxy_methods.rb +6 -6
  11. data/lib/neo4j/active_node/enum.rb +3 -6
  12. data/lib/neo4j/active_node/has_n.rb +24 -19
  13. data/lib/neo4j/active_node/has_n/association.rb +6 -2
  14. data/lib/neo4j/active_node/has_n/association/rel_factory.rb +1 -1
  15. data/lib/neo4j/active_node/has_n/association/rel_wrapper.rb +1 -1
  16. data/lib/neo4j/active_node/has_n/association_cypher_methods.rb +1 -1
  17. data/lib/neo4j/active_node/id_property.rb +52 -15
  18. data/lib/neo4j/active_node/labels.rb +32 -10
  19. data/lib/neo4j/active_node/labels/index.rb +5 -55
  20. data/lib/neo4j/active_node/node_list_formatter.rb +13 -0
  21. data/lib/neo4j/active_node/node_wrapper.rb +39 -37
  22. data/lib/neo4j/active_node/persistence.rb +27 -13
  23. data/lib/neo4j/active_node/query/query_proxy.rb +11 -9
  24. data/lib/neo4j/active_node/query/query_proxy_eager_loading.rb +4 -4
  25. data/lib/neo4j/active_node/query/query_proxy_enumerable.rb +1 -0
  26. data/lib/neo4j/active_node/query/query_proxy_link.rb +13 -9
  27. data/lib/neo4j/active_node/query/query_proxy_methods.rb +76 -8
  28. data/lib/neo4j/active_node/query/query_proxy_methods_of_mass_updating.rb +1 -1
  29. data/lib/neo4j/active_node/query_methods.rb +3 -3
  30. data/lib/neo4j/active_node/scope.rb +24 -7
  31. data/lib/neo4j/active_rel.rb +21 -3
  32. data/lib/neo4j/active_rel/initialize.rb +2 -2
  33. data/lib/neo4j/active_rel/persistence.rb +32 -6
  34. data/lib/neo4j/active_rel/persistence/query_factory.rb +3 -3
  35. data/lib/neo4j/active_rel/property.rb +9 -9
  36. data/lib/neo4j/active_rel/query.rb +6 -4
  37. data/lib/neo4j/active_rel/rel_wrapper.rb +24 -16
  38. data/lib/neo4j/active_rel/related_node.rb +5 -1
  39. data/lib/neo4j/active_rel/types.rb +2 -2
  40. data/lib/neo4j/config.rb +0 -1
  41. data/lib/neo4j/errors.rb +3 -0
  42. data/lib/neo4j/migration.rb +90 -71
  43. data/lib/neo4j/migrations.rb +10 -0
  44. data/lib/neo4j/migrations/base.rb +44 -0
  45. data/lib/neo4j/migrations/helpers.rb +101 -0
  46. data/lib/neo4j/migrations/helpers/id_property.rb +75 -0
  47. data/lib/neo4j/migrations/helpers/relationships.rb +66 -0
  48. data/lib/neo4j/migrations/helpers/schema.rb +53 -0
  49. data/lib/neo4j/migrations/migration_file.rb +24 -0
  50. data/lib/neo4j/migrations/runner.rb +110 -0
  51. data/lib/neo4j/migrations/schema_migration.rb +9 -0
  52. data/lib/neo4j/model_schema.rb +100 -0
  53. data/lib/neo4j/railtie.rb +29 -110
  54. data/lib/neo4j/schema/operation.rb +24 -13
  55. data/lib/neo4j/session_manager.rb +137 -0
  56. data/lib/neo4j/shared.rb +20 -11
  57. data/lib/neo4j/shared/attributes.rb +10 -16
  58. data/lib/neo4j/shared/callbacks.rb +3 -3
  59. data/lib/neo4j/shared/cypher.rb +1 -1
  60. data/lib/neo4j/shared/declared_properties.rb +1 -1
  61. data/lib/neo4j/shared/declared_property.rb +1 -1
  62. data/lib/neo4j/shared/enum.rb +6 -18
  63. data/lib/neo4j/shared/identity.rb +27 -21
  64. data/lib/neo4j/shared/persistence.rb +26 -17
  65. data/lib/neo4j/shared/property.rb +5 -2
  66. data/lib/neo4j/shared/query_factory.rb +4 -5
  67. data/lib/neo4j/shared/type_converters.rb +8 -9
  68. data/lib/neo4j/shared/validations.rb +1 -5
  69. data/lib/neo4j/tasks/migration.rake +83 -2
  70. data/lib/neo4j/version.rb +1 -1
  71. data/lib/rails/generators/neo4j/migration/migration_generator.rb +14 -0
  72. data/lib/rails/generators/neo4j/migration/templates/migration.erb +9 -0
  73. data/lib/rails/generators/neo4j/model/model_generator.rb +1 -3
  74. data/lib/rails/generators/neo4j_generator.rb +1 -0
  75. data/neo4j.gemspec +3 -3
  76. metadata +58 -65
  77. data/bin/rake +0 -17
  78. data/lib/neo4j/shared/permitted_attributes.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10c4a3071672ec1cbeeaf8c16a827491adf838ce
4
- data.tar.gz: e372ea171b766c38f20ce48919e7c38f77e58a26
3
+ metadata.gz: ae62feb1503e7f65d35cbc182034a65a28c9361b
4
+ data.tar.gz: 5ddeb82fa562a1868c1a6b5d8898c5b0dca80276
5
5
  SHA512:
6
- metadata.gz: 4d1037a455e81fe4791f0c6ee1427eb1949a2b689ebf6a536046c0536bc2ecb62690ee0ac615e12bc099a60460372782bb558d2c378c5eb65d50f0550467d54d
7
- data.tar.gz: 1b86a45979724c810b9dfdc137aa66f77b3705697dd9d0e6d6dabfdb5e934f02ac1e5c508f17a9be09e9588642edddbbb7e4059da3ce06e25daf5d1885d0a79e
6
+ metadata.gz: 8acc45e1a6fa2cc4c314558f12b737ab2ffa0c30b914244672839da5f7ab9a64ea4194f39d9e4b90cb6f85e7a32b10b2f73c52eedd28c5d4bf072828881d4acc
7
+ data.tar.gz: 47c95259853558c3637073ef6150d3f53c6af8bf54c9866cee1fcff543561482e48e38bdc723916ba41c6125fa073dfb53f26689a15f497cd211b57deb8109af
@@ -3,47 +3,41 @@ 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
- ## [7.2.3] - 09-28-2016
6
+ ## [Unreleased] Unreleased
7
7
 
8
- ### Fixed
9
-
10
- - `as` resetting scope of the current query chain (see #1298)
11
-
12
- ## [7.2.2] - 09-22-2016
13
-
14
- ### Fixed
15
-
16
- - `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
17
-
18
- ## [7.2.1] - 09-19-2016
19
-
20
- ### Fixed
21
-
22
- - During ActiveRel create, node and rel property values formatted like Cypher props (`{val}`) were interpreted as props, causing errors.
8
+ ### Changed
23
9
 
24
- ## [7.2.0] - 08-23-2016
10
+ - Improved `QueryProxy` and `AssociationProxy` `#inspect` method to show a result preview (thanks ProGM / see #1228 #1232)
11
+ - Renamed the old migration task to `neo4j:legacy_migrate`
12
+ - Renamed the ENV variable to silence migrations output from `silenced` to `MIGRATIONS_SILENCED`
13
+ - Changed the behavior with transactions when a validation fails. This is a potentially breaking change, since now calling `save` would not fail the current transaction, as expected. (thanks ProGM / see #1156)
14
+ - Invalid options to the `property` method now raise an exception (see #1169)
15
+ - Label #indexes/#constraints return array without needing to access [:property_keys]
16
+ - `server_db` server type is no longer supported. Use `http` instead to connect to Neo4j via the HTTP JSON API
25
17
 
26
18
  ### Added
27
19
 
28
- - Backporting #1245 to 7.x versions. It implements the [`ForbiddenAttributesProtection` API](http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html) from ActiveRecord.
29
-
30
- ## [7.1.4] - 09-20-2016
20
+ - Allow to pass a Proc for a default property value (thanks @knapo / see #1250)
21
+ - Adding a new ActiveRecord-like migration framework (thanks ProGM / see #1197)
22
+ - Adding a set of rake tasks to manage migrations (thanks ProGM / see #1197)
23
+ - Implemented autoloading for new and legacy migration modules (there's no need to `require` them anymore)
24
+ - Adding explicit identity method for use in Query strings (thanks brucek / see #1159)
25
+ - New adaptor-based API has been created for connecting to Neo4j (See the [upgrade guide](TODO!!!!)). Changes include:
26
+ - The old APIs are deprecated and will be removed later.
27
+ - In the new API, there is no such thing as a "current" session. Users of `neo4j-core` must create and maintain references themselves to their sessions
28
+ - New `Neo4j::Core::Node` and `Neo4j::Core::Relationshp` classes have been created to provide consistent results between adaptors. `Neo4j::Core::Path` has also been added
29
+ - New API is centered around Cypher. No special methods are defined to, for example, load/create/etc... nodes/relationships
30
+ - There is now a new API for making multiple queries in the same HTTP request
31
+ - It is now possible to subscribe separately to events for querying in different adaptors and for HTTP requests (see [the docs](TODO!!!!))
32
+ - Schema queries (changes to indexes/constraints) happen in a separate thread for performance and reduce the complexity of the code
33
+ - New session API does not include replacement for on_next_session_available
34
+ - Adding a migration helper to mass relabel migrations (thanks @JustinAiken / see #1166 #1239)
35
+ - Added support for `find_or_initialize_by` and `first_or_initialize` methods from ActiveRecord (thanks ProGM / see #1164)
36
+ - Support for using Neo4j-provided IDs (`neo_id`) instead of UUID or another Ruby-provided ID. (Huge thanks to @klobuczek, see #1174)
31
37
 
32
38
  ### Fixed
33
39
 
34
- - `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
35
-
36
- ## [7.1.3] - 08-18-2016
37
-
38
- ### Changed
39
-
40
- - Default value for `enum` is `nil` instead of the first value. This is a **BREAKING** change but is being released as a patch because the original behavior was considered a bug. See [this pull request](https://github.com/neo4jrb/neo4j/pull/1270) (thanks to ProGM and andyweiss1982)
41
-
42
- ## [7.1.2] - 08-01-2016
43
-
44
- ### Fixed
45
-
46
- - Fixed issue where the label wrapping cache would get stuck
40
+ - Made some memory optimizations (thanks ProGM / see #1221)
47
41
 
48
42
  ## [7.1.1] - 07-22-2016
49
43
 
@@ -58,18 +52,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
58
52
  - Gemspec dependency requirements were modified where ActiveModel, ActiveSupport, and Railties are concerned. The gem now requires >= 4.0, < 5.1.
59
53
  - `ActiveModel::Serializers::Xml` is only included if supported if available.
60
54
 
61
- ## [7.0.16] - 09-20-2016
62
-
63
- ### Fixed
64
-
65
- - `where` clause with question mark parameter and array values only using the first element (see #1247 #1290)
66
-
67
- ## [7.0.15] - 08-18-2016
68
-
69
- ### Changed
70
-
71
- - Default value for `enum` is `nil` instead of the first value. This is a **BREAKING** change but is being released as a patch because the original behavior was considered a bug. See [this pull request](https://github.com/neo4jrb/neo4j/pull/1270) (thanks to ProGM and andyweiss1982)
72
-
73
55
  ## [7.0.14] - 07-10-2016
74
56
 
75
57
  ### Fixed
@@ -87,6 +69,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
87
69
  ### Fixed
88
70
 
89
71
  - Fix dipendence from JSON when using outside of rails (thanks ProGM)
72
+ >>>>>>> 7.1.x
90
73
 
91
74
  ## [7.0.10] - 06-07-2016
92
75
 
@@ -154,7 +137,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
154
137
  No changes from `rc.7`
155
138
 
156
139
  ## [7.0.0.rc.7] - 03-16-2016
157
- /
140
+
158
141
  ### Changed
159
142
 
160
143
  - `with_associations` now generates separate `OPTIONAL MATCH` clauses, separated by `WITH` clauses and is preceeded by a `WITH` clause.
@@ -211,6 +194,7 @@ No changes from `rc.7`
211
194
  - Rails will now rescue all `Neo4j::RecordNotFound` errors with a 404 status code by default
212
195
  - A clone of [ActiveRecord::Enum](http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html) API. See docs for details. (thanks ProGM / #1129)
213
196
  - Added #branch method to `QueryProxy` to allow for easy branching of matches in association chains (thanks ProGM / #1147 / #1143)
197
+ - The `.match` method on ActiveNode model class has changed to allow a second argument which takes `on_create`, `on_match`, and `set` keys. These allow you to define attribute values for the Cypher `MERGE` in the different cases (thanks leviwilson / see #1123)
214
198
 
215
199
  ### Removed
216
200
 
data/Gemfile CHANGED
@@ -2,10 +2,14 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- # if ENV['CI']
6
- # gem 'neo4j-core', github: 'neo4jrb/neo4j-core', branch: 'master'
7
- # gem 'neo4j-rake_tasks', github: 'neo4jrb/neo4j-rake_tasks', branch: 'master'
8
- # end
5
+ # gem 'neo4j-core', github: 'neo4jrb/neo4j-core', branch: 'master' if ENV['CI']
6
+
7
+ if branch = ENV['TRAVIS_BRANCH']
8
+ same_branch_exists = `curl --head https://github.com/neo4jrb/neo4j-core/tree/#{branch} | head -1`.match(/200 OK/)
9
+ gem 'neo4j-core', github: 'neo4jrb/neo4j-core', branch: same_branch_exists ? branch : 'master'
10
+ else
11
+ gem 'neo4j-core', github: 'neo4jrb/neo4j-core'
12
+ end
9
13
 
10
14
  # gem 'active_attr', github: 'neo4jrb/active_attr', branch: 'performance'
11
15
  # gem 'active_attr', path: '../active_attr'
@@ -13,26 +17,23 @@ gemspec
13
17
  gem 'listen', '< 3.1'
14
18
 
15
19
  if RUBY_VERSION.to_f < 2.2
16
- gem 'activemodel', '~> 4.2'
17
- gem 'activesupport', '~> 4.2'
18
- gem 'railties', '~> 4.2'
20
+ gem 'activemodel', '~> 4'
21
+ gem 'activesupport', '~> 4'
22
+ gem 'railties', '~> 4'
19
23
  end
20
24
 
25
+ gem 'tins', '< 1.7' if RUBY_VERSION.to_f < 2.0
26
+
21
27
  group 'test' do
22
28
  gem 'coveralls', require: false
23
- if RUBY_VERSION.to_f < 2.0
24
- gem 'term-ansicolor', '< 1.4'
25
- gem 'tins', '< 1.7'
26
- gem 'overcommit', '< 0.35.0'
27
- else
28
- gem 'overcommit'
29
- end
29
+ gem 'tins', '< 1.7' if RUBY_VERSION.to_f < 2.0
30
30
  gem 'codecov', require: false
31
31
  gem 'simplecov', require: false
32
32
  gem 'simplecov-html', require: false
33
33
  gem 'rspec', '~> 3.4'
34
34
  gem 'its'
35
35
  gem 'test-unit'
36
+ gem 'overcommit'
36
37
  gem 'colored'
37
38
  gem 'dotenv'
38
39
  gem 'timecop'
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Welcome to Neo4j.rb
2
2
 
3
+ **FOR INFORMATION ABOUT NEO4J 3.0 SUPPORT, SEE [VERSION SUPPORT](https://github.com/neo4jrb/neo4j#neo4j-version-support) and [FEATURE SUPPORT](https://github.com/neo4jrb/neo4j#neo4j-feature-support) sections**
4
+
5
+ **ALSO NOTE THAT MASTER IS CURRENT IN FLUX IN PREPARATION FOR AN ALPHA OF 8.0 AND IT IS NOT RECOMMENDED TO BE USED**
6
+
3
7
  ## Code Status
4
8
 
5
9
  [![Build Status](https://secure.travis-ci.org/neo4jrb/neo4j.png?branch=master)](http://travis-ci.org/neo4jrb/neo4j) [![Coverage Status](https://coveralls.io/repos/neo4jrb/neo4j/badge.png?branch=master)](https://coveralls.io/r/neo4jrb/neo4j?branch=master) [![Code Climate](https://codeclimate.com/github/neo4jrb/neo4j.png)](https://codeclimate.com/github/neo4jrb/neo4j) [![PullReview stats](https://www.pullreview.com/github/neo4jrb/neo4j/badges/master.svg?)](https://www.pullreview.com/github/neo4jrb/neo4j/reviews/master)
@@ -48,25 +52,27 @@ Neo4j.rb v4.1.0 was released in January of 2015. Its changes are outlined [here]
48
52
 
49
53
  ## Neo4j version support
50
54
 
51
- | **Neo4j Version** | v2.x | v3.x | >= v4.x |
52
- |-------------------|------|-------|---------|
53
- | 1.9.x | Yes | No | No |
54
- | 2.0.x | No | Yes | No |
55
- | 2.1.x | No | Yes | Yes * |
56
- | 2.2.x | No | No | Yes |
57
- | 2.3.x | No | No | Yes |
55
+ | **Neo4j Version** | v2.x | v3.x | >= v4.x | >= 7.0.3 |
56
+ |-------------------|------|-------|---------|----------|
57
+ | 1.9.x | Yes | No | No | No |
58
+ | 2.0.x | No | Yes | No | No |
59
+ | 2.1.x | No | Yes | Yes * | Yes |
60
+ | 2.2.x | No | No | Yes | Yes |
61
+ | 2.3.x | No | No | Yes | Yes |
62
+ | 3.0.x | No | No | No | Yes |
58
63
 
59
64
  `*` Neo4j.rb >= 4.x doesn't support Neo4j versions before 2.1.5. To use 2.1.x you should upgrade to a version >= 2.1.5
60
65
 
61
66
  ## Neo4j feature support
62
67
 
63
- | **Neo4j Feature** | v2.x | v3.x | >= v4.x |
64
- |----------------------------|--------|------|---------|
65
- | Auth | No | No | Yes |
66
- | Remote Cypher | Yes | Yes | Yes |
67
- | Transactions | Yes | Yes | Yes |
68
- | High Availability | No | Yes | Yes |
69
- | Embedded JVM support | Yes | Yes | Yes |
68
+ | **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x (coming soon) |
69
+ |----------------------------|--------|------|---------|----------------------|
70
+ | Bolt Protocol | No | No | No | Yes (coming soon) |
71
+ | Auth | No | No | Yes | Yes |
72
+ | Remote Cypher | Yes | Yes | Yes | Yes |
73
+ | Transactions | Yes | Yes | Yes | Yes |
74
+ | High Availability | No | Yes | Yes | Yes |
75
+ | Embedded JVM support | Yes | Yes | Yes | Yes |
70
76
 
71
77
  ## Modern (3.x/4.X) Documentation
72
78
 
@@ -101,3 +107,4 @@ Always welcome! Please review the [guidelines for contributing](CONTRIBUTING.md
101
107
  * Neo4j - Dual free software/commercial license, see [Licensing Guide](http://www.neo4j.org/learn/licensing).
102
108
 
103
109
  **Notice:** There are different licenses for the `neo4j-community`, `neo4j-advanced`, and `neo4j-enterprise` jar gems. Only the `neo4j-community` gem is required by default.
110
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'neo4j'
4
4
 
5
- if ARGV.length == 0
5
+ if ARGV.empty?
6
6
  puts <<TEXT
7
7
  A tool for copying jar files needed by the application server, like trinidad
8
8
  It copies all jar files which has been required (neo4j-community, neo4j-advanced or neo4j-enterprise) to the lib folder of the current directory
@@ -3,6 +3,11 @@ require 'neo4j/version'
3
3
  require 'neo4j-core'
4
4
  require 'neo4j/core/cypher_session'
5
5
  require 'neo4j/core/query'
6
+
7
+ require 'neo4j/active_base'
8
+ require 'neo4j/model_schema'
9
+ require 'neo4j/active_base/session_registry'
10
+
6
11
  require 'active_model'
7
12
  require 'active_support/concern'
8
13
  require 'active_support/core_ext/class/attribute.rb'
@@ -40,7 +45,6 @@ require 'neo4j/shared/typecaster'
40
45
  require 'neo4j/shared/initialize'
41
46
  require 'neo4j/shared/query_factory'
42
47
  require 'neo4j/shared/cypher'
43
- require 'neo4j/shared/permitted_attributes'
44
48
  require 'neo4j/shared'
45
49
 
46
50
  require 'neo4j/active_rel/callbacks'
@@ -54,6 +58,7 @@ require 'neo4j/active_rel/related_node'
54
58
  require 'neo4j/active_rel/types'
55
59
  require 'neo4j/active_rel'
56
60
 
61
+ require 'neo4j/active_node/node_list_formatter'
57
62
  require 'neo4j/active_node/dependent'
58
63
  require 'neo4j/active_node/dependent/query_proxy_methods'
59
64
  require 'neo4j/active_node/dependent/association_methods'
@@ -88,6 +93,12 @@ require 'neo4j/active_node/query'
88
93
  require 'neo4j/active_node/scope'
89
94
  require 'neo4j/active_node'
90
95
 
96
+ module Neo4j
97
+ extend ActiveSupport::Autoload
98
+ autoload :Migrations
99
+ autoload :Migration
100
+ end
101
+
91
102
  require 'neo4j/active_node/orm_adapter'
92
103
  if defined?(Rails)
93
104
  require 'rails/generators'
@@ -0,0 +1,68 @@
1
+ module Neo4j
2
+ # To contain any base login for ActiveNode/ActiveRel which
3
+ # is external to the main classes
4
+ module ActiveBase
5
+ class << self
6
+ # private?
7
+ def current_session
8
+ SessionRegistry.current_session.tap do |session|
9
+ fail 'No session defined!' if session.nil?
10
+ end
11
+ end
12
+
13
+ def current_transaction_or_session
14
+ current_transaction || current_session
15
+ end
16
+
17
+ def query(*args)
18
+ current_transaction_or_session.query(*args)
19
+ end
20
+
21
+ # Should support setting session via config options
22
+ def current_session=(session)
23
+ SessionRegistry.current_session = session
24
+ end
25
+
26
+ def current_adaptor=(adaptor)
27
+ self.current_session = Neo4j::Core::CypherSession.new(adaptor)
28
+ end
29
+
30
+ def run_transaction(run_in_tx = true)
31
+ Neo4j::Transaction.run(current_session, run_in_tx) do |tx|
32
+ yield tx
33
+ end
34
+ end
35
+
36
+ def new_transaction
37
+ Neo4j::ModelSchema.validate_model_schema!
38
+ Neo4j::Transaction.new(current_session)
39
+ end
40
+
41
+ def new_query(options = {})
42
+ Neo4j::ModelSchema.validate_model_schema!
43
+ Neo4j::Core::Query.new({session: current_session}.merge(options))
44
+ end
45
+
46
+ def magic_query(*args)
47
+ if args.empty? || args.map(&:class) == [Hash]
48
+ ActiveBase.new_query(*args)
49
+ else
50
+ ActiveBase.current_session.query(*args)
51
+ end
52
+ end
53
+
54
+ def current_transaction
55
+ Neo4j::ModelSchema.validate_model_schema!
56
+ Neo4j::Transaction.current_for(current_session)
57
+ end
58
+
59
+ def label_object(label_name)
60
+ Neo4j::Core::Label.new(label_name, current_session)
61
+ end
62
+
63
+ def logger
64
+ @logger ||= (Neo4j::Config[:logger] || Logger.new(STDOUT))
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,12 @@
1
+ require 'active_support/per_thread_registry'
2
+
3
+ module Neo4j
4
+ module ActiveBase
5
+ # Provides a simple API to manage sessions in a thread-safe manner
6
+ class SessionRegistry
7
+ extend ActiveSupport::PerThreadRegistry
8
+
9
+ attr_accessor :current_session
10
+ end
11
+ end
12
+ end
@@ -44,11 +44,12 @@ module Neo4j
44
44
  include Neo4j::ActiveNode::Scope
45
45
  include Neo4j::ActiveNode::Dependent
46
46
  include Neo4j::ActiveNode::Enum
47
- include Neo4j::Shared::PermittedAttributes
48
47
 
49
48
  def initialize(args = nil)
50
- args = sanitize_input_parameters(args)
51
- super(args)
49
+ self.class.ensure_id_property_info! # So that we make sure all objects have an id_property
50
+
51
+ symbol_args = args.is_a?(Hash) ? args.symbolize_keys : args
52
+ super(symbol_args)
52
53
  end
53
54
 
54
55
  def neo4j_obj
@@ -68,9 +69,12 @@ module Neo4j
68
69
  included do
69
70
  include Neo4j::Timestamps if Neo4j::Config[:record_timestamps]
70
71
 
71
- def self.inherited(other)
72
- Neo4j::ActiveNode::Labels.clear_wrapped_models
72
+ def self.inherited?
73
+ !!@inherited
74
+ end
73
75
 
76
+ def self.inherited(other)
77
+ other.instance_variable_set('@inherited', true)
74
78
  inherit_id_property(other)
75
79
  attributes.each_pair do |k, v|
76
80
  other.inherit_property k.to_sym, v.clone, declared_properties[k].options
@@ -81,22 +85,10 @@ module Neo4j
81
85
  end
82
86
 
83
87
  def self.inherit_id_property(other)
84
- Neo4j::Session.on_next_session_available do |_|
85
- next if other.manual_id_property? || !self.id_property?
86
- id_prop = self.id_property_info
87
- conf = id_prop[:type].empty? ? {auto: :uuid} : id_prop[:type]
88
- other.id_property id_prop[:name], conf
89
- end
90
- end
91
-
92
- Neo4j::Session.on_next_session_available do |_|
93
- next if manual_id_property?
94
- id_property :uuid, auto: :uuid unless self.id_property?
95
-
96
- name = Neo4j::Config[:id_property]
97
- type = Neo4j::Config[:id_property_type]
98
- value = Neo4j::Config[:id_property_type_value]
99
- id_property(name, type => value) if name && type && value
88
+ return if other.manual_id_property? || !self.id_property?
89
+ id_prop = self.id_property_info
90
+ conf = id_prop[:type].empty? && id_prop[:name] != :neo_id ? {auto: :uuid} : id_prop[:type]
91
+ other.id_property id_prop[:name], conf, true
100
92
  end
101
93
  end
102
94
 
@@ -37,12 +37,12 @@ module Neo4j
37
37
 
38
38
  def unique_nodes_query(association, self_identifer, other_node, other_rel)
39
39
  query.with(identity).proxy_as_optional(source_object.class, self_identifer)
40
- .send(association.name, other_node, other_rel)
41
- .query
42
- .with(other_node)
43
- .match("()#{association.arrow_cypher(:orphan_rel)}(#{other_node})")
44
- .with(other_node, count: 'count(*)')
45
- .where('count = {one}', one: 1)
40
+ .send(association.name, other_node, other_rel)
41
+ .query
42
+ .with(other_node)
43
+ .match("()#{association.arrow_cypher(:orphan_rel)}(#{other_node})")
44
+ .with(other_node, count: 'count(*)')
45
+ .where('count = {one}', one: 1)
46
46
  end
47
47
  end
48
48
  end