MappedLongForeignKey with unique index (and other thoughts on Mapper)

10 views
Skip to first unread message

Matt Feury

unread,
Feb 25, 2016, 12:42:21 PM2/25/16
to Lift
Hi all, long time no lift,

I want to verify that I'm not crazy re: mapper functionality and then move into another discussion:

1. Is it not possible to use a MappedLongForeignKey (in Mapper) with a unique index?

I use the negative in that question, because it looks like adding a `dbIndexes` UniqueIndex (which I believe is the proper way to do this) will attempt to create an index twice (one for the `mappedFields` calculation and one for the `table.dbIndexes` loop). This will explode since the index already exists. Is there another way to do this or would this involve rolling my own?

2. Assuming the answer to the above is that it's not possible, I'm curious to know what the suggested ORM to use is these days.

It seems like Mapper vs Record is the conversation, but from what I see neither are fully robust. Having a unique foreign key seems pretty standard to me, and it makes me a little nervous moving forward with a corporate project with something that seems to lack what I think are "the basics."

Not tryin to pick a fight, but curious to hear opinions of the masses.

thanks all

Antonio Salazar Cardozo

unread,
Feb 25, 2016, 12:59:21 PM2/25/16
to Lift
It looks like MappedLongForeignKey is only included in that first loop if
dbIndexed_? is true. So you can just override that to be `false` and then
set up your own index, right?
Thanks,
Antonio

Matt Feury

unread,
Feb 25, 2016, 1:04:24 PM2/25/16
to Lift
the salad czar! that looks like it will work, although it makes me a little nervous to use that field "unsemantically." that could have strange side effects down the road. imo if the field is indexed, that field should be true. i like it as a workaround, but does make me nervous.

Antonio Salazar Cardozo

unread,
Feb 25, 2016, 2:02:45 PM2/25/16
to Lift
Yeah, I think its meaning isn't as semantic as the name indicates. Rest
assured, if we change the meaning, deprecations will abound.

I do wonder if dbIndexed_? should instead be indexType: Option[IndexType],
where IndexType could be something like Standard|Unique. Or perhaps
it could just be fieldIndexes and take a partial version of Index.
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages