Introduce the concept of functions#91
Conversation
|
yeah this is definitely awesome. Would be nice to make the function thing 'extensible' so one can easily add other functions. I know with postgres as you enable other addons (such as postGis or plv8) you get more functions. It would be nice to be able to add those functions in user-land code through a public api within node-sql. |
…'hello', 'world'))
… how to load dialect specific functions
|
This one is ready to be reviewed, after the Having clause pull request is reviewed. Sql.functionCallCreator will return a function that creates a function call node. It can be used to create custom functions, ie. ST_AsGeoJSON = Sql.functionCallCreator('ST_AsGeoJSON'), and then use it as ST_AsGeoJSON(table.column). |
|
What do you think about adding the functions to Column.prototype so they can be used without referencing sql.functions? Obviously they can & should stay there (for multi-column functions at the very least) but I do like doing things like
Regardless, that can be a future pull request. This bad boy looks good to go! |
Introduce the concept of functions
This isn't completely done yet, there's work to be done to load in dialect specific functions. For example, Postgres and MySQL have a ton of math and string functions that aren't available to sqlite.
Columns currently support the concept of aggregate, but it's not as powerful of a concept as function. For example, the column's sum aggregation only sums that particular column, so you can't express sum(columnA.plus(columnB))