Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

How to make a join statement #72

Closed
aaleotti-unimore opened this issue Oct 13, 2016 · 4 comments
Closed

How to make a join statement #72

aaleotti-unimore opened this issue Oct 13, 2016 · 4 comments

Comments

@aaleotti-unimore
Copy link

Hi, I read the documentation but there's no sign how to make a join statement (or using implicit notation, select from two different tables using a where clause). is there a proper way rather than directly with low level sql statements?

@bmuller
Copy link
Owner

bmuller commented Oct 13, 2016

@bmuller bmuller closed this as completed Oct 13, 2016
@aaleotti-unimore
Copy link
Author

so there's no way to make a relationship that's not based on the id colum of a table?

@bmuller
Copy link
Owner

bmuller commented Oct 13, 2016

I think you can specify the join columns

On Oct 13, 2016, at 08:15, aaleotti-unimore notifications@github.com wrote:

so there's no way to make a relationship that's not based on the id colum of a table?


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.

@aaleotti-unimore
Copy link
Author

aaleotti-unimore commented Oct 13, 2016

can you tell where it's explained? because it's not specified anywhere which are the acceptable arguments for the optional dictionary of the HASONE / HASMANY / etc class variables
The example only says to refer to the Relationships class but in the docs there's nothing to define the columns.

I used the line as shown in the example:

class Comment(DBObject):
     HASONE = [{'name': 'User', 'class_name': 'user', foreign_key: 'user_id'}]

class User(DBObject):
     pass

but I can't specify which is the column in the Comment class i want to join in the User class (named user_id as well)

can I use this like shown in this ruby-on-rails example i found on Stackfoverflow?

class Client < ActiveRecord::Base
  belongs_to :region, foreign_key: 'location_id'

class Region < ActiveRecord::Base
  has_many :clients, foreign_key: 'place_id'

Thanks for your support

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

No branches or pull requests

2 participants