Make the text length limit optional

This commit is contained in:
Eike Kettner
2021-01-22 22:56:51 +01:00
parent 8dd1672c8c
commit c7e850116f
5 changed files with 35 additions and 17 deletions

View File

@ -578,7 +578,7 @@ object QItem {
)
)(
Select(
select(substring(m.content.s, 0, maxLen).s, tagsTid.s, tagsName.s),
select(contentMax(maxLen), tagsTid.s, tagsName.s),
from(i)
.innerJoin(a, a.itemId === i.id)
.innerJoin(m, a.id === m.id)
@ -597,7 +597,7 @@ object QItem {
): ConnectionIO[TextAndTag] =
readTextAndTag(collective, itemId, pageSep) {
Select(
select(substring(m.content.s, 0, maxLen).s, org.oid.s, org.name.s),
select(contentMax(maxLen), org.oid.s, org.name.s),
from(i)
.innerJoin(a, a.itemId === i.id)
.innerJoin(m, m.id === a.id)
@ -614,7 +614,7 @@ object QItem {
): ConnectionIO[TextAndTag] =
readTextAndTag(collective, itemId, pageSep) {
Select(
select(substring(m.content.s, 0, maxLen).s, pers0.pid.s, pers0.name.s),
select(contentMax(maxLen), pers0.pid.s, pers0.name.s),
from(i)
.innerJoin(a, a.itemId === i.id)
.innerJoin(m, m.id === a.id)
@ -631,7 +631,7 @@ object QItem {
): ConnectionIO[TextAndTag] =
readTextAndTag(collective, itemId, pageSep) {
Select(
select(substring(m.content.s, 0, maxLen).s, pers0.pid.s, pers0.name.s),
select(contentMax(maxLen), pers0.pid.s, pers0.name.s),
from(i)
.innerJoin(a, a.itemId === i.id)
.innerJoin(m, m.id === a.id)
@ -648,7 +648,7 @@ object QItem {
): ConnectionIO[TextAndTag] =
readTextAndTag(collective, itemId, pageSep) {
Select(
select(substring(m.content.s, 0, maxLen).s, equip.eid.s, equip.name.s),
select(contentMax(maxLen), equip.eid.s, equip.name.s),
from(i)
.innerJoin(a, a.itemId === i.id)
.innerJoin(m, m.id === a.id)
@ -657,6 +657,12 @@ object QItem {
)
}
private def contentMax(maxLen: Int): SelectExpr =
if (maxLen <= 0) {
logger.debug("Max text length limit disabled")
m.content.s
} else substring(m.content.s, 0, maxLen).s
private def readTextAndTag(collective: Ident, itemId: Ident, pageSep: String)(
q: Select
): ConnectionIO[TextAndTag] =