Skip to content

Fix SqlDelightModule type resolver order #5625

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

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

griffio
Copy link
Contributor

@griffio griffio commented Jan 22, 2025

Issue when looking into SqlDelightModules for potential use with PostgreSql Extensions - noticed that the typeResolver order is incorrect when loading a module DialectTypeResolver -> ModuleTypeResolver -> AnsiTypeResolver .

Currently it worked for Sqlite JsonModule as only added functions and not any types

Fix returns the typeResolver and parent resolver(s) composed of either:

DialectTypeResolver -> AnsiTypeResolver - no SqlDelightModule

ModuleTypeResolver -> DialectTypeResolver -> AnsiTypeResolver - with SqlDelightModule

This ensures that the Module TypeResolver methods are called first and can delegate to the dialect parent resolver for any inherited types and then the Ansi Resolver

Returns the typeResolver that is composed of either:

DialectTypeResolver(AnsiTypeResolver) - default

When loading a SqlDelightModule use

ModuleTypeResolver(DialectTypeResolver(AnsiTypeResolver))

This ensures that the Module TypeResolver methods are called first and can delegate to the immediate dialect parent for the base types
@griffio
Copy link
Contributor Author

griffio commented Jan 22, 2025

Dialect modules maybe an alternative way in supporting third-party PostgreSql extensions likePostGis currently in #5602 - add as a dialect module like json-module

e.g Locally, I created a hacky proof of concept for the same PostGis functionality loaded from a module like so

sqldelight {
    databases {
        create("Sample") {
             dialect("app.cash.sqldelight:postgresql-dialect:2.0.2")
             module("app.cash.sqldelight:postgresql-postgis-module:2.0.2")
        }
    }
}

@hfhbd hfhbd merged commit 1463930 into sqldelight:master Feb 11, 2025
12 checks passed
@griffio griffio deleted the fix-sqldelightmodule-type-resolver branch February 11, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants