Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace var names select, base_select, base_query with query #44270

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dstandish
Copy link
Contributor

Previosly it was base_select then recently renamed to select. select is not a great choice because it collides with the sqlalchemy function. Query is a better name.

Also best to remove the "base" part of it because we tend to mutate it, making it not a "base" of anything.

def apply_filters_to_select(
*, base_select: Select, filters: Sequence[BaseParam | None] | None = None
) -> Select:
def apply_filters_to_select(*, query: Select, filters: Sequence[BaseParam | None] | None = None) -> Select:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about select_obj since this is not yet a query? It becomes a query when we use session.scalars, session.execute etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query is also a sqlalchemy function. But, I think, we can just leave it to be select cause, within the function, there's no need for sqlalchemy's select. If it's confusing, we can also make it _select or select_obj

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote for select_obj too. select and query are both in the SQLAchemy namespace. Also as Ephraim mentioned a Select is not the same as a Query.

+1 for removing the base in every name.

Copy link
Contributor Author

@dstandish dstandish Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i'm aware of Query but i don't think there is a query free function. query is a very common word for what you would pass here. you can see it in very many places in the codebase where we use query to refer to a select.

Copy link
Contributor Author

@dstandish dstandish Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and yes, query is a method on session; but this of course does not collide with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See what i mean?

query is a colloquial term for "select statement"

Used in many places already
image

Copy link
Contributor Author

@dstandish dstandish Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, @ephraimbuddy i'm not sure what you mean. it beomes some kind of a "result" object after running through scalars. i'm not sure it every becomes a Query object. and anyway, again, i'm not naming the object because of its class (we have annotations to tell us that anyway) i am just giving it a name to describe what it is in simple terms.

but, ok, if y'all really hate query, we can do statement. please let me know. for now i leave it query.

Copy link
Member

@potiuk potiuk Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is hard. I agree query is bad choice.

How about select_statement as a name ? Sounds pretty obvious to me - BTW. I think select_obj is proably worse idea than query.

Previosly it was `base_select` then recently renamed to `select`.  `select` is not
a great choice because it collides with the sqlalchemy function.  Query is a better name.

Also best to remove the "base" part of it because we tend to mutate it, making it not a "base" of anything.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants