Skip to content

table aliases #17

@yurykozyrev

Description

@yurykozyrev

I would suggest to introduce table aliases for using them in query.

Problem
E.g.: if we use column like this

pqt.NewColumn("version", pqt.TypeIntegerBig(), pqt.WithNotNull(), pqt.WithDefault("version+1", pqt.EventUpdate)

it will generate the following code in SELECT ... ON CONFLICT ... DO UPDATE SET ...:

INSERT INTO tablename (value, version) VALUES ('data', 0) 
ON CONFLICT (id) DO UPDATE SET value='data', version=version+1
RETURNING data, version

which will cause an error column reference "version" is ambiguous

Suggestion
Add table alias so it produce the code like

INSERT INTO tablename AS alias ... alias.version=version+1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions