-
hi, core questionI am trying to have
I want to have
a suggestion or request could be: could you provide a simple example to implement things that have already been implemented in investigation i didI read about declaring custom languages (ie, I also see some good test coverage: https://github.com/oguimbal/pg-mem/blob/master/src/tests/function-calls.spec.ts#L34
I see in the code where a custom enum is built in which calls it looks like the core of what I want to do (register an enum) is via this implementation:
but am unable to reason about how I could go about implementing something so simple as a mock return value (create the enum type) for |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi ! The pgsql language is not implemented, but it doesnt mean that you cannot execute simple queries (that are supported). So my answer may be naïve, but did you try something like this ? db.registerLanguage('plpgsql', ({ code, args, returns }) => {
assert(code).to.equal(expected); // or whatever
return () => {
if (!db.public.one(`select 1 from pg_type where typname = 'transaction_type'`)) {
db.public.none(`create type transaction_type as enum ('charge', 'refund');`);
}
};
}); |
Beta Was this translation helpful? Give feedback.
-
Thank you @oguimbal ! That's perfect. This is exactly what I was looking for - just enough code / a simple example to get started. Do you mind adding a reference to this discussion in the wiki for future users? I tweaked it slightly, it's obviously not a full implementation or anything of the like, but if you have 1 or two
|
Beta Was this translation helpful? Give feedback.
Hi !
The pgsql language is not implemented, but it doesnt mean that you cannot execute simple queries (that are supported).
So my answer may be naïve, but did you try something like this ?