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

Added connection attributes to SingleStore #3717

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) Red Gate Software Ltd 2010-2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.flywaydb.database;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.extensibility.PluginMetadata;
import org.flywaydb.core.internal.util.FileUtils;

public class SingleStoreDatabaseExtension implements PluginMetadata {
public String getDescription() {
return "SingleStoreDB database support " + readVersion() + " by Redgate";
}

public static String readVersion() {
try {
return FileUtils.copyToString(
SingleStoreDatabaseExtension.class.getClassLoader().getResourceAsStream("org/flywaydb/database/version.txt"),
StandardCharsets.UTF_8);
} catch (IOException e) {
throw new FlywayException("Unable to read extension version: " + e.getMessage(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import org.flywaydb.core.internal.jdbc.StatementInterceptor;
import org.flywaydb.core.internal.parser.Parser;
import org.flywaydb.core.internal.parser.ParsingContext;
import org.flywaydb.database.SingleStoreDatabaseExtension;

import java.sql.Connection;
import java.sql.Types;
import java.util.Arrays;
import java.util.Properties;

public class SingleStoreDatabaseType extends BaseDatabaseType {
@Override
Expand Down Expand Up @@ -56,6 +59,19 @@ public boolean handlesDatabaseProductNameAndVersion(String databaseProductName,
return databaseProductName.contains("SingleStore");
}

@Override
public void setDefaultConnectionProps(String url, Properties props, ClassLoader classLoader) {
props.put("connectionAttributes",
String.format("_connector_name:%s,_connector_version:%s,_product_version:%s,program_name:%s,program_version:%s,program_vendor:%s",
"SingleStoreDB Flyway connector",
SingleStoreDatabaseExtension.readVersion(),
SingleStoreDatabaseExtension.readVersion(),
"Redgate_Flyway",
SingleStoreDatabaseExtension.readVersion(),
"Redgate"
));
}

@Override
public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor) {
return new SingleStoreDatabase(configuration, jdbcConnectionFactory, statementInterceptor);
Expand Down