Possible issue with Squeryl Record

34 views
Skip to first unread message

Dave Whittaker

unread,
Jan 11, 2011, 12:12:12 PM1/11/11
to Lift
I've just started to play around with Squeryl and Lift Record and I
think I may have come across a small issue. When you define an index
within a Schema the syntax is:

on(table)(t => declare(t.column is indexed))

For some reason, at least in my project, this causes a compilation
error when the column is a MandatoryTypedField unless it is an
IntField. The error that I've been getting is:

type mismatch;
[error] found : org.squeryl.internals.Indexed
[error] required: Int

Indexing any OptionalTypedField or IntField works fine. I've done a
small test with org.squeryl.customtypes.CustomTypesMode and putting an
index on its' StringField seems to work so this does seem to be a Lift
Record issue and not a Squeryl issue.

There are work arounds for this, what I did was use the
declare(columns(column) are indexed) variation and of course you could
just define the index in the database manually but if this is a quirk
of the Lift implementation I figured it's at least worth documenting.

Let me know if you need any more information.

Michael Gottschalk

unread,
Jan 12, 2011, 5:56:30 PM1/12/11
to Lift, maxime....@gmail.com
Hi Dave,

thanks for reporting the issue.
I have already reproduced this myself now and I'll try to fix it.

Can you open a ticket at http://ticket.liftweb.net (you must be a
watcher of the Liftweb assembla space to open tickets)?

Apart from what you mentioned, there is another workaround: simply use
on(table)(t => declare(t.column.is is indexed))
(note the ".is").

Maxime, do you know what could be causing this behavior? Is there some
implicit conversion that somehow only works for numeric fields?

Cheers,
Michael

Maxime Lévesque

unread,
Jan 12, 2011, 10:25:00 PM1/12/11
to Michael Gottschalk, lif...@googlegroups.com

I'm thinking it might be a clash with the method 'is' defined in both MandatoryTypedField and TypeField, just to rule out this
possibility, can you try this :


   on(table)(t =>  declare(t.column.~.is(indexed)))

?

the .~ will force the implicit conversion to take precedence over the 'is' from the field

Max

2011/1/12 Michael Gottschalk <MGott...@gmx.net>
Hi Dave,

thanks for reporting the issue.
I have already reproduced this myself now and I'll try to fix it.

Can you open a ticket at http://ticket.liftweb.net (you must be a watcher of the Liftweb assembla space to open tickets)?

Apart from what you mentioned, there is another workaround: simply use
 on(table)(t =>  declare(t.column.is is indexed))
(note the ".is").

Maxime, do you know what could be causing this behavior? Is there some implicit conversion that somehow only works for numeric fields?

Cheers,
Michael

Dave Whittaker

unread,
Jan 13, 2011, 10:00:49 AM1/13/11
to Lift
Thanks for checking it out and getting back to me.

Ticket is created:
http://www.assembla.com/spaces/liftweb/tickets/840-can-t-declare-a-squeryl-index-on-a-mandatorytypedfield-unless-it-is-of-type-int

Maxime: Yes, the ~is form does work. I thought it was a conflict with
the is method on TypedField as well at first, but strangely IntField
works as do any of the OptionalTypedFields.

Just a heads up, I ran into another Squeryl/Record issue and I have a
possible fix for it that I'll post about today when I've got a moment.

On Jan 12, 10:25 pm, Maxime Lévesque <maxime.leves...@gmail.com>
wrote:
> I'm thinking it might be a clash with the method 'is' defined in both
> MandatoryTypedField and TypeField, just to rule out this
> possibility, can you try this :
>
>    on(table)(t =>  declare(t.column.~.is(indexed)))
>
> ?
>
> the .~ will force the implicit conversion to take precedence over the 'is'
> from the field
>
> Max
>
> 2011/1/12 Michael Gottschalk <MGottsch...@gmx.net>
>
>
>
>
>
>
>
> > Hi Dave,
>
> > thanks for reporting the issue.
> > I have already reproduced this myself now and I'll try to fix it.
>
> > Can you open a ticket athttp://ticket.liftweb.net(you must be a watcher
Reply all
Reply to author
Forward
0 new messages