Comments (3)
For postgresql you need to specifiy all columns in the group by statement (except for the aggregate), so it should look like this:
auto records = _connection(
select(
reports.id,
reports.aoi,
reports.toi,
reports.roi,
reports.story,
reports.created,
reports.properties,
reports.author,
users.firstName,
users.lastName,
count(places.id)
).from(
reports.join(users).on(reports.author == users.id).left_outer_join(places).on(reports.id == places.report)
).group_by(reports.id, reports.aoi, reports.toi, reports.roi, reports.story, reports.created, reports.properties, reports.author, users.firstName, users.Lastname)
.limit(limit).offset(offset).order_by(reports.id.asc()).unconditionally()
);
from sqlpp11-connector-postgresql.
But in PgAdmin SQL query works only with group by reports.id.
I tried including all the fields. the reports.properties
is of type json
but in sqlpp11 it is mapped as text
It gave me exceptions
ERROR: could not identify an equality operator for type json
LINE 1: ...rts.toi,reports.roi,reports.story,reports.created,reports.pr...
^
unhandled exception ERROR: could not identify an equality operator for type json
LINE 1: ...rts.toi,reports.roi,reports.story,reports.created,reports.pr...
^
from sqlpp11-connector-postgresql.
Interesting. I thought that @matthijs is right, but maybe there are rules for joins that allow this? Iยดd be thankful if you could dig up the rules that allow to use group by reports.id only.
However, the rules for select in the library are as stated.
Since you apparently cannot group by the JSON field, I see two options:
- Use
verbatim
. That is a bit hacky, but probably the fastest way. - Restructure your query to join with a select. Something like this (taken from test/Select.cpp):
auto rowCount = select(t.alpha, count(t.alpha)).from(t).unconditionally().group_by(t.alpha).as(sqlpp::alias::a);
db(select(f.omega, rowCount.count)
.from(f.join(rowCount).on(f.omega == rowCount.alpha))
.unconditionally()
.order_by(rowCount.count.asc()));
from sqlpp11-connector-postgresql.
Related Issues (20)
- Why boost dependency? HOT 2
- AppVeyor failed HOT 4
- Add additional types to ddl2cpp.py? HOT 13
- Compile for armv7 HOT 2
- wrong time point inserted by prepared statement on windows HOT 6
- if schema is public, generated code does not compile HOT 4
- Timezones not handled properly HOT 1
- Connection (& everything) silently fails HOT 1
- [question] Example of using extensions from contrib package HOT 1
- How to use it with sqlpp::connection_pool HOT 1
- Add UUID support HOT 8
- Underlying connector does not support size() HOT 2
- Primary key value of the inserted row HOT 4
- Linker error: undefined reference to `sqlpp::postgresql::connection::connection` HOT 16
- JSON field in where clause HOT 2
- fix double precision floating point. HOT 2
- Missing error check in last_insert_id()
- How can i get raw sql string from sqlpp::select/update/insert HOT 1
- Breaking changes in sqlpp11 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlpp11-connector-postgresql.