Skip to content

Draft: [Pg] Add support for procedural functions #4753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

luca-nardelli
Copy link

@luca-nardelli luca-nardelli commented Jul 17, 2025

Hi all, this PR is my attempt at adding support for postgres functions to Drizzle.

Syntax:

pgFunction('uppercase', {
	schema: 'public',
	args: 'input_text text',
	language: 'sql',
	returns: 'text',
	stability: 'stable',
	security: 'invoker',
	body: 'SELECT UPPER(input_text)',
})

While I did add some tests (basically only in drizzle-kit), I'm not 100% confident to have covered everything since this repo is quite big, so I'd ask for some review by the maintainers before proceeding further (that's why I'm marking this as draft). Right now it's possible to define functions, introspect functions and generate migrations from the schema snapshot. Every time a function changes, it will be dropped and recreated (to keep things simpler instead of ALTER-ing it).

Right now, not all function parameters are supported, but they should be easily added if the proposed approach works.

This PR also forces singlestore to use linux/amd64 image since it's not available on arm and tests were failing then.

Related issues/discussions:
#2586
#2434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant