A postgres specific problem and manyToManyRelation

33 views
Skip to first unread message

DetriusXii

unread,
Aug 2, 2011, 3:37:59 PM8/2/11
to squeryl-contributors
Anyways, when defining a many-to-many relation, the table gets defined
into the Postgres public schema rather than the schema I want it to be
defined at.

Currently, the trait org.squeryl.dsl.QueryDsl has the following two
functions

def manyToManyRelation[L <: KeyedEntity[_],R <: KeyedEntity[_],A <:
KeyedEntity[_]](l: Table[L], r: Table[R]) = new
ManyToManyRelationBuilder(l,r,None)

def manyToManyRelation[L <: KeyedEntity[_],R <: KeyedEntity[_],A <:
KeyedEntity[_]](l: Table[L], r: Table[R], nameOfMiddleTable: String) =
new ManyToManyRelationBuilder(l,r,Some(nameOfMiddleTable))


I'd like a third manyToManyRelation to be defined

def manyToManyRelation[L <: KeyedEntity[_],R <: KeyedEntity[_],A <:
KeyedEntity[_]](l: Table[L], r: Table[R], nameOfMiddleTable: String,
prefix: String) = new
ManyToManyRelationBuilder(l,r,Some(nameOfMiddleTable), Some(prefix))

The constructor for class ManyToManyRelationBuilder[L <:
KeyedEntity[_], R <: KeyedEntity[_]](l: Table[L], r: Table[R],
nameOverride: Option[String], schemaOverride : Option[String])

The constructor for class class ManyToManyRelationImpl[L <:
KeyedEntity[_],
R <: KeyedEntity[_],
A <: KeyedEntity[_]](val leftTable:
Table[L],
val rightTable:
Table[R],
aClass: Class[A],
f: (L,R,A)=>

Pair[EqualityExpression,EqualityExpression],
schema: Schema,
nameOverride:
Option[String],
schemaOverride:
Option[String])

class ManyToManyRelationImpl[L <: KeyedEntity[_],
R <: KeyedEntity[_],
A <: KeyedEntity[_]](val leftTable:
Table[L],
val rightTable:
Table[R],
aClass: Class[A],
f: (L,R,A)=>

Pair[EqualityExpression,EqualityExpression],
schema: Schema,
nameOverride:
Option[String],
schemaOverride:
Option[String])
extends Table[A]
(nameOverride.getOrElse(schema.tableNameFromClass(aClass)), aClass,
schema, schemaOverride) with ManyToManyRelation[L,R,A]

It's just gives the ability to handle custom schemas in Postgres
properly.

Maxime Lévesque

unread,
Aug 2, 2011, 11:22:59 PM8/2/11
to squeryl-co...@googlegroups.com
Just to make sure I understand correctly, you'd like the ability to specify the middle
table in a many to many relation instead of having it created by Squeryl ?

Sounds fair enough, I that is what you meant, I'll put it on the "feature to implement" list.

ML

2011/8/2 DetriusXii <ajel...@gmail.com>

DetriusXii

unread,
Aug 3, 2011, 10:10:03 AM8/3/11
to squeryl-contributors
Yes. That is correct. It just requires adding an extra parameter to
some of the class constructors.

On Aug 2, 9:22 pm, Maxime Lévesque <maxime.leves...@gmail.com> wrote:
> Just to make sure I understand correctly, you'd like the ability to specify
> the middle
> table in a many to many relation instead of having it created by Squeryl ?
>
> Sounds fair enough, I that is what you meant, I'll put it on the "feature to
> implement" list.
>
> ML
>
> 2011/8/2 DetriusXii <ajelo...@gmail.com>
Reply all
Reply to author
Forward
0 new messages