bmuller / twistar

Twistar is an object-relational mapper (ORM) for Python that uses the Twisted library to provide asynchronous DB interaction.

Home Page:http://findingscience.com/twistar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to make a join statement

aaleotti-unimore opened this issue · comments

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?

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

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.

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