Skip to content

Update Expressions #9

@esatterwhite

Description

@esatterwhite

I'm looking to expand the update statement. It may be something specific to postgres, but the SET clauses can be expressions

UPDATE table
SET 
  ts = NOW()
, text = SOME_FN( VARIADIC ARRAY(<SUBQUERY>) )

What isn't apparently obvious to me is what can be an expression and what can not be. I guess what I'm looking for is the low level bits that convert the SQL AST objects into the query. is there one?

What does this?

const sql = convertToSQL({
  ':fn()': [ 
     'arg1'
   , {':lower()', {':plain': 'foobar'}}
   , sql.statement('select').where(...)
   ]
})

The more I use this package, the more I see it as a generic sql compiler. The problem I tent to run into is that not everything uses the AST, for lack of a better term.

update set clauses, order by clauses, for example don't allow this, but SQL does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions