diff --git a/src/connections/bigquery.ts b/src/connections/bigquery.ts index 8edcab4..04d8138 100644 --- a/src/connections/bigquery.ts +++ b/src/connections/bigquery.ts @@ -204,7 +204,7 @@ export class BigQueryConnection extends SqlConnection { * @param parameters - An object containing the parameters to be used in the query. * @returns Promise<{ data: any, error: Error | null }> */ - async query>( + async internalQuery>( query: Query ): Promise> { try { diff --git a/src/connections/index.ts b/src/connections/index.ts index 250da7b..4199a72 100644 --- a/src/connections/index.ts +++ b/src/connections/index.ts @@ -32,7 +32,10 @@ export abstract class Connection { // Retrieve metadata about the database, useful for introspection. abstract fetchDatabaseSchema(): Promise; - abstract raw(query: string): Promise; + abstract raw( + query: string, + params?: Record | unknown[] + ): Promise; abstract testConnection(): Promise<{ error?: string }>; // Connection common operations that will be used by Outerbase diff --git a/src/connections/motherduck.ts b/src/connections/motherduck.ts index d4dcc7b..06f181b 100644 --- a/src/connections/motherduck.ts +++ b/src/connections/motherduck.ts @@ -51,7 +51,7 @@ export class DuckDBConnection extends PostgreBaseConnection { * @param parameters - An object containing the parameters to be used in the query. * @returns Promise<{ data: any, error: Error | null }> */ - async query>( + async internalQuery>( query: Query ): Promise> { const connection = this.connection; diff --git a/src/connections/mysql.ts b/src/connections/mysql.ts index 6a002ac..33321b4 100644 --- a/src/connections/mysql.ts +++ b/src/connections/mysql.ts @@ -225,7 +225,7 @@ export class MySQLConnection extends SqlConnection { return super.mapDataType(dataType); } - async query>( + async internalQuery>( query: Query ): Promise> { try { diff --git a/src/connections/postgre/postgresql.ts b/src/connections/postgre/postgresql.ts index 7acd3d2..4c36088 100644 --- a/src/connections/postgre/postgresql.ts +++ b/src/connections/postgre/postgresql.ts @@ -27,7 +27,7 @@ export class PostgreSQLConnection extends PostgreBaseConnection { await this.client.end(); } - async query>( + async internalQuery>( query: Query ): Promise> { try { diff --git a/src/connections/snowflake/snowflake.ts b/src/connections/snowflake/snowflake.ts index b4a9798..fbfd365 100644 --- a/src/connections/snowflake/snowflake.ts +++ b/src/connections/snowflake/snowflake.ts @@ -175,7 +175,7 @@ export class SnowflakeConnection extends PostgreBaseConnection { ); } - async query>( + async internalQuery>( query: Query ): Promise> { try { diff --git a/src/connections/sql-base.ts b/src/connections/sql-base.ts index 5df9114..652753c 100644 --- a/src/connections/sql-base.ts +++ b/src/connections/sql-base.ts @@ -16,7 +16,7 @@ export abstract class SqlConnection extends Connection { abstract dialect: AbstractDialect; protected numberedPlaceholder = false; - abstract query>( + abstract internalQuery>( query: Query ): Promise>; @@ -26,6 +26,23 @@ export abstract class SqlConnection extends Connection { return dataType; } + /** + * This is a deprecated function, use raw instead. We keep this for + * backward compatibility. + * + * @deprecated + * @param query + * @returns + */ + async query>( + query: Query + ): Promise> { + return (await this.raw( + query.query, + query.parameters + )) as QueryResult; + } + async raw( query: string, params?: Record | unknown[] @@ -51,7 +68,10 @@ export abstract class SqlConnection extends Connection { // Named placeholder const { query: newQuery, bindings } = namedPlaceholder(query, params!); - return await this.query({ query: newQuery, parameters: bindings }); + return await this.internalQuery({ + query: newQuery, + parameters: bindings, + }); } async select( diff --git a/src/connections/sqlite/cloudflare.ts b/src/connections/sqlite/cloudflare.ts index 0ac5190..adf529a 100644 --- a/src/connections/sqlite/cloudflare.ts +++ b/src/connections/sqlite/cloudflare.ts @@ -107,7 +107,7 @@ export class CloudflareD1Connection extends SqliteBaseConnection { * @param parameters - An object containing the parameters to be used in the query. * @returns Promise<{ data: any, error: Error | null }> */ - async query>( + async internalQuery>( query: Query ): Promise> { if (!this.apiKey) throw new Error('Cloudflare API key is not set'); diff --git a/src/connections/sqlite/starbase.ts b/src/connections/sqlite/starbase.ts index 0d8ee5f..98bba73 100644 --- a/src/connections/sqlite/starbase.ts +++ b/src/connections/sqlite/starbase.ts @@ -90,7 +90,7 @@ export class StarbaseConnection extends SqliteBaseConnection { * @param parameters - An object containing the parameters to be used in the query. * @returns Promise<{ data: any, error: Error | null }> */ - async query>( + async internalQuery>( query: Query ): Promise> { if (!this.url) throw new Error('Starbase URL is not set'); diff --git a/src/connections/sqlite/turso.ts b/src/connections/sqlite/turso.ts index f323608..4e03cd2 100644 --- a/src/connections/sqlite/turso.ts +++ b/src/connections/sqlite/turso.ts @@ -16,7 +16,7 @@ export class TursoConnection extends SqliteBaseConnection { this.client = client; } - async query>( + async internalQuery>( query: Query ): Promise> { try {