8000 Difference in behavior between a Field and an Attribute when used directly in a class · Issue #835 · kayak/pypika · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Difference in behavior between a Field and an Attribute when used directly in a class #835

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

Open
PedroH183 opened this issue Apr 2, 2025 · 0 comments

Comments

@PedroH183
Copy link

Below, I show a simple example. The generated SQL has a difference in the "" around the field, but in the docs it is showed as equivalent.

What is the proper use case for these features ?

from pypika import Table, Query, Field, Parameter

shops = Table("shops")

first_query = Query.from_(shops).select(
    Field(shops.id, 'identification')
).where(
    shops.id == Parameter("%(shop_id)s")
)
# SELECT ""id"" "identification" FROM "shops" WHERE "id"=%(shop_id)s

second_query = Query.from_(shops).select(
    shops.id.as_('identification')
).where(
    shops.id == Parameter("%(shop_id)s")
)
# SELECT "id" "identification" FROM "shops" WHERE "id"='%(shop_id)s'

assert first_query == second_query
print(first_query, second_query)
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

No branches or pull requests

1 participant
0