1 | import { Alias } from "./Alias";
|
2 | import { ObjectLiteral } from "../common/ObjectLiteral";
|
3 | import { OrderByCondition } from "../find-options/OrderByCondition";
|
4 | import { JoinAttribute } from "./JoinAttribute";
|
5 | import { RelationIdAttribute } from "./relation-id/RelationIdAttribute";
|
6 | import { RelationCountAttribute } from "./relation-count/RelationCountAttribute";
|
7 | import { Connection } from "../connection/Connection";
|
8 | import { EntityMetadata } from "../metadata/EntityMetadata";
|
9 | import { SelectQuery } from "./SelectQuery";
|
10 | import { ColumnMetadata } from "../metadata/ColumnMetadata";
|
11 | import { RelationMetadata } from "../metadata/RelationMetadata";
|
12 | import { QueryBuilder } from "./QueryBuilder";
|
13 | import { SelectQueryBuilderOption } from "./SelectQueryBuilderOption";
|
14 | /**
|
15 | * Contains all properties of the QueryBuilder that needs to be build a final query.
|
16 | */
|
17 | export declare class QueryExpressionMap {
|
18 | protected connection: Connection;
|
19 | /**
|
20 | * Indicates if QueryBuilder used to select entities and not a raw results.
|
21 | */
|
22 | queryEntity: boolean;
|
23 | /**
|
24 | * Main alias is a main selection object selected by QueryBuilder.
|
25 | */
|
26 | mainAlias?: Alias;
|
27 | /**
|
28 | * All aliases (including main alias) used in the query.
|
29 | */
|
30 | aliases: Alias[];
|
31 | /**
|
32 | * Represents query type. QueryBuilder is able to build SELECT, UPDATE and DELETE queries.
|
33 | */
|
34 | queryType: "select" | "update" | "delete" | "insert" | "relation";
|
35 | /**
|
36 | * Data needs to be SELECT-ed.
|
37 | */
|
38 | selects: SelectQuery[];
|
39 | /**
|
40 | * FROM-s to be selected.
|
41 | */
|
42 | /**
|
43 | * If update query was used, it needs "update set" - properties which will be updated by this query.
|
44 | * If insert query was used, it needs "insert set" - values that needs to be inserted.
|
45 | */
|
46 | valuesSet?: ObjectLiteral | ObjectLiteral[];
|
47 | /**
|
48 | * Optional returning (or output) clause for insert, update or delete queries.
|
49 | */
|
50 | returning: string | string[];
|
51 | /**
|
52 | * Extra returning columns to be added to the returning statement if driver supports it.
|
53 | */
|
54 | extraReturningColumns: ColumnMetadata[];
|
55 | /**
|
56 | * Optional on conflict statement used in insertion query in postgres.
|
57 | */
|
58 | onConflict: string;
|
59 | /**
|
60 | * Optional on ignore statement used in insertion query in databases.
|
61 | */
|
62 | onIgnore: string | boolean;
|
63 | /**
|
64 | * Optional on update statement used in insertion query in databases.
|
65 | */
|
66 | onUpdate: {
|
67 | columns?: string;
|
68 | conflict?: string;
|
69 | overwrite?: string;
|
70 | };
|
71 | /**
|
72 | * JOIN queries.
|
73 | */
|
74 | joinAttributes: JoinAttribute[];
|
75 | /**
|
76 | * RelationId queries.
|
77 | */
|
78 | relationIdAttributes: RelationIdAttribute[];
|
79 | /**
|
80 | * Relation count queries.
|
81 | */
|
82 | relationCountAttributes: RelationCountAttribute[];
|
83 | /**
|
84 | * WHERE queries.
|
85 | */
|
86 | wheres: {
|
87 | type: "simple" | "and" | "or";
|
88 | condition: string;
|
89 | }[];
|
90 | /**
|
91 | * HAVING queries.
|
92 | */
|
93 | havings: {
|
94 | type: "simple" | "and" | "or";
|
95 | condition: string;
|
96 | }[];
|
97 | /**
|
98 | * ORDER BY queries.
|
99 | */
|
100 | orderBys: OrderByCondition;
|
101 | /**
|
102 | * GROUP BY queries.
|
103 | */
|
104 | groupBys: string[];
|
105 | /**
|
106 | * LIMIT query.
|
107 | */
|
108 | limit?: number;
|
109 | /**
|
110 | * OFFSET query.
|
111 | */
|
112 | offset?: number;
|
113 | /**
|
114 | * Number of rows to skip of result using pagination.
|
115 | */
|
116 | skip?: number;
|
117 | /**
|
118 | * Number of rows to take using pagination.
|
119 | */
|
120 | take?: number;
|
121 | /**
|
122 | * Locking mode.
|
123 | */
|
124 | lockMode?: "optimistic" | "pessimistic_read" | "pessimistic_write" | "dirty_read";
|
125 | /**
|
126 | * Current version of the entity, used for locking.
|
127 | */
|
128 | lockVersion?: number | Date;
|
129 | /**
|
130 | * Parameters used to be escaped in final query.
|
131 | */
|
132 | parameters: ObjectLiteral;
|
133 | /**
|
134 | * Indicates if alias, table names and column names will be ecaped by driver, or not.
|
135 | *
|
136 | * todo: rename to isQuotingDisabled, also think if it should be named "escaping"
|
137 | */
|
138 | disableEscaping: boolean;
|
139 | /**
|
140 | * Indicates if virtual columns should be included in entity result.
|
141 | *
|
142 | * todo: what to do with it? is it properly used? what about persistence?
|
143 | */
|
144 | enableRelationIdValues: boolean;
|
145 | /**
|
146 | * Extra where condition appended to the end of original where conditions with AND keyword.
|
147 | * Original condition will be wrapped into brackets.
|
148 | */
|
149 | extraAppendedAndWhereCondition: string;
|
150 | /**
|
151 | * Indicates if query builder creates a subquery.
|
152 | */
|
153 | subQuery: boolean;
|
154 | /**
|
155 | * If QueryBuilder was created in a subquery mode then its parent QueryBuilder (who created subquery) will be stored here.
|
156 | */
|
157 | parentQueryBuilder: QueryBuilder<any>;
|
158 | /**
|
159 | * Indicates if property names are prefixed with alias names during property replacement.
|
160 | * By default this is enabled, however we need this because aliases are not supported in UPDATE and DELETE queries,
|
161 | * but user can use them in WHERE expressions.
|
162 | */
|
163 | aliasNamePrefixingEnabled: boolean;
|
164 | /**
|
165 | * Indicates if query result cache is enabled or not.
|
166 | */
|
167 | cache: boolean;
|
168 | /**
|
169 | * Time in milliseconds in which cache will expire.
|
170 | * If not set then global caching time will be used.
|
171 | */
|
172 | cacheDuration: number;
|
173 | /**
|
174 | * Cache id.
|
175 | * Used to identifier your cache queries.
|
176 | */
|
177 | cacheId: string;
|
178 | /**
|
179 | * Options that define QueryBuilder behaviour.
|
180 | */
|
181 | options: SelectQueryBuilderOption[];
|
182 | /**
|
183 | * Property path of relation to work with.
|
184 | * Used in relational query builder.
|
185 | */
|
186 | relationPropertyPath: string;
|
187 | /**
|
188 | * Entity (target) which relations will be updated.
|
189 | */
|
190 | of: any | any[];
|
191 | /**
|
192 | * List of columns where data should be inserted.
|
193 | * Used in INSERT query.
|
194 | */
|
195 | insertColumns: string[];
|
196 | /**
|
197 | * Used if user wants to update or delete a specific entities.
|
198 | */
|
199 | whereEntities: ObjectLiteral[];
|
200 | /**
|
201 | * Indicates if entity must be updated after insertion / updation.
|
202 | * This may produce extra query or use RETURNING / OUTPUT statement (depend on database).
|
203 | */
|
204 | updateEntity: boolean;
|
205 | /**
|
206 | * Indicates if listeners and subscribers must be called before and after query execution.
|
207 | */
|
208 | callListeners: boolean;
|
209 | /**
|
210 | * Indicates if query must be wrapped into transaction.
|
211 | */
|
212 | useTransaction: boolean;
|
213 | /**
|
214 | * Extra parameters.
|
215 | * Used in InsertQueryBuilder to avoid default parameters mechanizm and execute high performance insertions.
|
216 | */
|
217 | nativeParameters: ObjectLiteral;
|
218 | constructor(connection: Connection);
|
219 | /**
|
220 | * Get all ORDER BY queries - if order by is specified by user then it uses them,
|
221 | * otherwise it uses default entity order by if it was set.
|
222 | */
|
223 | readonly allOrderBys: OrderByCondition;
|
224 | /**
|
225 | * Creates a main alias and adds it to the current expression map.
|
226 | */
|
227 | setMainAlias(alias: Alias): Alias;
|
228 | /**
|
229 | * Creates a new alias and adds it to the current expression map.
|
230 | */
|
231 | createAlias(options: {
|
232 | type: "from" | "select" | "join" | "other";
|
233 | name?: string;
|
234 | target?: Function | string;
|
235 | tablePath?: string;
|
236 | subQuery?: string;
|
237 | metadata?: EntityMetadata;
|
238 | }): Alias;
|
239 | /**
|
240 | * Finds alias with the given name.
|
241 | * If alias was not found it throw an exception.
|
242 | */
|
243 | findAliasByName(aliasName: string): Alias;
|
244 | findColumnByAliasExpression(aliasExpression: string): ColumnMetadata | undefined;
|
245 | /**
|
246 | * Gets relation metadata of the relation this query builder works with.
|
247 | *
|
248 | * todo: add proper exceptions
|
249 | */
|
250 | readonly relationMetadata: RelationMetadata;
|
251 | /**
|
252 | * Copies all properties of the current QueryExpressionMap into a new one.
|
253 | * Useful when QueryBuilder needs to create a copy of itself.
|
254 | */
|
255 | clone(): QueryExpressionMap;
|
256 | }
|