Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Jacob Ablowitz
@jacob-dmi
particularly ENDS WITH or CONTAINS usage, per that page...?
Heinrich Klobuczek
@klobuczek
Hmm, I cannot comment on this specifically. If you encounter any we will have to investigate.
Jacob Ablowitz
@jacob-dmi
Roger that, I'll let you know. Happy to know it's not a "known problem," so to speak.
tester123
@opensourcechris
Is there a method to handle union clause in the gem?
Amit Suryavanshi
@amitTheSongadya_twitter
@opensourcechris There us union_cypher method on Neo4j::Core::Query object. https://github.com/neo4jrb/neo4j-core/blob/master/lib/neo4j/core/query.rb#L389
Levi Wilson
@leviwilson
tester123
@opensourcechris
That would be a useful feature, maybe you can use callbacks to stop update on those fields?
tester123
@opensourcechris
We are using the neo4j will_paginate gem, which requires two queries for each page, one to count all the records and one to return the page. I'd like a method to combine those queries into one and came up with this PROFILE MATCH (n:Client) WITH count(n) as counted_n MATCH (m:Client) RETURN m, counted_n LIMIT 25
Are there any thoughts? If I were to get this working would it be worth a PR?
Niels Jansen
@nielsjansendk
I was wondering: has anyone had success with getting neo4j-ruby-driver to work with the neo4j gem? There are hint is the documentation that it should be possible with the jruby version, by setting config.neo4j.session.options = { adaptor_class: Neo4j::Core::CypherSession::Adaptors::Driver } in application.rb, but there is nothing about the version that uses seabolt. I have installed seabolt, and it works, I have installed the neo4j-ruby-driver and I can run the example code in my console but how do I hook it up so Neo4j::Core uses it? When I attempt with setting the session options, I get the following error: uninitialized constant Neo4j::Core::CypherSession::Adaptors::Driver (NameError) I'm on neo4j-core version 9.0.0 and neo4j version 9.6.0. Is the infrastructure for it even there yet?
Niels Jansen
@nielsjansendk
I am using MRI 2.6.5, and I can't use jruby.
Heinrich Klobuczek
@klobuczek
@nielsjansendk sorry for the sparse documentation. Everything is currently changing. If you have neo4j-ruby-driver running you should be able to use it with the released version of neo4j. Starting from version 0.1.3 of neo4j-ruby-driver and neo4j-java-driver the gems are fuly compatible and replacable, but you need to include 1 in your Gemfile. Scroll up I have written some minimal instructions in this channel.
Everything will be much simpler hopefully soon. We need badly some help with gem’s documentation.
Heinrich Klobuczek
@klobuczek
@opensourcechris I’ve looked into the neo4j-will_paginate gem. It has not been maintained for 6 years. I cannot imagine it is working with our latest neo4j gem. So I think it requires much more work. Nobody of us has the bandwidth to do so. You are more than welcome to bring it up to speed.
Niels Jansen
@nielsjansendk
@klobuczek Would it be possible to make a bare-bones rails application that uses MRI and the neo4j-ruby-driver? I only see documentation for jruby, i.e. you have to use "embedded" as type in the neo4j config. Which will not work unless I am on jruby.
tester123
@opensourcechris
@klobuczek it seems to work fine for me, we use it but do not run the test suite that comes with the gem. I'll look into it a abit deeper.
Niels Jansen
@nielsjansendk
Oh, and btw, is anyone is on mac, someone made a homebrew tap for seabolt. Makes installation much easier: https://github.com/michael-simons/homebrew-seabolt
Niels Jansen
@nielsjansendk

This is clunky, but if you make an initializer in Rails.root/config/initializers/neo4j.rb and put in

config = YAML.load(File.read(::Rails.root.to_s + '/config/neo4j.yml'))[::Rails.env].symbolize_keys Neo4j::ActiveBase.current_adaptor = Neo4j::Core::CypherSession::Adaptors::Driver.new(config[:url])

It will use the driver. It's ugly, and what is needed is that in this file: https://github.com/neo4jrb/neo4j/blob/0ce207eccd8fe12db7c5bf7fd1f6cd8e0dfef1c9/lib/neo4j/session_manager.rb the private method adaptor_class_by_type needs an extra option called "driver". If that is put in, it will make things work, I think.

Heinrich Klobuczek
@klobuczek
@nielsjansendk thank you for homebrew seabolt hint. Can I reverse the request for bare-bones ruby app. Could you share yours and I will simplify it if it’s doing too much. At this point I can use any help I can get. :)
Niels Jansen
@nielsjansendk
@klobuczek I can make one, now that I got it to work.
Niels Jansen
@nielsjansendk
Heinrich Klobuczek
@klobuczek
@nielsjansendk does the automatic load of config/neo4j.ym as described here https://neo4jrb.readthedocs.io/en/stable/Setup.html#rails-configuration not work for you? Why are you loading the file in initializer?
Niels Jansen
@nielsjansendk

@klobuczek That isn't woking, no, if I pick bolt it will not use the neo4j-ruby-driver, and I cannot pick embedded, because I am not using jruby. If I pick nothing, it defaults to http, which also does not use the driver. If you want that to work, you have to make an option called "driver" in the session manager file. Also, the seabolt environment needs to be declared before neo4j-ruby-driver is required. I mean, in principle you should put it in application.rb, but that is not the rails way of doing it. Isolation it in the initializer is the best way to do it, and I would still use it to declare the environment variable, even if the session manager supported using the driver. There are other gems that installs their own initializers, if they are rails specific (like devise, aasm and money, to mention a few), it is pretty standard behavior.

While you are at it, it would be nice if datetimes were not converted to integers when using neo4j-ruby-driver. I guess that is a neo4j-core change.

Heinrich Klobuczek
@klobuczek
this is sufficient configuration except the SEABOLT_LIB var which needs to be present :point_up: September 19, 2019 2:42 PM
replace neo4j-java-driver with neo4j-ruby-driver. Just tested on a huge rails app.
this config ignores session.type since it is explicitely specified with a class. The embedded in the docs is a mistake.
Niels Jansen
@nielsjansendk
@klobuczek I see, but it should still be placed in an initializer, IMHO, not in application.rb. application.rb should contain configutation related to rails, not to other gems. If another gem needs configuration, it should be placed in an initalizer. All initializers are run when application.rb is loaded, so it is a question of how the code is organized. At least, that is my understnding of best practises.
@klobuczek See rubocops style guide here: https://github.com/rubocop-hq/rails-style-guide under Gem Initializers.
leehericks
@leehericks
Initializer 👍
Heinrich Klobuczek
@klobuczek
@leehericks @nielsjansendk are you saying the way neo4j 9.x recommends to configure a rails applications ( https://neo4jrb.readthedocs.io/en/stable/Setup.html#rails-configuration ) does not follow best practices?
Our goal has been to use rails configuration objects https://guides.rubyonrails.org/configuring.html#custom-configuration
I don’t have a strong opinion where to place those configuration lines. It is unclear to me if rubocop refers to those lines as codeand thus belonging to initializer.
Or are you actually suggesting that the code in https://github.com/neo4jrb/neo4j/blob/master/lib/neo4j/railtie.rb be moved to initializer?
Niels Jansen
@nielsjansendk
@klobuczek Railtie should stay where it is. But the suggestion to put the configuration in application.rb should change to a suggestion to create an initializer and put the configuration there. If the yaml-file alone is enough, no need for an initializer, but currently it is not.
Jacob Ablowitz
@jacob-dmi
anyone know an easy way to get a list of all undeclared properties set on a given node?
or even better, for a given set of nodes x, a list of all properties - including undeclared - that have non-null values
problem I'm trying to solve: customer asked for a CSV output report of a subset of information we collect. Some of the "columns" they want are pre-defined standard properties in our schema. However, for good reasons we also allow our customers to submit a variety of data elements that vary on a customer-by-customer basis, and the non-predefined ones get set as arbitrary key-value pairs using ActiveNode::UndeclaredProperties
So I need to assemble a routine that can easily say "here is the complete list of properties where at least one node has data present for that property name"
Then I can assemble the report out of the nodelist...
Jacob Ablowitz
@jacob-dmi
DISREGARD ABOVE - my colleague showed me how to use the keys cypher method, and I'm all set.
wackymidget
@wackymidget
@m-zielinski Hi Marek, can you eleborate on your solution for the fulltext indexes? When I define a fulltext index in neo4j, I get the following error when I try something like User.all: irb(main):001:0> User.all
BOLT+TLS: 6ms bolt://neo4j:...@localhost:7687
BOLT+TLS: 41ms bolt://neo4j:...@localhost:7687
BOLT+TLS: 4ms bolt://neo4j:...@localhost:7687
BOLT+TLS: 2ms bolt://neo4j:...@localhost:7687
BOLT+TLS: 17ms bolt://neo4j:...@localhost:7687
BOLT+TLS: 2ms bolt://neo4j:...@localhost:7687
(Object doesn't support #inspect)
wackymidget
@wackymidget
Hi guys, what is the best way to handle something like this? User.as(:n).pluck('n{.*, my_temp_var:true}').my_temp_var
William E Calderon
@wecalderonc
Hi everybody, I have this question: Its possible to have a "validate_uniqueness_of" a relation? . Ej: I have a Thing that has_one Location. But At this moment that thing can have more than one locations.... why that happens? thanks!
Amit Suryavanshi
@amitTheSongadya_twitter
@wecalderonc Can we get some more info around how these relations are created.
William E Calderon
@wecalderonc
yes @amitTheSongadya_twitter

`class Thing
include Neo4j::ActiveNode
has_one :out, :locates, rel_class: :ThingLocation, model_class: :Location
end

class Location
include Neo4j::ActiveNode

has_one :in, :thing, rel_class: :ThingLocation, model_class: :Thing
end

class ThingLocation
include Neo4j::ActiveRel

from_class :Thing
to_class :Location
type :thing_location

creates_unique
end`

Amit Suryavanshi
@amitTheSongadya_twitter
@wecalderonc, assuming you are creating relationships with ThingLocation.create(...). There is a current limitation with gem to respect has_one relationship. You can set up a config flag (enforce_has_one: true) in your rails app to raise error in such scenarios. https://github.com/neo4jrb/neo4j/blob/master/docs/Configuration.rst Build on documentation has not run for a while, will check on that. We need to work on this issue to fix it properly.
William E Calderon
@wecalderonc
@amitTheSongadya_twitter I saw that apparently this only works with 9.6.0 update? or only with ActiveNode? I'm in 9.4.0, it's possible?
Amit Suryavanshi
@amitTheSongadya_twitter
@wecalderonc 9.5.3 onwards, you can check CHANGELOG, https://github.com/neo4jrb/neo4j/blob/master/CHANGELOG.md
tester123
@opensourcechris
Is there a way to identify changed associations before save?
Amit Suryavanshi
@amitTheSongadya_twitter
@opensourcechris Not sure if we can do that. We delete all rels and create new ones while updating.
tester123
@opensourcechris
I'm working on a fork of the audited gem, so far auditing attributes works great, only missing piece is changes on has_one associations. Maybe I can inject some before_save hooks and compare UUID of has_one associations and cache the before and after...