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

Cannot use IF NOT EXISTS when creating extensions #5356

Open
Angel-Ponce opened this issue Jul 16, 2024 · 1 comment
Open

Cannot use IF NOT EXISTS when creating extensions #5356

Angel-Ponce opened this issue Jul 16, 2024 · 1 comment
Labels

Comments

@Angel-Ponce
Copy link

SQLDelight Version

2.0.2

SQLDelight Dialect

PostgreSQL

Describe the Bug

I'm trying to execute:

CREATE EXTENSION IF NOT EXISTS unaccent;

But it seems that it's not supported yet.

image

Stacktrace

No response

@griffio
Copy link
Contributor

griffio commented Jul 17, 2024

🤔 It should already be in 2.0.2

create_extension_stmt ::= CREATE 'EXTENSION' [ IF NOT EXISTS ] extension_name [ WITH ] [ 'SCHEMA' id ] [ 'VERSION' extension_version ] [ CASCADE ]

(Though your screen shot shows "CREATE IF NOT EXISTS EXTENSION..." that is invalid)

Here is an example project https://github.com/griffio/sqldelight-postgres-textsearch/blob/master/src/main/sqldelight/griffio/migrations/V1__Initial_version.sqm that uses pg_trgm for improved text searching in Postgres.

Note: The big issue with using PostgreSql extensions with SqlDelight is that any functions and types that are loaded by the extension, SqlDelight will not recognise them. The example here shows this can be mitigated with creating a custom dialect module https://github.com/griffio/sqldelight-custom-dialect/tree/master adding in some of the text search functions

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