Hi Steven,
thanks for already tracking down the problem so far.
I'll try to reproduce and fix it.
Cheers,
Michael
On 28 Jan., 09:21, Steven Yang <
kenshin...@gmail.com> wrote:
> Hi
> I am currently trying out Record-Squeryl and found something weird.
>
> Here is my Record declaration.
>
> *class Textbook private() extends Record[Textbook] with KeyedRecord[Long] {*
> * override def meta = Textbook*
> *
> *
> * @Column(name="id")*
> * override val idField = new LongField(this)*
> *
> *
> * val bookName = new StringField(this, 100)*
> * val coverPicture = new StringField(this, 200)*
> *}*
> *
> *
> *object Textbook extends Textbook with MetaRecord[Textbook]*
>
> here are some of my methods:
>
> 1.
> *//select all textbooks*
> *def getAllTextbooks() = from(KKSchema.textbooks) (b => select(b))*
>
> 2.
> *def getFromAllTextbooks(id: Long) =*
> * //select all subquery part is just trying to make things complicated*
> * from(getAllTextbooks) (b => where(
b.id === id) select(
b.id))*
>
> 3.
> *//simple direct from table, select id columns only*
> *def getAllTextbookIds() = from(KKSchema.textbooks) (b => select(
b.id))*
>
> the resulting query looks like:
>
> *for query 2:*
> *Select*
> * q1.Textbook2_id as q1_Textbook2_id,*
> * q1.Textbook2_id as q1_Textbook2_id*
> *From*
> * (Select*
> * Textbook2.bookName as Textbook2_bookName,*
> * Textbook2.id as Textbook2_id,*
> * Textbook2.coverPicture as Textbook2_coverPicture*
> * From*
> * Textbook Textbook2*
> * ) q1*
> *Where*
> * (q1.Textbook2_id = 3)*
>
> *for query 3:*
>
> *Select*
> * Textbook1.id as Textbook1_id,*
> * Textbook1.id as Textbook1_id*
> *From*
> * Textbook Textbook1*
> *
> *
> notice that the column is selected twice
>
> if i change the selected column to bookName
>
> *for query 2:*
> *Select*
> * q1.Textbook2_bookName as q1_Textbook2_bookName,*
> * q1.Textbook2_bookName as q1_Textbook2_bookName,*
> * q1.Textbook2_id as q1_Textbook2_id,*
> * q1.Textbook2_coverPicture as q1_Textbook2_coverPicture*
> *From*
> * (Select*
> * Textbook2.bookName as Textbook2_bookName,*
> * Textbook2.id as Textbook2_id,*
> * Textbook2.coverPicture as Textbook2_coverPicture*
> * From*
> * Textbook Textbook2*
> * ) q1*
> *Where*
> * (q1.Textbook2_id = 3)*
>
> *for query 3:*
> *Select*
> * Textbook1.bookName as Textbook1_bookName,*
> * Textbook1.bookName as Textbook1_bookName,*
> * Textbook1.id as Textbook1_id,*
> * Textbook1.coverPicture as Textbook1_coverPicture*
> *From*
> * Textbook Textbook1*
>
> notice that all columns are selected with bookName twice
>
> The thing here is that the result is correct.
> I do get a "list" of Long or String depends on the column I selected.
>
> The problem comes when I use these queries as a sub-query in a "in" clause.
> The generated SQL will look something like
> ...
> *
b.id in (*
> * Select*
> * Textbook1.bookName as Textbook1_bookName,*
> * Textbook1.bookName as Textbook1_bookName,*
> * Textbook1.id as Textbook1_id,*
> * Textbook1.coverPicture as Textbook1_coverPicture*
> * From ....)*
> *
> *
> And there for giving me a SQL exception.
>
> for the above SQLs if I use none Record class like:
> *class Textbook(val id: Long, val bookName: String, val coverPicture:
> String)*
> *
> *