orma
Advanced tools
Comparing version 1.0.259 to 1.0.260
@@ -14,3 +14,3 @@ import { Path } from '../../types'; | ||
record: Record<string, any> & { | ||
$operation: 'create' | 'update' | 'delete' | 'upsert'; | ||
$operation: 'create' | 'update' | 'delete' | 'upsert' | 'none'; | ||
}; | ||
@@ -17,0 +17,0 @@ path: Path; |
import { OrmaSchema } from '../types/schema/schema_types'; | ||
import { MutationPlan } from './plan/mutation_batches'; | ||
import { OrmaStatement } from './statement_generation/mutation_statements'; | ||
export type MutationOperation = 'create' | 'update' | 'delete'; | ||
export type MutationOperation = 'create' | 'update' | 'delete' | 'none'; | ||
export type operation = MutationOperation | 'query'; | ||
@@ -6,0 +6,0 @@ export type MysqlFunction = (statements: OrmaStatement[]) => Promise<Record<string, any>[][]>; |
@@ -34,3 +34,23 @@ "use strict"; | ||
}); | ||
(0, mocha_1.test)('handles operation none', async () => { | ||
const mutation = { | ||
posts: [ | ||
{ | ||
$operation: 'create', | ||
title: 'my post 1235', | ||
user_id: 1, | ||
post_has_categories: [ | ||
{ | ||
$operation: 'none' | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
const res = await (0, integration_setup_test_1.test_mutate)(mutation, [ | ||
{ $entity: 'users', $field: 'id', $values: [1] } | ||
]); | ||
(0, chai_1.expect)(1).to.equal(1); | ||
}); | ||
}); | ||
}); |
@@ -65,2 +65,5 @@ "use strict"; | ||
} | ||
else if (operation === 'none') { | ||
asts = []; | ||
} | ||
else { | ||
@@ -67,0 +70,0 @@ throw new Error(`Unrecognized $operation ${operation}`); |
@@ -14,3 +14,3 @@ "use strict"; | ||
type: 'string', | ||
enum: ['create', 'update', 'delete', 'upsert'], | ||
enum: ['create', 'update', 'delete', 'upsert', 'none'], | ||
}, | ||
@@ -25,3 +25,3 @@ }, | ||
type: 'string', | ||
enum: ['create', 'update', 'delete', 'upsert'], | ||
enum: ['create', 'update', 'delete', 'upsert', 'none'], | ||
}, | ||
@@ -28,0 +28,0 @@ $identifying_fields: { |
@@ -83,3 +83,4 @@ "use strict"; | ||
const is_create = mutation_pieces[piece_index].record.$operation === 'create'; | ||
return is_create ? [] : [piece_index]; | ||
const is_none = mutation_pieces[piece_index].record.$operation === 'none'; | ||
return is_create || is_none ? [] : [piece_index]; | ||
}); | ||
@@ -86,0 +87,0 @@ const identifying_where = (0, record_searching_1.get_identifying_where)(orma_schema, guid_map, mutation_pieces, relevant_piece_indices); |
@@ -9,3 +9,3 @@ "use strict"; | ||
(0, mocha_1.describe)(query_1.orma_nester.name, () => { | ||
(0, mocha_1.test)('nests restults', () => { | ||
(0, mocha_1.test)('nests results', () => { | ||
const result = (0, query_1.orma_nester)(global_test_schema_1.global_test_schema, { | ||
@@ -12,0 +12,0 @@ posts: { |
@@ -10,3 +10,3 @@ import { GetAllEdges, GetAllEntities, GetFieldNotNull, GetFields, GetFieldType } from '../schema/schema_helper_types'; | ||
}; | ||
type Operation = 'create' | 'update' | 'delete' | 'upsert'; | ||
type Operation = 'create' | 'update' | 'delete' | 'upsert' | 'none'; | ||
type FieldsObj<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = { | ||
@@ -13,0 +13,0 @@ readonly [Field in GetFields<Schema, Entity>]?: FieldType<Schema, Entity, Field> | (Field extends GetAllEdges<Schema, Entity>['from_field'] ? { |
{ | ||
"name": "orma", | ||
"version": "1.0.259", | ||
"version": "1.0.260", | ||
"description": "A declarative relational syncronous orm", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -70,3 +70,3 @@ import { Path } from '../../types' | ||
record: Record<string, any> & { | ||
$operation: 'create' | 'update' | 'delete' | 'upsert' | ||
$operation: 'create' | 'update' | 'delete' | 'upsert' | 'none' | ||
} | ||
@@ -73,0 +73,0 @@ path: Path |
@@ -39,3 +39,25 @@ import { describe, test } from 'mocha' | ||
}) | ||
test('handles operation none', async () => { | ||
const mutation = { | ||
posts: [ | ||
{ | ||
$operation: 'create', | ||
title: 'my post 1235', | ||
user_id: 1, | ||
post_has_categories: [ | ||
{ | ||
$operation: 'none' | ||
} | ||
] | ||
} | ||
] | ||
} as const satisfies GlobalTestMutation | ||
const res = await test_mutate(mutation, [ | ||
{ $entity: 'users', $field: 'id', $values: [1] } | ||
]) | ||
expect(1).to.equal(1) | ||
}) | ||
}) | ||
}) |
@@ -24,3 +24,3 @@ import { OrmaSchema } from '../types/schema/schema_types' | ||
export type MutationOperation = 'create' | 'update' | 'delete' | ||
export type MutationOperation = 'create' | 'update' | 'delete' | 'none' | ||
export type operation = MutationOperation | 'query' | ||
@@ -27,0 +27,0 @@ export type MysqlFunction = ( |
@@ -133,2 +133,4 @@ import { push_path } from '../../helpers/push_path' | ||
] | ||
} else if (operation === 'none') { | ||
asts = [] | ||
} else { | ||
@@ -135,0 +137,0 @@ throw new Error(`Unrecognized $operation ${operation}`) |
@@ -25,3 +25,3 @@ import { validate } from 'jsonschema' | ||
type: 'string', | ||
enum: ['create', 'update', 'delete', 'upsert'], | ||
enum: ['create', 'update', 'delete', 'upsert', 'none'], | ||
}, | ||
@@ -36,3 +36,3 @@ }, | ||
type: 'string', | ||
enum: ['create', 'update', 'delete', 'upsert'], | ||
enum: ['create', 'update', 'delete', 'upsert', 'none'], | ||
}, | ||
@@ -39,0 +39,0 @@ $identifying_fields: { |
@@ -153,3 +153,6 @@ import { OrmaError } from '../../helpers/error_handling' | ||
return is_create ? [] : [piece_index] | ||
const is_none = | ||
mutation_pieces[piece_index].record.$operation === 'none' | ||
return is_create || is_none ? [] : [piece_index] | ||
}) | ||
@@ -156,0 +159,0 @@ const identifying_where = get_identifying_where( |
@@ -8,3 +8,3 @@ import { expect } from 'chai' | ||
describe(orma_nester.name, () => { | ||
test('nests restults', () => { | ||
test('nests results', () => { | ||
const result = orma_nester( | ||
@@ -11,0 +11,0 @@ global_test_schema, |
@@ -30,3 +30,3 @@ import { GlobalTestSchema } from '../../test_data/global_test_schema' | ||
type Operation = 'create' | 'update' | 'delete' | 'upsert' | ||
type Operation = 'create' | 'update' | 'delete' | 'upsert' | 'none' | ||
@@ -33,0 +33,0 @@ type FieldsObj< |
1693201
41260