Skip to content

copy.go: Missing field to add options #688

@charlespare

Description

@charlespare

copy.go: Missing field to add options

According to the doc, when you use CopyIn you can add options at the end of the statement:
https://www.postgresql.org/docs/9.2/static/sql-copy.html

In my case I wanted to add options to handle null values. To fix it quickly I ended up writing a function that modify the statement before sending it to the database:

txn.Prepare(AddOptionToStmt(pq.CopyIn("column1", "column2", "column3")))

func AddOptionToStmt(inputStatement string) string {
outputStatement := inputStatement + WITH NULL 'NULL'
return outputStatement
}

It would be nice to handle options in the code directly in the pq.CopyIn function by adding a parameter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions