Skip to content

Generate VALUES statement from model instance #519

@AndrewWinterman

Description

@AndrewWinterman

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I would like to be able to generate a virtual table from an existing model instance, so that I can do a conditional insert in postgres without resorting to postgres.Raw or transaction semantics.

For example, I want to do

INSERT INTO users (name, email, created_at)
  SELECT 'John Doe', '[email protected]', NOW()
  WHERE NOT EXISTS (
      SELECT 1 FROM users WHERE email = '[email protected]'
  );

but I want all the fields to be provided by any arbitrary jet model instance

Describe the solution you'd like
A clear and concise description of what you want to happen.

One possible solution would be to simply make func UnwindRowFromModel(columns []Column, data interface{}) []Serializer { public.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions