r2dbc / r2dbc-mssql

R2DBC Driver for Microsoft SQL Server using TDS (Tabular Data Stream) Protocol
Apache License 2.0
183 stars 32 forks source link

MssqlConnectionConfiguration schema option. #258

Closed omuralcin-ge closed 1 year ago

omuralcin-ge commented 1 year ago

Feature Request

I searched it on Github and Stackoverflow but I didn't find anything about this feature. I am using MSSQL database and I want to create schema for each tenants. While I was designing per-schema multitenancy for mssql database I needed to add new schema name to connections of the each tenants like postgresql above :

protected PostgresqlConnectionConfiguration.Builder getPostgresqlConnectionConfigurationBuilder(String schema) {
    return PostgresqlConnectionConfiguration
            .builder()
            .username(dbUser)
            .password(dbPassword)
            .host(dbHost)
            .port(dbPort)
            .database(dbName)
            .schema(schemaName);
}

There is a schema option for PostgresqlConnectionConfiguration at the r2dbc-postgresql for this work but r2dbc-mssql doesn't provide schema option yet.So I couldn't add schema name to my mssql connection config.

Please add new feature for schema option to MssqlConnectionConfiguration class.

Best Regards.

mp911de commented 1 year ago

Care to elaborate? As far as I know, there's no direct support to set the namespace (owner namespace) through a driver other than logging into the database with an according user. Does the JDBC SQL Server driver have such an option?

omuralcin-ge commented 1 year ago

@mp911de I guess it's about user functionality not JDBC session for mssql. I found this answer about the JDBC schema option for mssql at the SO.

omuralcin-ge commented 1 year ago

@mp911de do you have an idea for this situation?

mp911de commented 1 year ago

The schema is a MS SQL-specific behavior that cannot be set through the driver/client. While Postgres allows setting a session variable to tell the session in which schema to look for a database object, but SQL Server doesn't support that.

The only thing I found so far is the default schema for a user but that is nothing we can affect from a driver side.

Therefore, I'm closing this ticket because it isn't actionable.