dialect.d.ts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { entityKind } from "../entity.js";
  2. import type { MigrationConfig, MigrationMeta } from "../migrator.js";
  3. import { type BuildRelationalQueryResult, type DBQueryConfig, type Relation, type TableRelationalConfig, type TablesRelationalConfig } from "../relations.js";
  4. import { type QueryWithTypings, SQL } from "../sql/sql.js";
  5. import { SQLiteColumn } from "./columns/index.js";
  6. import type { SQLiteDeleteConfig, SQLiteInsertConfig, SQLiteUpdateConfig } from "./query-builders/index.js";
  7. import { SQLiteTable } from "./table.js";
  8. import { type Casing, type UpdateSet } from "../utils.js";
  9. import type { SQLiteSelectConfig } from "./query-builders/select.types.js";
  10. import type { SQLiteSession } from "./session.js";
  11. export interface SQLiteDialectConfig {
  12. casing?: Casing;
  13. }
  14. export declare abstract class SQLiteDialect {
  15. static readonly [entityKind]: string;
  16. constructor(config?: SQLiteDialectConfig);
  17. escapeName(name: string): string;
  18. escapeParam(_num: number): string;
  19. escapeString(str: string): string;
  20. private buildWithCTE;
  21. buildDeleteQuery({ table, where, returning, withList, limit, orderBy, }: SQLiteDeleteConfig): SQL;
  22. buildUpdateSet(table: SQLiteTable, set: UpdateSet): SQL;
  23. buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy, }: SQLiteUpdateConfig): SQL;
  24. /**
  25. * Builds selection SQL with provided fields/expressions
  26. *
  27. * Examples:
  28. *
  29. * `select <selection> from`
  30. *
  31. * `insert ... returning <selection>`
  32. *
  33. * If `isSingleTable` is true, then columns won't be prefixed with table name
  34. */
  35. private buildSelection;
  36. private buildJoins;
  37. private buildLimit;
  38. private buildOrderBy;
  39. private buildFromTable;
  40. buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, distinct, setOperators, }: SQLiteSelectConfig): SQL;
  41. buildSetOperations(leftSelect: SQL, setOperators: SQLiteSelectConfig['setOperators']): SQL;
  42. buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset }, }: {
  43. leftSelect: SQL;
  44. setOperator: SQLiteSelectConfig['setOperators'][number];
  45. }): SQL;
  46. buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, }: SQLiteInsertConfig): SQL;
  47. sqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings;
  48. buildRelationalQuery({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
  49. fullSchema: Record<string, unknown>;
  50. schema: TablesRelationalConfig;
  51. tableNamesMap: Record<string, string>;
  52. table: SQLiteTable;
  53. tableConfig: TableRelationalConfig;
  54. queryConfig: true | DBQueryConfig<'many', true>;
  55. tableAlias: string;
  56. nestedQueryRelation?: Relation;
  57. joinOn?: SQL;
  58. }): BuildRelationalQueryResult<SQLiteTable, SQLiteColumn>;
  59. }
  60. export declare class SQLiteSyncDialect extends SQLiteDialect {
  61. static readonly [entityKind]: string;
  62. migrate(migrations: MigrationMeta[], session: SQLiteSession<'sync', unknown, Record<string, unknown>, TablesRelationalConfig>, config?: string | MigrationConfig): void;
  63. }
  64. export declare class SQLiteAsyncDialect extends SQLiteDialect {
  65. static readonly [entityKind]: string;
  66. migrate(migrations: MigrationMeta[], session: SQLiteSession<'async', any, any, any>, config?: string | MigrationConfig): Promise<void>;
  67. }