Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Mario564 committed Nov 11, 2023
1 parent 5b62339 commit a6b1e68
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 56 deletions.
7 changes: 4 additions & 3 deletions drizzle-orm/src/built-in-function.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { entityKind } from './entity.ts';
import { Dialect } from './column-builder.ts';
import { type SQLWrapper, type SQL, sql, DriverValueDecoder, GetDecoderResult } from './sql/sql.ts';
import type { Dialect } from './column-builder.ts';
import type { SQLWrapper, SQL, DriverValueDecoder, GetDecoderResult } from './sql/sql.ts';

/** @internal */
export const BuiltInFunctionSQL = Symbol.for('drizzle:BuiltInFunctionSQL');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface BuiltInFunction<T = unknown> extends SQLWrapper {
// SQLWrapper runtime implementation is defined in 'sql/sql.ts'
}
Expand All @@ -24,7 +25,7 @@ export abstract class BuiltInFunction<T = unknown> implements SQLWrapper {
/** @internal */
get [BuiltInFunctionSQL](): SQL<T> {
return this.sql;
};
}

protected sql: SQL<T>;

Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/distinct.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { entityKind, is } from './entity.ts';
import { type SQLWrapper } from './index.ts';
import type { SQLWrapper } from './index.ts';

/** @internal */
export const DistinctValue = Symbol.for('drizzle:DistinctValue');
Expand Down
24 changes: 7 additions & 17 deletions drizzle-orm/src/mysql-core/functions/aggregate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { is, entityKind } from '~/entity.ts';
import { MySqlColumn } from '../columns/index.ts';
import { type SQL, sql, type SQLWrapper, isSQLWrapper, SQLChunk } from '~/sql/index.ts';
import { sql, type SQLWrapper, isSQLWrapper, type SQLChunk } from '~/sql/index.ts';
import { MySqlBuiltInFunction } from './common.ts';
import { type MaybeDistinct, getValueWithDistinct } from '~/distinct.ts';

Expand Down Expand Up @@ -122,14 +122,9 @@ export function max<T extends SQLWrapper>(expression: T): T extends MySqlColumn
? MySqlAggregateFunction<T['_']['data'] | null>
: MySqlAggregateFunction<string | null>
{
let sql_ = sql.join([sql`max(`, expression, sql`)`]);

if (is(expression, MySqlColumn)) {
sql_ = sql_.mapWith(expression);
} else {
sql_ = sql_.mapWith(String);
}

const sql_ = sql
.join([sql`max(`, expression, sql`)`])
.mapWith(is(expression, MySqlColumn) ? expression : String);
return new MySqlAggregateFunction(sql_) as any;
}

Expand All @@ -147,13 +142,8 @@ export function min<T extends SQLWrapper>(expression: T): T extends MySqlColumn
? MySqlAggregateFunction<T['_']['data'] | null>
: MySqlAggregateFunction<string | null>
{
let sql_ = sql.join([sql`min(`, expression, sql`)`]);

if (is(expression, MySqlColumn)) {
sql_ = sql_.mapWith(expression);
} else {
sql_ = sql_.mapWith(String);
}

const sql_ = sql
.join([sql`min(`, expression, sql`)`])
.mapWith(is(expression, MySqlColumn) ? expression : String);
return new MySqlAggregateFunction(sql_) as any;
}
24 changes: 7 additions & 17 deletions drizzle-orm/src/pg-core/functions/aggregate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { is, entityKind } from '~/entity.ts';
import { PgColumn } from '../columns/index.ts';
import { type SQL, sql, type SQLWrapper, isSQLWrapper, SQLChunk } from '~/sql/index.ts';
import { type SQL, sql, type SQLWrapper, isSQLWrapper, type SQLChunk } from '~/sql/index.ts';
import { PgBuiltInFunction } from './common.ts';
import { type MaybeDistinct, getValueWithDistinct } from '~/distinct.ts';

Expand Down Expand Up @@ -135,14 +135,9 @@ export function max<T extends SQLWrapper>(expression: T): T extends PgColumn
? PgAggregateFunction<T['_']['data'] | null>
: PgAggregateFunction<string | null>
{
let sql_ = sql.join([sql`max(`, expression, sql`)`]);

if (is(expression, PgColumn)) {
sql_ = sql_.mapWith(expression);
} else {
sql_ = sql_.mapWith(String);
}

const sql_ = sql
.join([sql`max(`, expression, sql`)`])
.mapWith(is(expression, PgColumn) ? expression : String);
return new PgAggregateFunction(sql_) as any;
}

Expand All @@ -160,13 +155,8 @@ export function min<T extends SQLWrapper>(expression: T): T extends PgColumn
? PgAggregateFunction<T['_']['data'] | null>
: PgAggregateFunction<string | null>
{
let sql_ = sql.join([sql`min(`, expression, sql`)`]);

if (is(expression, PgColumn)) {
sql_ = sql_.mapWith(expression);
} else {
sql_ = sql_.mapWith(String);
}

const sql_ = sql
.join([sql`min(`, expression, sql`)`])
.mapWith(is(expression, PgColumn) ? expression : String);
return new PgAggregateFunction(sql_) as any;
}
2 changes: 1 addition & 1 deletion drizzle-orm/src/pg-core/query-builders/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Table } from '~/table.ts';
import { mapUpdateSet, orderSelectedFields, type UpdateSet } from '~/utils.ts';
import type { SelectedFields, SelectedFieldsOrdered } from './select.types.ts';
import type { PgColumn } from '../columns/common.ts';
import { PgBuiltInFunction } from '../functions/common.ts'
import type { PgBuiltInFunction } from '../functions/common.ts'

export interface PgUpdateConfig {
where?: SQL | undefined;
Expand Down
24 changes: 7 additions & 17 deletions drizzle-orm/src/sqlite-core/functions/aggregate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { is, entityKind } from '~/entity.ts';
import { SQLiteColumn } from '../columns/index.ts';
import { type SQL, sql, type SQLWrapper, isSQLWrapper, SQLChunk } from '~/sql/index.ts';
import { type SQL, sql, type SQLWrapper, isSQLWrapper, type SQLChunk } from '~/sql/index.ts';
import { SQLiteBuiltInFunction } from './common.ts';
import { type MaybeDistinct, getValueWithDistinct } from '~/distinct.ts';

Expand Down Expand Up @@ -143,14 +143,9 @@ export function max<T extends SQLWrapper>(expression: T): T extends SQLiteColumn
? SQLiteAggregateFunction<T['_']['data'] | null>
: SQLiteAggregateFunction<string | null>
{
let sql_ = sql.join([sql`max(`, expression, sql`)`]);

if (is(expression, SQLiteColumn)) {
sql_ = sql_.mapWith(expression);
} else {
sql_ = sql_.mapWith(String);
}

const sql_ = sql
.join([sql`max(`, expression, sql`)`])
.mapWith(is(expression, SQLiteColumn) ? expression : String)
return new SQLiteAggregateFunction(sql_) as any;
}

Expand All @@ -168,13 +163,8 @@ export function min<T extends SQLWrapper>(expression: T): T extends SQLiteColumn
? SQLiteAggregateFunction<T['_']['data'] | null>
: SQLiteAggregateFunction<string | null>
{
let sql_ = sql.join([sql`min(`, expression, sql`)`]);

if (is(expression, SQLiteColumn)) {
sql_ = sql_.mapWith(expression);
} else {
sql_ = sql_.mapWith(String);
}

const sql_ = sql
.join([sql`min(`, expression, sql`)`])
.mapWith(is(expression, SQLiteColumn) ? expression : String);
return new SQLiteAggregateFunction(sql_) as any;
}

0 comments on commit a6b1e68

Please sign in to comment.