Skip to content

Commit

Permalink
typesTree against tree_id: 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Jun 10, 2023
1 parent c6d6b16 commit 1767589
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions imports/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ async ({ deep, require, gql, data: { newLink } }) => {
{ id: 'promiseTreePromiseResult', type: 'TreeIncludeNode', from: 'promiseTree', to: 'PromiseResult' },

{ id: 'MigrationsEnd', type: 'Type' },

{ id: 'typesTree', type: 'Tree' },
],
errors: [],
strict: true,
Expand Down
4 changes: 3 additions & 1 deletion migrations/1621815803572-materialized-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const triggerOptionos = {
mpInclude."to_id" IN (NEW.type_id, ${_ids?.['@deep-foundation/core']?.Any}) AND
mpInclude."from_id" = mpGroup."id" AND
mpGroup."type_id" = ${_ids?.['@deep-foundation/core']?.Tree} AND
mpGroup."id" != ${_ids?.['@deep-foundation/core']?.typesTree} AND
((groupid != 0 AND groupid = mpGroup."id") OR groupid = 0)
) LOOP`,
iteratorInsertEnd: 'END LOOP;',
Expand All @@ -69,7 +70,8 @@ const triggerOptionos = {
mpInclude."type_id" IN (${_ids?.['@deep-foundation/core']?.TreeIncludeDown},${_ids?.['@deep-foundation/core']?.TreeIncludeUp},${_ids?.['@deep-foundation/core']?.TreeIncludeNode}, ${_ids?.['@deep-foundation/core']?.TreeIncludeIn}, ${_ids?.['@deep-foundation/core']?.TreeIncludeOut}, ${_ids?.['@deep-foundation/core']?.TreeIncludeFromCurrent}, ${_ids?.['@deep-foundation/core']?.TreeIncludeToCurrent}, ${_ids?.['@deep-foundation/core']?.TreeIncludeCurrentFrom}, ${_ids?.['@deep-foundation/core']?.TreeIncludeCurrentTo}, ${_ids?.['@deep-foundation/core']?.TreeIncludeFromCurrentTo}, ${_ids?.['@deep-foundation/core']?.TreeIncludeToCurrentFrom}) AND
mpInclude."to_id" IN (OLD.type_id, ${_ids?.['@deep-foundation/core']?.Any}) AND
mpInclude."from_id" = mpGroup."id" AND
mpGroup."type_id" = ${_ids?.['@deep-foundation/core']?.Tree}
mpGroup."type_id" = ${_ids?.['@deep-foundation/core']?.Tree} AND
mpGroup."id" != ${_ids?.['@deep-foundation/core']?.typesTree}
) LOOP`,
iteratorDeleteEnd: 'END LOOP;',
groupDelete: 'groupRow."id"',
Expand Down
7 changes: 4 additions & 3 deletions migrations/1621815803592-type-mp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Trigger } from '@deep-foundation/materialized-path/trigger.js';
import Debug from 'debug';
import { DeepClient } from '../imports/client.js';
import { TABLE_NAME as LINKS_TABLE_NAME } from './1616701513782-links.js';
import { _ids } from '../imports/client.js';

const debug = Debug('deeplinks:migrations:type-mp');
const log = debug.extend('log');
Expand Down Expand Up @@ -34,13 +35,13 @@ const createTrigger = async () => {
mpTableName: MP_TABLE_NAME,
graphTableName: LINKS_TABLE_NAME,
id_type: 'bigint',
iteratorInsertDeclare: `groupRow bigint DEFAULT 0;`,
iteratorInsertDeclare: `groupRow bigint DEFAULT ${_ids?.['@deep-foundation/core']?.typesTree};`,
iteratorDeleteArgumentSend: 'groupRow',
iteratorDeleteArgumentGet: `groupRow bigint = 0`,
iteratorDeleteArgumentGet: `groupRow bigint = ${_ids?.['@deep-foundation/core']?.typesTree}`,
iteratorInsertBegin: ``,
iteratorInsertEnd: '',
groupInsert: 'groupRow',
iteratorDeleteDeclare: `groupRow bigint DEFAULT 0;`,
iteratorDeleteDeclare: `groupRow bigint DEFAULT ${_ids?.['@deep-foundation/core']?.typesTree};`,
iteratorDeleteBegin: ``,
iteratorDeleteEnd: '',
groupDelete: 'groupRow',
Expand Down

0 comments on commit 1767589

Please sign in to comment.