On Thu, Apr 13, 2023, at 1:13 PM, Peter Harrison wrote:
> Thanks Mike,
> 
> Ideally we'd prefer to find a solution via Graphene-SQLAlchemy. Unfortunately 
> we don't have the luxury of creating our own query when interacting with 
> Graphene-SQLAlchemy.
> 
> So the key question for us is, can you modify an existing 
> sqlalchemy.orm.query.Query object to insert a "func.max(Data.value)" object 
> into the select?

yes, use the add_columns method

https://docs.sqlalchemy.org/en/20/orm/queryguide/query.html#sqlalchemy.orm.Query.add_columns


> 
> 
> 
> This is what Graphene-SQLAlchemy is giving us.
> If this is possible, then the group_by part is easy. We have tested that 
> frequently, the hard part is the modifying the original "select" object.
> 
> 1. We have tried add_columns, but that adds in incompatible object type in 
> the GraphQL results making it an unusable option.

I dont know what that means... wouldn't this be an issue for 
graphene-SQLAlchemy to fix?  this is a basic Query method.  if you can query 
individual columns to GraphQL, it should work.  Then as stated before, if 
whatever graphene-sqlalchemy does is not compatible with individual columns, 
that would have to be resolved on that end.


> 2. We thought that modifying the select would be  possible using data with 
> "statement.froms" but can't figure out how to update the MetaData object in it

again this is very vague and doesn't make much sense.   if you want to add a 
fromclause to a select() or a query, there's an add_froms() method.   This has 
nothing to do with updating MetaData objects, which are not part of the "froms" 
of a select and are only a collection that Table objects belong towards, and 
they have nothing to do with how SELECT statements are rendered.

> 
> If modifying the "select" after its creation is not possible, we need to 
> start considering using a separate reporting table with hourly data.

yes unfortunately I know nothing about graphene-sqlalchemy or graphql and these 
sound like details that are deeply embedded in a larger system, the people who 
created this extension would have the best chance of helping with new 
integrations.   

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/275f600c-86fd-4870-bf83-79699d4f7164%40app.fastmail.com.

Reply via email to