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

Add Support for TRY_CAST in PostgreSQL Dialect #2142

Open
bjp232004 opened this issue Sep 27, 2024 · 0 comments
Open

Add Support for TRY_CAST in PostgreSQL Dialect #2142

bjp232004 opened this issue Sep 27, 2024 · 0 comments
Assignees

Comments

@bjp232004
Copy link

Describe the bug
We are using the PostgreSQL dialect to verify SQL queries. Along with that, we support various SQL functions, and one of the functions we use is TRY_CAST. However, PostgreSQL dialect natively supports CAST but does not support TRY_CAST.

We need a way to add support for the TRY_CAST function, even though PostgreSQL itself does not have native support for this function.

Database Engine
PostgreSQL + Additional Custom Function

To Reproduce
-the SQL that be parsed: select TRY_CAST(field1 as INT) from table
-the node-sql-parser version: 5.2.0
Node Version: 20+

Expected behavior
TRY_CAST should function similarly to other databases that support it, where it tries to cast the value to the target type and returns NULL if the cast fails.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

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

2 participants