fix: sqlite3 memory typo and drop leading asterisk doc
Signed-off-by: Minn Soe <contributions@minn.io>
This commit is contained in:
@@ -83,7 +83,7 @@ describe('PluginConnectionDatabaseManager', () => {
|
||||
},
|
||||
differentclientconnstring: {
|
||||
client: 'sqlite3',
|
||||
connection: ':inmemory:',
|
||||
connection: ':memory:',
|
||||
},
|
||||
stringoverride: {
|
||||
connection: 'postgresql://testuser:testpass@acme:5432/userdbname',
|
||||
@@ -180,7 +180,7 @@ describe('PluginConnectionDatabaseManager', () => {
|
||||
backend: {
|
||||
database: {
|
||||
client: 'sqlite3',
|
||||
connection: ':inmemory:',
|
||||
connection: ':memory:',
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -192,7 +192,7 @@ describe('PluginConnectionDatabaseManager', () => {
|
||||
|
||||
expect(overrides).toHaveProperty(
|
||||
'connection.filename',
|
||||
expect.stringContaining(':inmemory:'),
|
||||
expect.stringContaining(':memory:'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -276,7 +276,7 @@ describe('PluginConnectionDatabaseManager', () => {
|
||||
|
||||
expect(baseConfig.get().client).toEqual('sqlite3');
|
||||
|
||||
expect(overrides).toHaveProperty('connection.filename', ':inmemory:');
|
||||
expect(overrides).toHaveProperty('connection.filename', ':memory:');
|
||||
});
|
||||
|
||||
it('generates a database name override when prefix is not explicitly set', async () => {
|
||||
|
||||
@@ -74,7 +74,7 @@ export class PluginConnectionDatabaseManager {
|
||||
* the value from `PluginConnectionDatabaseManager.DEFAULT_PREFIX`.
|
||||
*
|
||||
* @param pluginId Lookup the database name for given plugin
|
||||
* */
|
||||
*/
|
||||
getDatabaseName(pluginId: string): string {
|
||||
const pluginConfig: Config = this.getConfigForPlugin(pluginId);
|
||||
|
||||
@@ -83,7 +83,7 @@ export class PluginConnectionDatabaseManager {
|
||||
const rootSqliteName =
|
||||
typeof rootConnection === 'string'
|
||||
? rootConnection
|
||||
: this.config.getOptionalString('connection.filename') ?? ':inmemory:';
|
||||
: this.config.getOptionalString('connection.filename') ?? ':memory:';
|
||||
|
||||
const prefix =
|
||||
this.config.getOptionalString('prefix') ??
|
||||
@@ -95,7 +95,7 @@ export class PluginConnectionDatabaseManager {
|
||||
pluginConfig.getOptionalString('connection.database') ??
|
||||
// attempt to lookup sqlite3 database file name
|
||||
pluginConfig.getOptionalString('connection.filename') ??
|
||||
// if root is sqlite - attempt to use top level connection, fallback to :inmemory:
|
||||
// if root is sqlite - attempt to use top level connection, fallback to :memory:
|
||||
(isSqlite ? rootSqliteName : null) ??
|
||||
// generate a database name using prefix and pluginId
|
||||
`${prefix}${pluginId}`
|
||||
@@ -113,7 +113,7 @@ export class PluginConnectionDatabaseManager {
|
||||
* connection config will be extended with plugin specific config.
|
||||
*
|
||||
* @param pluginId The plugin that the database baseConfig should correspond to
|
||||
* */
|
||||
*/
|
||||
private getConfigForPlugin(pluginId: string): Config {
|
||||
const pluginConfig = this.config.getOptionalConfig(pluginPath(pluginId));
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ type DatabaseClient = 'pg' | 'sqlite3' | 'mysql' | 'mysql2' | string;
|
||||
*
|
||||
* Database connectors can be aliased here, for example mysql2 uses
|
||||
* the same connector as mysql.
|
||||
* */
|
||||
*/
|
||||
const ConnectorMapping: Record<DatabaseClient, DatabaseConnector> = {
|
||||
pg: pgConnector,
|
||||
sqlite3: sqlite3Connector,
|
||||
@@ -80,7 +80,7 @@ export async function ensureDatabaseExists(
|
||||
|
||||
/**
|
||||
* Provides a Knex.Config object with the provided database name for a given client.
|
||||
* */
|
||||
*/
|
||||
export function createNameOverride(
|
||||
client: string,
|
||||
name: string,
|
||||
@@ -97,7 +97,7 @@ export function createNameOverride(
|
||||
|
||||
/**
|
||||
* Parses a connection string for a given client and provides a connection config.
|
||||
* */
|
||||
*/
|
||||
export function parseConnectionString(
|
||||
connectionString: string,
|
||||
client?: string,
|
||||
@@ -119,7 +119,7 @@ export function parseConnectionString(
|
||||
|
||||
/**
|
||||
* Normalizes a connection config or string into an object which can be passed to Knex.
|
||||
* */
|
||||
*/
|
||||
export function normalizeConnection(
|
||||
connection: Knex.StaticConnectionConfig | JsonObject | string,
|
||||
client: string,
|
||||
|
||||
@@ -173,7 +173,7 @@ export function createMysqlNameOverride(name: string): Partial<Knex.Config> {
|
||||
* MySql database connector.
|
||||
*
|
||||
* Exposes database connector functionality via an immutable object.
|
||||
* */
|
||||
*/
|
||||
export const mysqlConnector: DatabaseConnector = Object.freeze({
|
||||
createClient: createMysqlDatabaseClient,
|
||||
ensureDatabaseExists: ensureMysqlDatabaseExists,
|
||||
|
||||
@@ -145,7 +145,7 @@ export function createPgNameOverride(name: string): Partial<Knex.Config> {
|
||||
* PostgreSQL database connector.
|
||||
*
|
||||
* Exposes database connector functionality via an immutable object.
|
||||
* */
|
||||
*/
|
||||
export const pgConnector: DatabaseConnector = Object.freeze({
|
||||
createClient: createPgDatabaseClient,
|
||||
ensureDatabaseExists: ensurePgDatabaseExists,
|
||||
|
||||
@@ -119,7 +119,7 @@ export function parseSqliteConnectionString(
|
||||
* Sqlite3 database connector.
|
||||
*
|
||||
* Exposes database connector functionality via an immutable object.
|
||||
* */
|
||||
*/
|
||||
export const sqlite3Connector: DatabaseConnector = Object.freeze({
|
||||
createClient: createSqliteDatabaseClient,
|
||||
createNameOverride: createSqliteNameOverride,
|
||||
|
||||
Reference in New Issue
Block a user