Comments (7)
When supporting multiple aggregate columns we should consider that there could be queries that mix aggregate and non-aggregate fields. See for example the following query:
SELECT a.id, count(b::id) FROM a LEFT JOIN b ON a.id = b.a_id GROUP BY a.id;
from diesel.
@aturon @nikomatsakis Was thinking about this recently, and thought you might be interested as it would have been helped by the lattice rule, but could be aided by other additions to the type system as well. Basically we have an impl that looks like this for every size tuple:
impl<T, U> Expression for (T, U) where
T: Expression + NonAggregate,
U: Expression + NonAggregate,
{
// ...
}
What we need is to write something along the lines of:
impl<T, U> Expression for (T, U) where
T: Expression + !NonAggregate,
U: Expression + !NonAggregate,
{
// ...
}
With the lattice rule we could have added an Aggregate
trait, and then had an impl for T: Expression + Aggregate + NonAggregate
with a body that would force it to fail to compile if it was ever used. Ultimately though, what we really need here is either negative reasoning, or mutual exclusion.
The main goal (in case there's another solution that I'm missing) is to make sure that we do not have an impl for T: Aggregate, U: NonAggregate
.
from diesel.
Also I know you had asked me to keep you in the loop when I find some concrete examples to point you guys at. Is there a preferred form of communication besides just pinging you on issues like this?
from diesel.
@sgrif this seems good. The hard part I guess might be finding these examples later -- I'll try to keep a log. For what it's worth, this would probably be addressed by the semi-proposal for negative reasoning I advanced in this comment, which itself is just a variant on rust-lang/rfcs#1148.
from diesel.
@sgrif Thanks for the heads up! In general issue comments like this are fine -- perhaps you could have a meta-issue with links to various examples as they come up, just so there's ultimately one place to track?
from diesel.
This problem could possibly be solved by using a PhantomData
marker similar to these two examples: ebfull/pcap and hyperium/hyper.
from diesel.
Closed by #2251
from diesel.
Related Issues (20)
- `overflow evaluating the requirement` when writing generic diesel code HOT 1
- Pagination guide doesn't work on entity represented by joined tables HOT 2
- losing type information when adding WHERE (filter) clause to query HOT 2
- Diesel not generate joinable when there are 2 foreign keys reference same field HOT 1
- `#[derive(AsExpression, FromSqlRow)]` won't compile when generic bounds have a default implementation. HOT 2
- Serials keep incrementing despite begin_test_transaction HOT 3
- Source code for diesel_derives 2.1.2 not available on GitHub HOT 1
- Cannot use multiple table_name for Insertable when also deriving Queryable HOT 1
- SSL_MODE option not behaving correctly with Mysql 5.7 HOT 3
- Derive Queryable deserialize_as attribute doesn't support tuples HOT 4
- msvc+rust1.75 compile error HOT 4
- `Using unsupported buffer type: 253 (parameter: 1)` when trying to use the CLI HOT 14
- double free or corruption issue when establishing connection HOT 18
- Unable to group by date HOT 1
- Regression: LIKE queries on nullable fields in MySQL HOT 5
- Windows CI is failing to install postgres HOT 2
- Can not use .eq(Decimal_field + xxx) HOT 4
- Closing a sqlite connection does not clear the -wal and -shm file HOT 4
- Execute single-statement migrations without batch_execute HOT 6
- Linking error for diesel_cli in Alpine despite libraries being installed HOT 5
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 diesel.