Skip to content
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

clean up meta.function identifiers #18

Closed
erichanson opened this issue Mar 21, 2016 · 1 comment
Closed

clean up meta.function identifiers #18

erichanson opened this issue Mar 21, 2016 · 1 comment

Comments

@erichanson
Copy link
Member

In meta.function, function signatures are getting screwed up. PostgreSQL supports several ways to define a function's signature. In meta, they're coming through like this:

aquameta=# select id from meta.function limit 20;
                                                                                      id
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 ("(bundle)",blob_hash_gen_trigger,{})
 ("(bundle)",checkout,"{""commit_id uuid""}")
 ("(bundle)",checkout_row,"{""row_id meta.row_id"",""fields bundle._checkout_field"",""force_overwrite boolean""}")
 ("(bundle)",commit,"{""bundle_name text"",""message text""}")
 ("(bundle)",commit_log,"{""bundle_name text"",""out commit_id uuid"",""out message text"",""out count bigint""}")
 ("(bundle)",construct_bundle_diff,"{""bundle_id uuid"",""new_commits pg_catalog._uuid"",""temp_table_name text"",""create_bundle boolean""}")
 ("(bundle)",delete,"{""_bundle_id uuid""}")
 ("(bundle)",delete_commit,"{""_commit_id uuid""}")
 ("(bundle)",exec,"{""statements pg_catalog._text""}")
 ("(bundle)",head_rows,"{""bundle_name text"",""out commit_id uuid"",""out schema_name text"",""out relation_name text"",""out pk_column_name text"",""out pk_value text""}")
 ("(bundle)",remote_compare_commits,"{""_remote_id uuid"",""out local_commit_id uuid"",""out remote_commit_id uuid""}")
 ("(bundle)",remote_fetch,"{""remote_id uuid"",""create_bundle boolean""}")
 ("(bundle)",remote_has_bundle,"{""_remote_id uuid"",""out has_bundle boolean""}")
 ("(bundle)",remote_push,"{""remote_id uuid"",""create_bundle boolean""}")
 ("(bundle)",stage_field_change,"{""bundle_id uuid"",""changed_field_id meta.field_id""}")
 ("(bundle)",stage_field_change,"{""bundle_name text"",""schema_name text"",""relation_name text"",""pk_column_name text"",""pk_value text"",""column_name text""}")
 ("(bundle)",stage_row_add,"{""bundle_name text"",""schema_name text"",""relation_name text"",""pk_column_name text"",""pk_value text""}")
 ("(bundle)",stage_row_delete,"{""bundle_name text"",""schema_name text"",""relation_name text"",""pk_column_name text"",""pk_value text""}")
 ("(bundle)",unstage_field_change,"{""bundle_id uuid"",""changed_field_id meta.field_id""}")
 ("(bundle)",unstage_field_change,"{""bundle_name text"",""schema_name text"",""relation_name text"",""pk_column_name text"",""pk_value text"",""column_name text""}")
(20 rows)

A few problems here:

  • argument names are nice but not part of PostgreSQL's function identifier. remove from id.
  • OUT vars are comign through as part of the id. Don't want
  • arguments should be an array, not a JSON object, because order is significant

Same problems in the parameters column, which may or may not even be needed, and possibly could be broken out into a function_argument table?

@erichanson
Copy link
Member Author

Casting meta_ids to string for use as URLs is straight forward except for function, where the argument type signature is part of the identifier.

PostgreSQL's function resolution procedure is here:

http://www.postgresql.org/docs/9.1/static/typeconv-func.html

The current version of endpoint.request just takes the first matching function with the same name and calls it:

https://github.com/aquametalabs/aquameta/blob/master/core/004-aquameta_endpoint/000-endpoint_server.sql#L708

We want to be able to use named arguments when they exist, ideally with a

endpoint.schema('bundle').function('foo', { name: 'Joe',  id: 'foo' });

This is nice, but it doesn't really match with the way PostgreSQL identifies functions. Functions can either have named arguments or unnamed, positional arguments. So we want to support positional arguments via an array as well:

endpoint.schema('bundle').function('foo', [ 1, 'Joe', 'hello' ]);

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

No branches or pull requests

1 participant