Created
December 29, 2013 20:04
-
-
Save solidsnack/8174206 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This Python/Scala like syntax with type annotations | |
| # would be easier for people to write. | |
| def join_convention(a: Table, b: Table): | |
| col: Column = b.columns[a.table_name] | |
| [ * for * in join(a, b) on a(id) = b(col) ] | |
| # This is more a sketch than anything. The handling of functions, | |
| # table column lookups, actual properties of tables and columns, | |
| # and "computed" tables and columns are all important in the syntax. | |
| ==== becomes ==== | |
| -- Note that 'regclass' is a Postgres type that is a pointer to a table. | |
| CREATE FUNCTION join_convention(a regclass, b regclass) | |
| RETURNS SETOF record AS $$ BEGIN | |
| RETURN QUERY EXECUTE | |
| 'SELECT * FROM '||a||' JOIN '||b||' ON ('||a||'.id = '||b||'.'||a||')'; | |
| END $$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment