Comments (3)
CREATE FUNCTION statements are now partially supported in [email protected]
, via the registration of custom languages.
This allows to provide either a custom compiler (for custom scripts such as javascript via eval()
), or a mock implementation for each function creation.
(I dont think actual plpgsql support is coming anytime soon)
from pg-mem.
Supporting the "create function" statement, without actually parsing/compiling the function body (which would force you to declare mocks for your created pg functions directly in JS).
Hey @oguimbal what's the path that you suggest to implement this? I think this is most easy way to do this right now. Allowing the stub implementation of PSQL functions like extensions.
from pg-mem.
The path... you mean how it must be implemented ?
I've been wanting to add that in contributing.md for a while, so i'll do that now.
Like any feature of pg-mem, it breaks down into:
A) Implement its parser
NB: For this use case (create function stubs), this will not exactly look like below, because create function
body must be "ignored" ... thus, I think that the lexer must be modified. Which is a bit tricky. But otherwise, it goes like that:
- Look very hard at the statement syntax
- Add the target statement type in pgsql-ast-parser AST based on what I understood.
- Implement unit tests I want to pass (ex with create sequence UTs)
- Implement its syntax in a new nearley file (example with the create sequence statement) and reference it in main.ne
- Work on it until unit tests are all failing, but with an error which is not a parsing error
- Add an entry for the new statement in
IAstPartialMapper
here and add its default visitor implem like here and here until compiler stops screaming - Add the "toSql" implementation of the new statement like here (until compiler stops)
- Check that ALL unit tests are green (not only the new ones)
- Release pgsql-ast-parser
B) Executor
- install pgsql-ast-parser@latest
- Write unit tests (create sequence UTs are here, for instance)
- Implement statement... that's the less codified thing, but it starts by adding a new case in this switch for new statements (which should fail to compile with the newly installed pgsql-ast-parser), or fix compilation errors & unit tests for other amendments to the parser.
- Check that ALL unit tests are OK
- Release 🎉
I'll do that soon, when I find a bit of time 😃
from pg-mem.
Related Issues (20)
- QueryFailedError: type "bit" does not exist
- INSERT w/ ON CONFLICT DO NOTHING RETURNING * is returning rows for ignored conflicts
- Bytea uses utf8 instead of hex
- @mikro-orm/[email protected] has a security issue
- Corrupted alias error when adding enum column to table with multikey index
- Deleting and re-creating table with primary key fails
- Default values are evaluated at column creation time rather than insert time HOT 3
- Stand-alone instance of pg-mem HOT 7
- `using` in table alter
- Partial constraints not working
- migrate on custom schemas does not work
- Allow table name prefixed with schema
- Docs request: getting started for Python users HOT 1
- Support for "HAVING" syntax
- pg_type table contains zero rows
- Receive problem when trying to reproduce tutorial example on my project entities HOT 3
- TypeError: DataSource is not a constructor HOT 1
- Implement the json_array_elements method
- Unknown alias error when using Group By HOT 1
- Query from node-pg-migrate that won't parse - REFERENCES
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg-mem.