how to set column attributes in Squeryl-Record?

28 views
Skip to first unread message

Andrzej Skalski

unread,
Aug 16, 2015, 10:19:32 AM8/16/15
to Lift
Hi,

I want to add column attributes (like "indexed" and "unique") to e-mail field of User (using squeryl-record protouser).

When I do it like described here http://squeryl.org/schema-definition.html

on(users)(s => declare(
    s.email.is(unique, indexed)
  ))

I get error

too many arguments for method apply: (index: Int)Char in class StringOps
[error]     s.email is(unique, indexed)


any clues?

Andrzej

Andreas Joseph Krogh

unread,
Aug 16, 2015, 10:48:55 AM8/16/15
to lif...@googlegroups.com
På søndag 16. august 2015 kl. 16:19:32, skrev Andrzej Skalski <andrzej....@gmail.com>:
Hi,

I want to add column attributes (like "indexed" and "unique") to e-mail field of User (using squeryl-record protouser).

When I do it like described here http://squeryl.org/schema-definition.html
 
on(users)(s => declare(
    s.email.is(unique, indexed)
  ))
 
Is this really your font-settings?
I find it not very easy to read...
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
 

Antonio Salazar Cardozo

unread,
Aug 17, 2015, 1:09:57 PM8/17/15
to Lift
This is probably Google Groups failing to be clever about pasting formatted text.

Any chance you're on a different version of Squeryl?
Thanks,
Antonio

David Whittaker

unread,
Aug 17, 2015, 1:24:22 PM8/17/15
to liftweb

Andrzej,

Check out the Lift Wiki entry on Squeryl. In particular, you’ll find this in the section on defining a schema:

The “is” function is ambiguous for records, so from version 2.3-SNAPSHOT on, you can use “defineAs” instead. Until then, you can also use “.~.is” if there is a compiler error.

I think that switching to defineAs will resolve your problem.


--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrzej Skalski

unread,
Aug 17, 2015, 6:19:09 PM8/17/15
to Lift
@Antonio:

I use
val liftVersion = "2.6.2"
 
Seq(
   
"net.liftweb"       %% "lift-webkit"        % liftVersion        % "compile",
   
"net.liftweb"       %% "lift-mapper"        % liftVersion        % "compile",
   
//"net.liftmodules"   %% "lift-jquery-module_2.6" % "2.8",
   
"net.liftweb"       %% "lift-record"            % liftVersion,
   
"net.liftweb"       %% "lift-squeryl-record"    % liftVersion,...

@David:

I tried

on(users)(s => declare(
    s
.email.~is(unique, indexed)
 
))

and I have error:

value ~ is not a member of net.liftweb.record.field.EmailField[code.model.User]
[error]     s.email.~is(unique, indexed)

David Whittaker

unread,
Aug 17, 2015, 10:50:39 PM8/17/15
to liftweb

Andrzej,

That’s because it would be .~.is, the initial .~ forces an implicit conversion to the type on which the .is method exists. Or, you could just do what I suggested in the first place and use defineAs :)

Andrzej Skalski

unread,
Aug 18, 2015, 7:16:09 AM8/18/15
to Lift
thanks for all the help, but I still can't get it working

for

on(users)(s => declare(
    s
.email.~.is(unique, indexed)
 
))

I have

value ~ is not a member of net.liftweb.record.field.EmailField[code.model.User]
[error]     s.email.~.is(unique, indexed)


and for

  on(users)(s => declare(
    s
.email defineAs(unique, indexed)
 
))

I have:

value defineAs is not a member of net.liftweb.record.field.EmailField[code.model.User]
[error]     s.email defineAs(unique, indexed)

Andrzej

David Whittaker

unread,
Aug 19, 2015, 2:48:54 PM8/19/15
to liftweb
Hm.  Both of those methods should be available via implicit conversion.  Do you have imported net.liftweb.squerylrecord.RecordTypeMode._  first?

Andrzej Skalski

unread,
Aug 19, 2015, 4:12:08 PM8/19/15
to Lift
no, and that was the problem. Thank you.

Kindest Regards
Andrzej Skalski
Reply all
Reply to author
Forward
0 new messages