Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to handle tables without primary key #10

Open
ck3mp3r opened this issue May 14, 2015 · 4 comments
Open

unable to handle tables without primary key #10

ck3mp3r opened this issue May 14, 2015 · 4 comments

Comments

@ck3mp3r
Copy link

ck3mp3r commented May 14, 2015

/Library/Ruby/Gems/2.0.0/gems/neo4apis-activerecord-0.8.0/lib/neo4apis/table_resolver.rb:29:in `block in identify_primary_key': Could not find a primary key for AccountContentset. (Neo4Apis::TableResolver::UnfoundPrimaryKeyError)

The table in question contains 2 foreign keys and is just used to form a many to many relationship.

@cheerfulstoic
Copy link
Contributor

This is a good point. I have some discussion in this realm here: #8 but it should definitely be addressed more thoroughly. I've put this on my list (though you're welcome to look into it as well)

@ck3mp3r
Copy link
Author

ck3mp3r commented May 15, 2015

I'd love to help but my knowledge of ruby is limited to Chef recipes...

@cheerfulstoic
Copy link
Contributor

I totally understand and no worries. If you would like to help I'll give you (and anyone else reading) a quick rundown of how the gem works below. You're also welcome to drop by our chat room on Gitter

So the quick overview:

The gem depends on neo4apis which is a gem that lets you set up a class which you can then hand objects to and which will take those objects and create Neo4j nodes and relationships from them. The main file that does that for neo4apis-activerecord is this:

https://github.com/neo4jrb/neo4apis-activerecord/blob/master/lib/neo4apis/activerecord.rb

In the end what that's doing is calling the add_node and add_relationship methods from neo4apis which do the work of generating Cypher queries and batching them up for import. That file also uses a couple of helpers (model_resolver.rb and table_resolver.rb).

Lastly there is a CLI (command-line interface) class which inherits from Neo4Apis::CLI::Base (again, from the neo4apis gem), which further inherits from Thor (see the Thor page). This is used to specify the commands and options which you can use when using neo4apis-activerecord from the command line.

So again, I wrote that because it's good to have out there. This gem might be a lot if you're not as familiar with Ruby or ActiveRecord, but you've got to start somewhere, right? ;)

Important note: Something that I just thought of. I'm not sure how you're using the gem, but if you're defining some ActiveRecord models (either in a Rails app or not) then I think you could define a has_and_belongs_to_many association and have it work for you. Check out my blog post introducing neo4apis-activerecord for details:

http://blog.brian-underwood.codes/sql/neo4j/neo4apis/activerecord/announcements/2015/01/08/loading_sql_to_neo4j_like_magic/

@ck3mp3r
Copy link
Author

ck3mp3r commented May 15, 2015

Hi,

that is the blog post I read before trying out the tools...

I'm currently trying to generate the CQL using SQL... let's see how that
goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants