Skip to content

Commit 93978b1

Browse files
committed
test for require and prepearing for plv8 3.1.5
1 parent ba6a395 commit 93978b1

File tree

7 files changed

+159
-137
lines changed

7 files changed

+159
-137
lines changed

mathjs-bundled/mathjs.js

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

migrations/1655979260869-sync-handlers.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ const triggerFunctionFabric = (handleOperationTypeId, valueTrigger) => /*javascr
383383
}
384384
385385
const require = (package) => {
386-
const code = plv8.find_function("${LINKS_TABLE_NAME}__".concat(package))();
387-
return eval(code)();
386+
const packageFabric = plv8.find_function("${LINKS_TABLE_NAME}__sync__handlers__".concat(package, '__package'));
387+
return packageFabric();
388388
}
389389
for (let i = 0; i < prepared.length; i++) {
390390
(()=>{
@@ -445,7 +445,7 @@ export const dropSyncInsertTriggerFunction = sql`DROP FUNCTION IF EXISTS ${LINKS
445445

446446
export const createSyncDeleteTriggerFunction = sql`CREATE OR REPLACE FUNCTION ${LINKS_TABLE_NAME}__sync__handlers__delete__trigger__function() RETURNS TRIGGER AS $$ ${triggerFunctionFabric(handleDeleteId, false)} $$ LANGUAGE plv8;`;
447447
export const createSyncDeleteTrigger = sql`CREATE TRIGGER a_${LINKS_TABLE_NAME}__sync__handlers__delete__trigger AFTER DELETE ON "links" FOR EACH ROW EXECUTE PROCEDURE ${LINKS_TABLE_NAME}__sync__handlers__delete__trigger__function();`;
448-
export const dropSyncDeleteTrigger = sql`DROP TRIGGER a_${LINKS_TABLE_NAME}__sync__delete__handler__trigger ON "${LINKS_TABLE_NAME}";`;
448+
export const dropSyncDeleteTrigger = sql`DROP TRIGGER a_${LINKS_TABLE_NAME}__sync__handlers__delete__trigger ON "${LINKS_TABLE_NAME}";`;
449449
export const dropSyncDeleteTriggerFunction = sql`DROP FUNCTION IF EXISTS ${LINKS_TABLE_NAME}__sync__handlers__delete__trigger__function CASCADE;`;
450450

451451
// strings triggers

migrations/1677594787268-mathjs.ts

+7-21
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
import Debug from 'debug';
2-
import { generateApolloClient } from '@deep-foundation/hasura/client';
3-
import { DeepClient } from '../imports/client';;
4-
import { api, TABLE_NAME as LINKS_TABLE_NAME } from '../migrations/1616701513782-links';
2+
import { api, TABLE_NAME as LINKS_TABLE_NAME } from './1616701513782-links';
53
import { sql } from '@deep-foundation/hasura/sql';
64
import { _ids } from '../imports/client';
5+
import fs from 'fs';
76

8-
const mathjs = require('../mathjs-bundled/mathjs.js').json;
7+
const mathjs = require('../mathjs-bundled/mathjs.js').code;
98

109
const debug = Debug('deeplinks:migrations:plv8');
1110
const log = debug.extend('log');
1211
const error = debug.extend('error');
1312

14-
const client = generateApolloClient({
15-
path: `${process.env.MIGRATIONS_HASURA_PATH}/v1/graphql`,
16-
ssl: !!+process.env.MIGRATIONS_HASURA_SSL,
17-
secret: process.env.MIGRATIONS_HASURA_SECRET,
18-
});
19-
20-
const deep = new DeepClient({
21-
apolloClient: client,
22-
})
23-
24-
25-
const mathjsFunction = /*javascript*/` return ${mathjs}`;
26-
27-
export const createMathjsFunction = sql`CREATE OR REPLACE FUNCTION ${LINKS_TABLE_NAME}__sync__handlers__mathjs__package(link jsonb, handletypeid bigint) RETURNS jsonb AS $$ ${mathjsFunction} $$ LANGUAGE plv8;`;
28-
export const dropMathjsFunction = sql`DROP FUNCTION IF EXISTS ${LINKS_TABLE_NAME}__sync__handlers__mathjs__package CASCADE;`;
29-
13+
const mathjsFunction = `const sync__handlers__package = ${mathjs}; return sync__handlers__package()`;
14+
export const createMathjsFunction = `CREATE OR REPLACE FUNCTION links__sync__handlers__mathjs__package() RETURNS jsonb AS $code$ ${mathjsFunction} $code$ LANGUAGE plv8;`;
15+
export const dropMathjsFunction = `DROP FUNCTION IF EXISTS links__sync__handlers__mathjs__package CASCADE;`;
3016

3117
export const up = async () => {
3218
log('up');
@@ -38,4 +24,4 @@ export const down = async () => {
3824
log('down');
3925

4026
await api.sql(dropMathjsFunction);
41-
};
27+
};

postgresql/dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
FROM postgres:12
22

3-
ENV PLV8_VERSION=3.0.0 \
4-
PLV8_SHASUM="de030f5d6b0439710efa05f4c35ffb8ef36ae754fa0e3c46d334352cf1507661"
3+
ENV PLV8_VERSION=3.1.5
54

65
RUN buildDependencies="build-essential \
6+
ninja-build \
77
ca-certificates \
88
curl \
99
git-core \
10-
python \
10+
python3 \
1111
gpp \
1212
cpp \
1313
pkg-config \
@@ -24,7 +24,6 @@ RUN buildDependencies="build-essential \
2424
&& mkdir -p /tmp/build \
2525
&& curl -o /tmp/build/v$PLV8_VERSION.tar.gz -SL "https://github.com/plv8/plv8/archive/v${PLV8_VERSION}.tar.gz" \
2626
&& cd /tmp/build \
27-
&& echo $PLV8_SHASUM v$PLV8_VERSION.tar.gz | sha256sum -c \
2827
&& tar -xzf /tmp/build/v$PLV8_VERSION.tar.gz -C /tmp/build/ \
2928
&& cd /tmp/build/plv8-$PLV8_VERSION \
3029
&& make static \

test.json

Whitespace-only changes.

test.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)