nayaverdier / dyntastic

A DynamoDB library on top of Pydantic and boto3.
MIT License
57 stars 14 forks source link

Attr query by class variables. #19

Open wesleyearlstander opened 8 months ago

wesleyearlstander commented 8 months ago

Hi team,

So I've had a look at the mechanism for querying and I feel as if it's very close to complete. My only question would be to perhaps rework the way that the query works to allow for the feeding in of class and its hinted variables. Then the work is offloaded to the Attr library internally.

This would allow for auto-completion when querying an object. I haven't played with the library but from the looks of it, you won't get static analysis on those variables from the Attr class.

This I think would be the final implementation change that would make the library extra-ordinary and bring it into wide usage.

I will re-iterate that this library is fantastic and I'm extremely grateful for the work already done on it. I'm curious if I can find a way to implement the above so I'll try take a look at it.

nayaverdier commented 8 months ago

That's a great idea. I'm not sure if there's a way to automatically treat the types of the class (e.g. MyTable.some_field) as Attr while still keeping MyTable(...).some_field as the original type defined, at least for the purposes of autocompletion. If you can find some way, that would be fantastic.

It looks like SQLAlchemy uses Mapped to provide this functionality, but this requires hinting all fields as Mapped[int], etc.