dialect.d.cts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { entityKind } from "../entity.cjs";
  2. import { GelColumn } from "./columns/index.cjs";
  3. import type { GelDeleteConfig, GelInsertConfig, GelUpdateConfig } from "./query-builders/index.cjs";
  4. import type { GelSelectConfig } from "./query-builders/select.types.cjs";
  5. import { GelTable } from "./table.cjs";
  6. import { type BuildRelationalQueryResult, type DBQueryConfig, type Relation, type TableRelationalConfig, type TablesRelationalConfig } from "../relations.cjs";
  7. import { type DriverValueEncoder, type QueryTypingsValue, type QueryWithTypings, SQL } from "../sql/sql.cjs";
  8. import { type Casing, type UpdateSet } from "../utils.cjs";
  9. import type { GelMaterializedView } from "./view.cjs";
  10. export interface GelDialectConfig {
  11. casing?: Casing;
  12. }
  13. export declare class GelDialect {
  14. static readonly [entityKind]: string;
  15. constructor(config?: GelDialectConfig);
  16. escapeName(name: string): string;
  17. escapeParam(num: number): string;
  18. escapeString(str: string): string;
  19. private buildWithCTE;
  20. buildDeleteQuery({ table, where, returning, withList }: GelDeleteConfig): SQL;
  21. buildUpdateSet(table: GelTable, set: UpdateSet): SQL;
  22. buildUpdateQuery({ table, set, where, returning, withList, from, joins }: GelUpdateConfig): SQL;
  23. /**
  24. * Builds selection SQL with provided fields/expressions
  25. *
  26. * Examples:
  27. *
  28. * `select <selection> from`
  29. *
  30. * `insert ... returning <selection>`
  31. *
  32. * If `isSingleTable` is true, then columns won't be prefixed with table name
  33. * ^ Temporarily disabled behaviour, see comments within method for a reasoning
  34. */
  35. private buildSelection;
  36. private buildJoins;
  37. private buildFromTable;
  38. buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, lockingClause, distinct, setOperators, }: GelSelectConfig): SQL;
  39. buildSetOperations(leftSelect: SQL, setOperators: GelSelectConfig['setOperators']): SQL;
  40. buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset }, }: {
  41. leftSelect: SQL;
  42. setOperator: GelSelectConfig['setOperators'][number];
  43. }): SQL;
  44. buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_ }: GelInsertConfig): SQL;
  45. buildRefreshMaterializedViewQuery({ view, concurrently, withNoData }: {
  46. view: GelMaterializedView;
  47. concurrently?: boolean;
  48. withNoData?: boolean;
  49. }): SQL;
  50. prepareTyping(encoder: DriverValueEncoder<unknown, unknown>): QueryTypingsValue;
  51. sqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings;
  52. buildRelationalQueryWithoutPK({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
  53. fullSchema: Record<string, unknown>;
  54. schema: TablesRelationalConfig;
  55. tableNamesMap: Record<string, string>;
  56. table: GelTable;
  57. tableConfig: TableRelationalConfig;
  58. queryConfig: true | DBQueryConfig<'many', true>;
  59. tableAlias: string;
  60. nestedQueryRelation?: Relation;
  61. joinOn?: SQL;
  62. }): BuildRelationalQueryResult<GelTable, GelColumn>;
  63. }