-
I would like to concatenate two columns but all what I get are errors :-( abstract class Bookings extends View {
Companies get c;
ProductionCompanies get pc;
Projects get p;
Events get e;
Positions get p2;
Contracts get c2;
@override
Query as() => select([
c.firstName,
c.lastName,
// const CustomExpression<String>("companies.firstname || ' ' || companies.lastname as company"),
p.projectName,
e.shootingDay,
c2.token,
c2.lastName,
c2.firstName,
p2.checkIn,
p2.checkOut,
p2.role,
]).from(c).join([
innerJoin(pc, c.companyId.equalsExp(pc.companyId) & c.companyDb.equalsExp(pc.companyDb)),
innerJoin(p, pc.companyId.equalsExp(p.companyId) & pc.companyDb.equalsExp(p.companyDb)),
innerJoin(e, p.projectId.equalsExp(e.projectId) & p.projectDb.equalsExp(e.projectDb)),
innerJoin(p2, e.eventId.equalsExp(p2.eventId) & e.eventDb.equalsExp(p2.eventDb)),
innerJoin(c2, p2.positionId.equalsExp(c2.positionId) & p2.positionDb.equalsExp(c2.positionDb)),
]);
} For example, when I use this
|
Beta Was this translation helpful? Give feedback.
Answered by
simolus3
Feb 17, 2022
Replies: 2 comments
-
Columns added in So you can do abstract class Bookings extends View {
Companies get c;
// ...
Expression<String> get company => c.firstname + c.lastname;
@override
Query as() => select([
c.firstName,
c.lastName,
company,
p.projectName,
e.shootingDay,
c2.token,
c2.lastName,
c2.firstName,
p2.checkIn,
p2.checkOut,
p2.role,
]).from(c).join([
innerJoin(pc, c.companyId.equalsExp(pc.companyId) & c.companyDb.equalsExp(pc.companyDb)),
innerJoin(p, pc.companyId.equalsExp(p.companyId) & pc.companyDb.equalsExp(p.companyDb)),
innerJoin(e, p.projectId.equalsExp(e.projectId) & p.projectDb.equalsExp(e.projectDb)),
innerJoin(p2, e.eventId.equalsExp(p2.eventId) & e.eventDb.equalsExp(p2.eventDb)),
innerJoin(c2, p2.positionId.equalsExp(c2.positionId) & p2.positionDb.equalsExp(c2.positionDb)),
]);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
-
this is my final Expression<String> get company => c.firstName + const Constant(' ') + c.lastName; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Columns added in
as()
should be simple references. I see that neither the docs nor the error message are particularly clear on this, I'll improve the UX here. The reason for that is that we need a name for the column, which we read from the getter.So you can do