Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Record-Squeryl select single column problem
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Steven Yang  
View profile  
 More options Jan 28 2011, 3:21 am
From: Steven Yang <kenshin...@gmail.com>
Date: Fri, 28 Jan 2011 16:21:58 +0800
Local: Fri, Jan 28 2011 3:21 am
Subject: Record-Squeryl select single column problem

 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)*
*
*
generated SQL looks correct only 1 column is in the Select statement.

(I did not test the IN for none Record class. I found this behavior when
trying to use IN with Record class)

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Gottschalk  
View profile  
 More options Jan 29 2011, 6:07 am
From: Michael Gottschalk <migottsch...@googlemail.com>
Date: Sat, 29 Jan 2011 03:07:59 -0800 (PST)
Local: Sat, Jan 29 2011 6:07 am
Subject: Re: Record-Squeryl select single column problem
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Gottschalk  
View profile  
 More options Jan 29 2011, 7:22 am
From: Michael Gottschalk <migottsch...@googlemail.com>
Date: Sat, 29 Jan 2011 04:22:31 -0800 (PST)
Local: Sat, Jan 29 2011 7:22 am
Subject: Re: Record-Squeryl select single column problem
Hi Steven,

I was able to reproduce the problem.

It seems that the implicit conversions defined in RecordTypeMode are
not applied for arguments of the select function.
As a workaround, you can just use the "is" function on the fields in
selects, e.g.:

from(KKSchema.textbooks) (b => select(b.idField.is))
or
from(KKSchema.textbooks) (b => select(b.bookName.is))

I'll see if It can be really fixed somehow.

Can you create a ticket for this problem and document it in the Squery-
Record Wiki page?

Thanks!
Michael

On 29 Jan., 12:07, Michael Gottschalk <migottsch...@googlemail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Yang  
View profile  
 More options Jan 29 2011, 8:47 am
From: Steven Yang <kenshin...@gmail.com>
Date: Sat, 29 Jan 2011 21:47:32 +0800
Local: Sat, Jan 29 2011 8:47 am
Subject: Re: [Lift] Re: Record-Squeryl select single column problem

Hi
thanks for the response

ticket created
http://www.assembla.com/spaces/liftweb/tickets/876-record-squeryl-sel...

and wiki added, please modify if necessary.

by the way, because I am in the pre-start phase of a Lift project and
wanting to use Squeryl for the main DB support and want to make sure Record
can support all the what Squeryl supports and the difference with pure
Squeryl if any.

I will be making test cases to make sure I can get Squeryl working at least
for every function state on the site.

I can do the equivalent test cases for Record-Squeryl and send you the cases
and report any issue if found.

On Sat, Jan 29, 2011 at 8:22 PM, Michael Gottschalk <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Gottschalk  
View profile  
 More options Jan 29 2011, 9:32 am
From: Michael Gottschalk <migottsch...@googlemail.com>
Date: Sat, 29 Jan 2011 06:32:31 -0800 (PST)
Local: Sat, Jan 29 2011 9:32 am
Subject: Re: Record-Squeryl select single column problem
Hi Steven,

On 29 Jan., 14:47, Steven Yang <kenshin...@gmail.com> wrote:

> Hi
> thanks for the response

> ticket createdhttp://www.assembla.com/spaces/liftweb/tickets/876-record-squeryl-sel...

> and wiki added, please modify if necessary.

nice, thank you.

> by the way, because I am in the pre-start phase of a Lift project and
> wanting to use Squeryl for the main DB support and want to make sure Record
> can support all the what Squeryl supports and the difference with pure
> Squeryl if any.

> I will be making test cases to make sure I can get Squeryl working at least
> for every function state on the site.

> I can do the equivalent test cases for Record-Squeryl and send you the cases
> and report any issue if found.

That sounds good. The test cases for squeryl-record are not yet very
comprehensive and I'd be glad to integrate more of them.

Cheers,
Michael


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Yang  
View profile  
 More options Jan 29 2011, 10:39 pm
From: Steven Yang <kenshin...@gmail.com>
Date: Sun, 30 Jan 2011 11:39:29 +0800
Local: Sat, Jan 29 2011 10:39 pm
Subject: Re: [Lift] Re: Record-Squeryl select single column problem

great i will get on it

but i am still consider new to Scala, Lift, Squeryl.

I suspect this will take me a while, do my best

On Sat, Jan 29, 2011 at 10:32 PM, Michael Gottschalk <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »