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

Doesn't handle psql casting without whitespace #30

Closed
DrFriedParts opened this issue Mar 12, 2016 · 2 comments
Closed

Doesn't handle psql casting without whitespace #30

DrFriedParts opened this issue Mar 12, 2016 · 2 comments
Labels

Comments

@DrFriedParts
Copy link

This is/should-be valid HugSQL because it is valid PSQL (works correctly in Yesql).

SELECT * FROM "the_table"
WHERE id = :key::bigint

But it will generate

SELECT * FROM "the_table" WHERE id = $1

instead of

SELECT * FROM "the_table" WHERE id = $1::bigint

The work-around is to add whitespace between the cast and the keyword, but it should support the concatenated format, no?

@csummers
Copy link
Member

HugSQL tries to support Postgresql type casting with ::, but this is a bit of an edge case when it is immediately preceded by a :parameter because of HugSQL's :param-type:param-name syntax.

HugSQL does support escaping the colon with \:.

SELECT * FROM "the_table"
WHERE id = :key\:\:bigint

I'll keep looking at this and see if I can build in a work-around.

@csummers
Copy link
Member

Support for this has been released in 0.4.5. Please confirm it works for you. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants