drizzle-orm-pg
Advanced tools
Comparing version 0.12.0-beta.36 to 0.12.0-beta.37
@@ -55,3 +55,3 @@ import { Logger, MigrationConfig, MigrationMeta } from 'drizzle-orm'; | ||
private buildSelection; | ||
buildSelectQuery({ fields, where, table, joins, orderBy, groupBy, limit, offset }: PgSelectConfig): SQL; | ||
buildSelectQuery({ fields, where, table, joins, orderBy, limit, offset }: PgSelectConfig): SQL; | ||
buildInsertQuery({ table, values, onConflict, returning }: PgInsertConfig): SQL; | ||
@@ -58,0 +58,0 @@ prepareSQL(sql: SQL): Query; |
@@ -201,3 +201,3 @@ "use strict"; | ||
} | ||
buildSelectQuery({ fields, where, table, joins, orderBy, groupBy, limit, offset }) { | ||
buildSelectQuery({ fields, where, table, joins, orderBy, limit, offset }) { | ||
const joinKeys = Object.keys(joins); | ||
@@ -230,13 +230,5 @@ const selection = this.buildSelection(fields, { isSingleTable: joinKeys.length === 0 }); | ||
const orderBySql = orderByList.length > 0 ? (0, drizzle_orm_1.sql) ` order by ${drizzle_orm_1.sql.fromList(orderByList)}` : undefined; | ||
const groupByList = []; | ||
groupBy.forEach((groupByValue, index) => { | ||
groupByList.push(groupByValue); | ||
if (index < groupBy.length - 1) { | ||
groupByList.push((0, drizzle_orm_1.sql) `, `); | ||
} | ||
}); | ||
const groupBySql = groupByList.length > 0 ? (0, drizzle_orm_1.sql) ` group by ${drizzle_orm_1.sql.fromList(groupByList)}` : undefined; | ||
const limitSql = limit ? (0, drizzle_orm_1.sql) ` limit ${limit}` : undefined; | ||
const offsetSql = offset ? (0, drizzle_orm_1.sql) ` offset ${offset}` : undefined; | ||
return (0, drizzle_orm_1.sql) `select ${selection} from ${table}${joinsSql}${whereSql}${groupBySql}${orderBySql}${limitSql}${offsetSql}`; | ||
return (0, drizzle_orm_1.sql) `select ${selection} from ${table}${joinsSql}${whereSql}${orderBySql}${limitSql}${offsetSql}`; | ||
} | ||
@@ -243,0 +235,0 @@ buildInsertQuery({ table, values, onConflict, returning }) { |
@@ -1,2 +0,2 @@ | ||
import { SQL, SQLWrapper } from 'drizzle-orm/sql'; | ||
import { SQL } from 'drizzle-orm/sql'; | ||
import { QueryResult, QueryResultRow } from 'pg'; | ||
@@ -13,4 +13,3 @@ import { AnyPgTable, InferModel, PgDialect, PgSession } from '.'; | ||
delete<TTable extends AnyPgTable>(table: TTable): PgDelete<TTable>; | ||
buildQuery(sqlWrapper: SQLWrapper): import("drizzle-orm/sql").Query; | ||
execute<T extends QueryResultRow = QueryResultRow>(query: SQL): Promise<QueryResult<T>>; | ||
} |
@@ -25,5 +25,2 @@ "use strict"; | ||
} | ||
buildQuery(sqlWrapper) { | ||
return sqlWrapper.getSQL().toQuery({ escapeName: this.dialect.escapeName, escapeParam: this.dialect.escapeParam }); | ||
} | ||
execute(query) { | ||
@@ -30,0 +27,0 @@ const { sql, params } = this.dialect.prepareSQL(query); |
{ | ||
"name": "drizzle-orm-pg", | ||
"version": "0.12.0-beta.36", | ||
"version": "0.12.0-beta.37", | ||
"description": "Drizzle ORM package for PostgreSQL database", | ||
@@ -48,4 +48,4 @@ "main": "index.js", | ||
"scripts": { | ||
"build": "concurrently -n build,test \"tsc -p tsconfig.build.json && resolve-tspaths\" pnpm:test", | ||
"test": "cd tests && tsc", | ||
"build": "tsc -p tsconfig.build.json && resolve-tspaths", | ||
"test:types": "cd tests && tsc", | ||
"pack": "cp README.md package.json dist/ && (cd dist && pnpm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz", | ||
@@ -52,0 +52,0 @@ "publish:beta": "npm publish package.tgz --tag beta", |
@@ -0,1 +1,2 @@ | ||
import { QueryPromise } from 'drizzle-orm/query-promise'; | ||
import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; | ||
@@ -6,3 +7,2 @@ import { QueryResult } from 'pg'; | ||
import { AnyPgTable, GetTableConfig, InferModel } from '../table'; | ||
import { QueryPromise } from './common'; | ||
export interface PgDeleteConfig { | ||
@@ -9,0 +9,0 @@ where?: SQL | undefined; |
@@ -13,6 +13,6 @@ "use strict"; | ||
exports.PgDelete = void 0; | ||
const query_promise_1 = require("drizzle-orm/query-promise"); | ||
const utils_1 = require("drizzle-orm/utils"); | ||
const table_1 = require("../table"); | ||
const common_1 = require("./common"); | ||
class PgDelete extends common_1.QueryPromise { | ||
class PgDelete extends query_promise_1.QueryPromise { | ||
constructor(table, session, dialect) { | ||
@@ -19,0 +19,0 @@ super(); |
@@ -0,1 +1,2 @@ | ||
import { QueryPromise } from 'drizzle-orm/query-promise'; | ||
import { Param, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; | ||
@@ -7,3 +8,2 @@ import { QueryResult } from 'pg'; | ||
import { AnyPgTable, GetTableConfig, InferModel } from '../table'; | ||
import { QueryPromise } from './common'; | ||
import { PgUpdateSetSource } from './update'; | ||
@@ -10,0 +10,0 @@ export interface PgInsertConfig<TTable extends AnyPgTable = AnyPgTable> { |
@@ -14,2 +14,3 @@ "use strict"; | ||
const drizzle_orm_1 = require("drizzle-orm"); | ||
const query_promise_1 = require("drizzle-orm/query-promise"); | ||
const sql_1 = require("drizzle-orm/sql"); | ||
@@ -19,3 +20,2 @@ const utils_1 = require("drizzle-orm/utils"); | ||
const utils_2 = require("../utils"); | ||
const common_1 = require("./common"); | ||
class PgInsertBuilder { | ||
@@ -46,3 +46,3 @@ constructor(table, session, dialect) { | ||
exports.PgInsertBuilder = PgInsertBuilder; | ||
class PgInsert extends common_1.QueryPromise { | ||
class PgInsert extends query_promise_1.QueryPromise { | ||
constructor(table, values, session, dialect) { | ||
@@ -49,0 +49,0 @@ super(); |
@@ -1,2 +0,2 @@ | ||
import { AnyColumn } from 'drizzle-orm'; | ||
import { QueryPromise } from 'drizzle-orm/query-promise'; | ||
import { Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; | ||
@@ -6,3 +6,2 @@ import { PgDialect, PgSession } from '../connection'; | ||
import { AnyPgTable, GetTableConfig } from '../table'; | ||
import { QueryPromise } from './common'; | ||
import { AppendToResult, JoinNullability, JoinsValue, JoinType, SelectResult } from './select.types'; | ||
@@ -17,3 +16,2 @@ export interface PgSelectConfig { | ||
orderBy: SQL[]; | ||
groupBy: (AnyColumn | SQL)[]; | ||
} | ||
@@ -36,3 +34,2 @@ export declare class PgSelect<TTable extends AnyPgTable, TInitialSelectResultFields extends SelectResultFields<PgSelectFields<GetTableConfig<TTable, 'name'>>>, TResult = undefined, TJoinsNotNullable extends Record<string, JoinNullability> = Record<GetTableConfig<TTable, 'name'>, 'not-null'>> extends QueryPromise<SelectResult<TTable, TResult, TInitialSelectResultFields, TJoinsNotNullable>> implements SQLWrapper { | ||
where(where: SQL | undefined): Omit<this, 'where' | `${JoinType}Join`>; | ||
groupBy(...columns: (AnyColumn | SQL)[]): Omit<this, 'where' | `${JoinType}Join`>; | ||
orderBy(...columns: SQL[]): Omit<this, 'where' | `${JoinType}Join` | 'orderBy'>; | ||
@@ -39,0 +36,0 @@ limit(limit: number): Omit<this, 'where' | `${JoinType}Join` | 'limit'>; |
@@ -13,6 +13,6 @@ "use strict"; | ||
exports.PgSelect = void 0; | ||
const query_promise_1 = require("drizzle-orm/query-promise"); | ||
const utils_1 = require("drizzle-orm/utils"); | ||
const table_1 = require("../table"); | ||
const common_1 = require("./common"); | ||
class PgSelect extends common_1.QueryPromise { | ||
class PgSelect extends query_promise_1.QueryPromise { | ||
constructor(table, fields, session, dialect) { | ||
@@ -31,3 +31,2 @@ super(); | ||
orderBy: [], | ||
groupBy: [], | ||
}; | ||
@@ -75,6 +74,2 @@ this.joinsNotNullable = { [table[table_1.PgTable.Symbol.Name]]: true }; | ||
} | ||
groupBy(...columns) { | ||
this.config.groupBy = columns; | ||
return this; | ||
} | ||
orderBy(...columns) { | ||
@@ -81,0 +76,0 @@ this.config.orderBy = columns; |
import { GetColumnData } from 'drizzle-orm'; | ||
import { QueryPromise } from 'drizzle-orm/query-promise'; | ||
import { Param, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; | ||
@@ -8,3 +9,2 @@ import { Simplify } from 'drizzle-orm/utils'; | ||
import { AnyPgTable, GetTableConfig, InferModel } from '../table'; | ||
import { QueryPromise } from './common'; | ||
export interface PgUpdateConfig { | ||
@@ -11,0 +11,0 @@ where?: SQL | undefined; |
@@ -13,6 +13,6 @@ "use strict"; | ||
exports.PgUpdate = exports.PgUpdateBuilder = void 0; | ||
const query_promise_1 = require("drizzle-orm/query-promise"); | ||
const utils_1 = require("drizzle-orm/utils"); | ||
const table_1 = require("../table"); | ||
const utils_2 = require("../utils"); | ||
const common_1 = require("./common"); | ||
class PgUpdateBuilder { | ||
@@ -29,3 +29,3 @@ constructor(table, session, dialect) { | ||
exports.PgUpdateBuilder = PgUpdateBuilder; | ||
class PgUpdate extends common_1.QueryPromise { | ||
class PgUpdate extends query_promise_1.QueryPromise { | ||
constructor(table, set, session, dialect) { | ||
@@ -32,0 +32,0 @@ super(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
188743
137
3087