我需要使用Postgres的generate_series函数,但是我不能用querydsl编写它。
我尝试编写以下代码:
final DatePath<LocalDate> days = Expressions.datePath(LocalDate.class, "days");
final JPASQLQuery<LocalDate> query = this.factory.query()
.select(days);
final DateExpression<LocalDate> generateSeries = Expressions.dateTemplate(LocalDate.class,
"generate_series('{0}'::date, '{1}'::date, '1 day')", Expressions.asDate(startDate), Expressions.asDate(endDate))
.as(days.getMetadata().getName());
final Expression<LocalDate> e = Expressions.path(LocalDate.class, generateSeries.toString());
final List<LocalDate> fetch = query.from(e).fetch();
但是它会生成此sql'select days from“ generate_series('2019-05-19':: date,'2019-05-25':: date,'1 day'”'),并带有引号导致错误。
我该怎么做?