@directus/api 24.0.0 → 24.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/get-ast-from-query/lib/parse-fields.js +4 -3
- package/dist/database/helpers/index.d.ts +1 -3
- package/dist/database/helpers/index.js +1 -3
- package/dist/database/helpers/schema/dialects/oracle.d.ts +6 -1
- package/dist/database/helpers/schema/dialects/oracle.js +15 -0
- package/dist/database/helpers/schema/types.d.ts +3 -1
- package/dist/database/helpers/schema/types.js +9 -0
- package/dist/operations/mail/index.d.ts +6 -3
- package/dist/operations/mail/index.js +2 -2
- package/dist/services/fields.js +22 -38
- package/dist/services/files.js +6 -5
- package/dist/utils/get-schema.js +1 -1
- package/dist/utils/sanitize-schema.d.ts +1 -1
- package/package.json +13 -13
- package/dist/database/helpers/nullable-update/dialects/default.d.ts +0 -3
- package/dist/database/helpers/nullable-update/dialects/default.js +0 -3
- package/dist/database/helpers/nullable-update/dialects/oracle.d.ts +0 -12
- package/dist/database/helpers/nullable-update/dialects/oracle.js +0 -16
- package/dist/database/helpers/nullable-update/index.d.ts +0 -7
- package/dist/database/helpers/nullable-update/index.js +0 -7
- package/dist/database/helpers/nullable-update/types.d.ts +0 -7
- package/dist/database/helpers/nullable-update/types.js +0 -12
|
@@ -169,10 +169,11 @@ export async function parseFields(options, context) {
|
|
|
169
169
|
continue;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
const childQuery = { ...options.query };
|
|
172
173
|
// update query alias for children parseFields
|
|
173
174
|
const deepAlias = getDeepQuery(options.deep?.[fieldKey] || {})?.['alias'];
|
|
174
|
-
if
|
|
175
|
-
|
|
175
|
+
// reset alias to empty if none are present
|
|
176
|
+
childQuery.alias = isEmpty(deepAlias) ? {} : deepAlias;
|
|
176
177
|
child = {
|
|
177
178
|
type: relationType,
|
|
178
179
|
name: relatedCollection,
|
|
@@ -184,7 +185,7 @@ export async function parseFields(options, context) {
|
|
|
184
185
|
children: await parseFields({
|
|
185
186
|
parentCollection: relatedCollection,
|
|
186
187
|
fields: nestedFields,
|
|
187
|
-
query:
|
|
188
|
+
query: childQuery,
|
|
188
189
|
deep: options.deep?.[fieldKey] || {},
|
|
189
190
|
accountability: options.accountability,
|
|
190
191
|
}, context),
|
|
@@ -3,17 +3,15 @@ import type { Knex } from 'knex';
|
|
|
3
3
|
import * as dateHelpers from './date/index.js';
|
|
4
4
|
import * as fnHelpers from './fn/index.js';
|
|
5
5
|
import * as geometryHelpers from './geometry/index.js';
|
|
6
|
+
import * as numberHelpers from './number/index.js';
|
|
6
7
|
import * as schemaHelpers from './schema/index.js';
|
|
7
8
|
import * as sequenceHelpers from './sequence/index.js';
|
|
8
|
-
import * as numberHelpers from './number/index.js';
|
|
9
|
-
import * as nullableUpdateHelper from './nullable-update/index.js';
|
|
10
9
|
export declare function getHelpers(database: Knex): {
|
|
11
10
|
date: dateHelpers.postgres | dateHelpers.oracle | dateHelpers.mysql | dateHelpers.mssql | dateHelpers.sqlite;
|
|
12
11
|
st: geometryHelpers.postgres | geometryHelpers.mssql | geometryHelpers.mysql | geometryHelpers.sqlite | geometryHelpers.oracle | geometryHelpers.redshift;
|
|
13
12
|
schema: schemaHelpers.cockroachdb | schemaHelpers.mssql | schemaHelpers.mysql | schemaHelpers.postgres | schemaHelpers.sqlite | schemaHelpers.oracle | schemaHelpers.redshift;
|
|
14
13
|
sequence: sequenceHelpers.mysql | sequenceHelpers.postgres;
|
|
15
14
|
number: numberHelpers.cockroachdb | numberHelpers.mssql | numberHelpers.postgres | numberHelpers.sqlite | numberHelpers.oracle;
|
|
16
|
-
nullableUpdate: nullableUpdateHelper.postgres | nullableUpdateHelper.oracle;
|
|
17
15
|
};
|
|
18
16
|
export declare function getFunctions(database: Knex, schema: SchemaOverview): fnHelpers.postgres | fnHelpers.mssql | fnHelpers.mysql | fnHelpers.sqlite | fnHelpers.oracle;
|
|
19
17
|
export type Helpers = ReturnType<typeof getHelpers>;
|
|
@@ -2,10 +2,9 @@ import { getDatabaseClient } from '../index.js';
|
|
|
2
2
|
import * as dateHelpers from './date/index.js';
|
|
3
3
|
import * as fnHelpers from './fn/index.js';
|
|
4
4
|
import * as geometryHelpers from './geometry/index.js';
|
|
5
|
+
import * as numberHelpers from './number/index.js';
|
|
5
6
|
import * as schemaHelpers from './schema/index.js';
|
|
6
7
|
import * as sequenceHelpers from './sequence/index.js';
|
|
7
|
-
import * as numberHelpers from './number/index.js';
|
|
8
|
-
import * as nullableUpdateHelper from './nullable-update/index.js';
|
|
9
8
|
export function getHelpers(database) {
|
|
10
9
|
const client = getDatabaseClient(database);
|
|
11
10
|
return {
|
|
@@ -14,7 +13,6 @@ export function getHelpers(database) {
|
|
|
14
13
|
schema: new schemaHelpers[client](database),
|
|
15
14
|
sequence: new sequenceHelpers[client](database),
|
|
16
15
|
number: new numberHelpers[client](database),
|
|
17
|
-
nullableUpdate: new nullableUpdateHelper[client](database),
|
|
18
16
|
};
|
|
19
17
|
}
|
|
20
18
|
export function getFunctions(database, schema) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KNEX_TYPES } from '@directus/constants';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Column } from '@directus/schema';
|
|
3
|
+
import type { Field, RawField, Relation, Type } from '@directus/types';
|
|
3
4
|
import type { Knex } from 'knex';
|
|
4
5
|
import type { Options, SortRecord, Sql } from '../types.js';
|
|
5
6
|
import { SchemaHelper } from '../types.js';
|
|
@@ -10,6 +11,10 @@ export declare class SchemaHelperOracle extends SchemaHelper {
|
|
|
10
11
|
preRelationChange(relation: Partial<Relation>): void;
|
|
11
12
|
processFieldType(field: Field): Type;
|
|
12
13
|
getDatabaseSize(): Promise<number | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Oracle throws an error when overwriting the nullable option for an existing column with the same value.
|
|
16
|
+
*/
|
|
17
|
+
setNullable(column: Knex.ColumnBuilder, field: RawField | Field, existing: Column | null): void;
|
|
13
18
|
prepQueryParams(queryParams: Sql): Sql;
|
|
14
19
|
prepBindings(bindings: Knex.Value[]): any;
|
|
15
20
|
addInnerSortFieldsToGroupBy(groupByFields: (string | Knex.Raw)[], sortRecords: SortRecord[], _hasRelationalSort: boolean): void;
|
|
@@ -52,6 +52,21 @@ export class SchemaHelperOracle extends SchemaHelper {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Oracle throws an error when overwriting the nullable option for an existing column with the same value.
|
|
57
|
+
*/
|
|
58
|
+
setNullable(column, field, existing) {
|
|
59
|
+
if (!existing) {
|
|
60
|
+
super.setNullable(column, field, existing);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (field.schema?.is_nullable === false && existing.is_nullable === true) {
|
|
64
|
+
column.notNullable();
|
|
65
|
+
}
|
|
66
|
+
else if (field.schema?.is_nullable === true && existing.is_nullable === false) {
|
|
67
|
+
column.nullable();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
55
70
|
prepQueryParams(queryParams) {
|
|
56
71
|
return prepQueryParams(queryParams, { format: (index) => `:${index + 1}` });
|
|
57
72
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KNEX_TYPES } from '@directus/constants';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Column } from '@directus/schema';
|
|
3
|
+
import type { Field, RawField, Relation, Type } from '@directus/types';
|
|
3
4
|
import type { Knex } from 'knex';
|
|
4
5
|
import type { DatabaseClient } from '../../../types/index.js';
|
|
5
6
|
import { DatabaseHelper } from '../types.js';
|
|
@@ -25,6 +26,7 @@ export declare abstract class SchemaHelper extends DatabaseHelper {
|
|
|
25
26
|
preColumnChange(): Promise<boolean>;
|
|
26
27
|
postColumnChange(): Promise<void>;
|
|
27
28
|
preRelationChange(_relation: Partial<Relation>): void;
|
|
29
|
+
setNullable(column: Knex.ColumnBuilder, field: RawField | Field, existing: Column | null): void;
|
|
28
30
|
processFieldType(field: Field): Type;
|
|
29
31
|
constraintName(existingName: string): string;
|
|
30
32
|
applyLimit(rootQuery: Knex.QueryBuilder, limit: number): void;
|
|
@@ -66,6 +66,15 @@ export class SchemaHelper extends DatabaseHelper {
|
|
|
66
66
|
preRelationChange(_relation) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
+
setNullable(column, field, existing) {
|
|
70
|
+
const isNullable = field.schema?.is_nullable ?? existing?.is_nullable ?? true;
|
|
71
|
+
if (isNullable) {
|
|
72
|
+
column.nullable();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
column.notNullable();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
69
78
|
processFieldType(field) {
|
|
70
79
|
return field.type;
|
|
71
80
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export type Options = {
|
|
2
|
-
body?: string;
|
|
3
|
-
template?: string;
|
|
4
|
-
data?: Record<string, any>;
|
|
5
2
|
to: string;
|
|
6
3
|
type: 'wysiwyg' | 'markdown' | 'template';
|
|
7
4
|
subject: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
template?: string;
|
|
7
|
+
data?: Record<string, any>;
|
|
8
|
+
cc?: string;
|
|
9
|
+
bcc?: string;
|
|
10
|
+
replyTo?: string;
|
|
8
11
|
};
|
|
9
12
|
declare const _default: import("@directus/extensions").OperationApiConfig<Options>;
|
|
10
13
|
export default _default;
|
|
@@ -5,9 +5,9 @@ import { useLogger } from '../../logger/index.js';
|
|
|
5
5
|
const logger = useLogger();
|
|
6
6
|
export default defineOperationApi({
|
|
7
7
|
id: 'mail',
|
|
8
|
-
handler: async ({ body, template, data, to, type, subject }, { accountability, database, getSchema }) => {
|
|
8
|
+
handler: async ({ body, template, data, to, type, subject, cc, bcc, replyTo }, { accountability, database, getSchema }) => {
|
|
9
9
|
const mailService = new MailService({ schema: await getSchema({ database }), accountability, knex: database });
|
|
10
|
-
const mailObject = { to, subject };
|
|
10
|
+
const mailObject = { to, subject, cc, bcc, replyTo };
|
|
11
11
|
const safeBody = typeof body !== 'string' ? JSON.stringify(body) : body;
|
|
12
12
|
if (type === 'template') {
|
|
13
13
|
mailObject.template = {
|
package/dist/services/fields.js
CHANGED
|
@@ -674,7 +674,17 @@ export class FieldsService {
|
|
|
674
674
|
else {
|
|
675
675
|
throw new InvalidPayloadError({ reason: `Illegal type passed: "${field.type}"` });
|
|
676
676
|
}
|
|
677
|
-
|
|
677
|
+
/**
|
|
678
|
+
* The column nullability must be set on every alter or it will be dropped
|
|
679
|
+
* This is due to column.alter() not being incremental per https://knexjs.org/guide/schema-builder.html#alter
|
|
680
|
+
*/
|
|
681
|
+
this.helpers.schema.setNullable(column, field, existing);
|
|
682
|
+
/**
|
|
683
|
+
* The default value must be set on every alter or it will be dropped
|
|
684
|
+
* This is due to column.alter() not being incremental per https://knexjs.org/guide/schema-builder.html#alter
|
|
685
|
+
*/
|
|
686
|
+
const defaultValue = field.schema?.default_value !== undefined ? field.schema?.default_value : existing?.default_value;
|
|
687
|
+
if (defaultValue !== undefined) {
|
|
678
688
|
const newDefaultValueIsString = typeof defaultValue === 'string';
|
|
679
689
|
const newDefaultIsNowFunction = newDefaultValueIsString && defaultValue.toLowerCase() === 'now()';
|
|
680
690
|
const newDefaultIsCurrentTimestamp = newDefaultValueIsString && defaultValue === 'CURRENT_TIMESTAMP';
|
|
@@ -694,57 +704,31 @@ export class FieldsService {
|
|
|
694
704
|
else {
|
|
695
705
|
column.defaultTo(defaultValue);
|
|
696
706
|
}
|
|
697
|
-
};
|
|
698
|
-
// for a new item, set the default value and nullable as provided without any further considerations
|
|
699
|
-
if (!existing) {
|
|
700
|
-
if (field.schema?.default_value !== undefined) {
|
|
701
|
-
setDefaultValue(field.schema.default_value);
|
|
702
|
-
}
|
|
703
|
-
if (field.schema?.is_nullable || field.schema?.is_nullable === undefined) {
|
|
704
|
-
column.nullable();
|
|
705
|
-
}
|
|
706
|
-
else {
|
|
707
|
-
column.notNullable();
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
else {
|
|
711
|
-
// for an existing item: if nullable option changed, we have to provide the default values as well and actually vice versa
|
|
712
|
-
// see https://knexjs.org/guide/schema-builder.html#alter
|
|
713
|
-
// To overwrite a nullable option with the same value this is not possible for Oracle though, hence the DB helper
|
|
714
|
-
if (field.schema?.default_value !== undefined || field.schema?.is_nullable !== undefined) {
|
|
715
|
-
this.helpers.nullableUpdate.updateNullableValue(column, field, existing);
|
|
716
|
-
let defaultValue = null;
|
|
717
|
-
if (field.schema?.default_value !== undefined) {
|
|
718
|
-
defaultValue = field.schema.default_value;
|
|
719
|
-
}
|
|
720
|
-
else if (existing.default_value !== undefined) {
|
|
721
|
-
defaultValue = existing.default_value;
|
|
722
|
-
}
|
|
723
|
-
setDefaultValue(defaultValue);
|
|
724
|
-
}
|
|
725
707
|
}
|
|
726
708
|
if (field.schema?.is_primary_key) {
|
|
727
709
|
column.primary().notNullable();
|
|
728
710
|
}
|
|
729
711
|
else if (!existing?.is_primary_key) {
|
|
730
712
|
// primary key will already have unique/index constraints
|
|
731
|
-
const uniqueIndexName = this.helpers.schema.generateIndexName('unique', collection, field.field);
|
|
732
713
|
if (field.schema?.is_unique === true) {
|
|
733
714
|
if (!existing || existing.is_unique === false) {
|
|
734
|
-
column.unique({ indexName:
|
|
715
|
+
column.unique({ indexName: this.helpers.schema.generateIndexName('unique', collection, field.field) });
|
|
735
716
|
}
|
|
736
717
|
}
|
|
737
718
|
else if (field.schema?.is_unique === false) {
|
|
738
|
-
if (existing
|
|
739
|
-
table.dropUnique([field.field],
|
|
719
|
+
if (existing?.is_unique === true) {
|
|
720
|
+
table.dropUnique([field.field], this.helpers.schema.generateIndexName('unique', collection, field.field));
|
|
740
721
|
}
|
|
741
722
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
723
|
+
if (field.schema?.is_indexed === true) {
|
|
724
|
+
if (!existing || existing.is_indexed === false) {
|
|
725
|
+
column.index(this.helpers.schema.generateIndexName('index', collection, field.field));
|
|
726
|
+
}
|
|
745
727
|
}
|
|
746
|
-
else if (field.schema?.is_indexed === false
|
|
747
|
-
|
|
728
|
+
else if (field.schema?.is_indexed === false) {
|
|
729
|
+
if (existing?.is_indexed === true) {
|
|
730
|
+
table.dropIndex([field.field], this.helpers.schema.generateIndexName('index', collection, field.field));
|
|
731
|
+
}
|
|
748
732
|
}
|
|
749
733
|
}
|
|
750
734
|
if (existing) {
|
package/dist/services/files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
|
-
import { ContentTooLargeError,
|
|
2
|
+
import { ContentTooLargeError, InvalidPayloadError, ServiceUnavailableError } from '@directus/errors';
|
|
3
3
|
import formatTitle from '@directus/format-title';
|
|
4
4
|
import { toArray } from '@directus/utils';
|
|
5
5
|
import encodeURL from 'encodeurl';
|
|
@@ -211,10 +211,11 @@ export class FilesService extends ItemsService {
|
|
|
211
211
|
*/
|
|
212
212
|
async deleteMany(keys) {
|
|
213
213
|
const storage = await getStorage();
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
214
|
+
const sudoFilesItemsService = new FilesService({
|
|
215
|
+
knex: this.knex,
|
|
216
|
+
schema: this.schema,
|
|
217
|
+
});
|
|
218
|
+
const files = await sudoFilesItemsService.readMany(keys, { fields: ['id', 'storage', 'filename_disk'], limit: -1 });
|
|
218
219
|
await super.deleteMany(keys);
|
|
219
220
|
for (const file of files) {
|
|
220
221
|
const disk = storage.location(file['storage']);
|
package/dist/utils/get-schema.js
CHANGED
|
@@ -44,10 +44,10 @@ export async function getSchema(options, attempt = 0) {
|
|
|
44
44
|
const subscription = new Promise((resolve, reject) => {
|
|
45
45
|
bus.subscribe(messageKey, busListener).catch(reject);
|
|
46
46
|
function busListener(options) {
|
|
47
|
+
cleanup();
|
|
47
48
|
if (options.schema === null) {
|
|
48
49
|
return reject();
|
|
49
50
|
}
|
|
50
|
-
cleanup();
|
|
51
51
|
setLocalSchemaCache(options.schema).catch(reject);
|
|
52
52
|
resolve(options.schema);
|
|
53
53
|
}
|
|
@@ -16,7 +16,7 @@ export declare function sanitizeCollection(collection: Collection | undefined):
|
|
|
16
16
|
* @returns sanitized field
|
|
17
17
|
*/
|
|
18
18
|
export declare function sanitizeField(field: Field | undefined, sanitizeAllSchema?: boolean): Partial<Field> | undefined;
|
|
19
|
-
export declare function sanitizeColumn(column: Column): Pick<Column, "table" | "name" | "
|
|
19
|
+
export declare function sanitizeColumn(column: Column): Pick<Column, "table" | "name" | "data_type" | "default_value" | "max_length" | "numeric_precision" | "numeric_scale" | "is_nullable" | "is_unique" | "is_indexed" | "is_primary_key" | "is_generated" | "generation_expression" | "has_auto_increment" | "foreign_key_table" | "foreign_key_column">;
|
|
20
20
|
/**
|
|
21
21
|
* Pick certain database vendor specific relation properties that should be compared when performing diff
|
|
22
22
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.1",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"otplib": "12.0.1",
|
|
129
129
|
"p-limit": "6.2.0",
|
|
130
130
|
"p-queue": "8.0.1",
|
|
131
|
-
"papaparse": "5.
|
|
131
|
+
"papaparse": "5.4.1",
|
|
132
132
|
"pino": "9.6.0",
|
|
133
133
|
"pino-http": "10.3.0",
|
|
134
134
|
"pino-http-print": "3.1.0",
|
|
@@ -147,29 +147,29 @@
|
|
|
147
147
|
"ws": "8.18.0",
|
|
148
148
|
"zod": "3.24.1",
|
|
149
149
|
"zod-validation-error": "3.4.0",
|
|
150
|
+
"@directus/app": "13.6.0",
|
|
150
151
|
"@directus/constants": "13.0.0",
|
|
151
|
-
"@directus/app": "13.5.0",
|
|
152
152
|
"@directus/env": "5.0.0",
|
|
153
153
|
"@directus/errors": "2.0.0",
|
|
154
|
-
"@directus/extensions": "3.0.
|
|
155
|
-
"@directus/extensions-
|
|
156
|
-
"@directus/extensions-
|
|
154
|
+
"@directus/extensions": "3.0.1",
|
|
155
|
+
"@directus/extensions-registry": "3.0.1",
|
|
156
|
+
"@directus/extensions-sdk": "13.0.1",
|
|
157
157
|
"@directus/format-title": "12.0.0",
|
|
158
158
|
"@directus/memory": "3.0.0",
|
|
159
|
-
"@directus/pressure": "3.0.0",
|
|
160
159
|
"@directus/schema": "13.0.0",
|
|
161
160
|
"@directus/specs": "11.1.0",
|
|
162
|
-
"@directus/storage": "12.0.0",
|
|
163
161
|
"@directus/storage-driver-azure": "12.0.0",
|
|
164
|
-
"@directus/
|
|
165
|
-
"@directus/storage
|
|
162
|
+
"@directus/pressure": "3.0.0",
|
|
163
|
+
"@directus/storage": "12.0.0",
|
|
166
164
|
"@directus/storage-driver-cloudinary": "12.0.0",
|
|
165
|
+
"@directus/storage-driver-local": "12.0.0",
|
|
166
|
+
"@directus/storage-driver-gcs": "12.0.0",
|
|
167
|
+
"@directus/storage-driver-s3": "12.0.0",
|
|
167
168
|
"@directus/storage-driver-supabase": "3.0.0",
|
|
168
|
-
"@directus/system-data": "3.0.0",
|
|
169
169
|
"@directus/utils": "13.0.0",
|
|
170
|
-
"@directus/
|
|
170
|
+
"@directus/system-data": "3.0.0",
|
|
171
171
|
"@directus/validation": "2.0.0",
|
|
172
|
-
"directus": "11.4.
|
|
172
|
+
"directus": "11.4.1"
|
|
173
173
|
},
|
|
174
174
|
"devDependencies": {
|
|
175
175
|
"@directus/tsconfig": "3.0.0",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Column } from '@directus/schema';
|
|
2
|
-
import type { Field, RawField } from '@directus/types';
|
|
3
|
-
import type { Knex } from 'knex';
|
|
4
|
-
import { NullableFieldUpdateHelper } from '../types.js';
|
|
5
|
-
/**
|
|
6
|
-
* Oracle throws an error when overwriting the nullable option with same value.
|
|
7
|
-
* Therefore we need to check if the nullable option has changed and only then apply it.
|
|
8
|
-
* The default value can be set regardless of the previous value.
|
|
9
|
-
*/
|
|
10
|
-
export declare class NullableFieldUpdateHelperOracle extends NullableFieldUpdateHelper {
|
|
11
|
-
updateNullableValue(column: Knex.ColumnBuilder, field: RawField | Field, existing: Column): void;
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NullableFieldUpdateHelper } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Oracle throws an error when overwriting the nullable option with same value.
|
|
4
|
-
* Therefore we need to check if the nullable option has changed and only then apply it.
|
|
5
|
-
* The default value can be set regardless of the previous value.
|
|
6
|
-
*/
|
|
7
|
-
export class NullableFieldUpdateHelperOracle extends NullableFieldUpdateHelper {
|
|
8
|
-
updateNullableValue(column, field, existing) {
|
|
9
|
-
if (field.schema?.is_nullable === false && existing.is_nullable === true) {
|
|
10
|
-
column.notNullable();
|
|
11
|
-
}
|
|
12
|
-
else if (field.schema?.is_nullable === true && existing.is_nullable === false) {
|
|
13
|
-
column.nullable();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { NullableFieldUpdateHelperOracle as oracle } from './dialects/oracle.js';
|
|
2
|
-
export { NullableFieldUpdateHelperDefault as postgres } from './dialects/default.js';
|
|
3
|
-
export { NullableFieldUpdateHelperDefault as mysql } from './dialects/default.js';
|
|
4
|
-
export { NullableFieldUpdateHelperDefault as cockroachdb } from './dialects/default.js';
|
|
5
|
-
export { NullableFieldUpdateHelperDefault as redshift } from './dialects/default.js';
|
|
6
|
-
export { NullableFieldUpdateHelperDefault as sqlite } from './dialects/default.js';
|
|
7
|
-
export { NullableFieldUpdateHelperDefault as mssql } from './dialects/default.js';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { NullableFieldUpdateHelperOracle as oracle } from './dialects/oracle.js';
|
|
2
|
-
export { NullableFieldUpdateHelperDefault as postgres } from './dialects/default.js';
|
|
3
|
-
export { NullableFieldUpdateHelperDefault as mysql } from './dialects/default.js';
|
|
4
|
-
export { NullableFieldUpdateHelperDefault as cockroachdb } from './dialects/default.js';
|
|
5
|
-
export { NullableFieldUpdateHelperDefault as redshift } from './dialects/default.js';
|
|
6
|
-
export { NullableFieldUpdateHelperDefault as sqlite } from './dialects/default.js';
|
|
7
|
-
export { NullableFieldUpdateHelperDefault as mssql } from './dialects/default.js';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
import { DatabaseHelper } from '../types.js';
|
|
3
|
-
import type { Column } from '@directus/schema';
|
|
4
|
-
import type { Field, RawField } from '@directus/types';
|
|
5
|
-
export declare class NullableFieldUpdateHelper extends DatabaseHelper {
|
|
6
|
-
updateNullableValue(column: Knex.ColumnBuilder, field: RawField | Field, existing: Column): void;
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DatabaseHelper } from '../types.js';
|
|
2
|
-
export class NullableFieldUpdateHelper extends DatabaseHelper {
|
|
3
|
-
updateNullableValue(column, field, existing) {
|
|
4
|
-
const isNullable = field.schema?.is_nullable ?? existing?.is_nullable ?? true;
|
|
5
|
-
if (isNullable) {
|
|
6
|
-
column.nullable();
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
column.notNullable();
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|