Comments (6)
With pg.v4 you can try something like:
ints := []int{1, 2, 3}
db.Exec(`SELECT * FROM insert_batch(?)`, types.Array(ints))
But array of time types.Array([]time.Time{...})
is not supported...
from pg.
Overall array support is very limited right now - https://github.com/go-pg/pg/blob/v4/types/array.go#L16-L28
from pg.
Actually the example needs curly brackets rather than round brackets:
ints := []int{1, 2, 3}
db.Exec("SELECT * FROM insert_batch(?)", types.Array{ints})
Otherwise you get:
cannot convert ints (type []int) to type types.Array
from pg.
Eventually I will make it work correctly, but first I want to stabilize v4 branch and release ORM to public...
from pg.
FYI #138 added support for []time.Time
array, but API changed slightly:
ints := []int{1, 2, 3}
times := []time.TIme{time.Now()}
db.Exec(`SELECT * FROM insert_batch(?, ?)`, pg.Array(&ints), pg.Array(×))
There is still some work to be done, but it should be usable.
from pg.
I consider array support finished. See https://godoc.org/gopkg.in/pg.v4#example-DB-Model-PostgresqlArrayStructTag and https://godoc.org/gopkg.in/pg.v4#example-Array for examples.
from pg.
Related Issues (20)
- Error in join query not erroring Select call
- CreateTable method not accepting CreateTableOptions struct HOT 4
- How do you change which field/column in the base table is referenced by the foreign key of a sub table?
- 42703 column does not exist, only for multi-word columns on one table
- Update omit zero when no fields produces invalid syntax HOT 1
- panic on non nil "Result" with nil value in "AfterQuery" hook
- "BeforeUpdate" hook not working for individual column updates
- CountEstimate is not safe to be called from transaction context
- nil-pointer dereference in getConn HOT 3
- conn.OnQueryProcessed undefined (type *pg.DB has no field or method OnQueryProcessed) HOT 1
- Only one of the Columns that have the same name parsed in map[string]interface{} HOT 1
- Open does not return Error when connection fails HOT 1
- r.db.RunInTransaction can not use r.db.ModelContext
- Do we support select to insert HOT 1
- Join() being ignored when using Delete() HOT 3
- Help me to get the relation.
- Scan JSON value get panic HOT 1
- Unable to insert a value of type uint64 into the table column of type DECIMAL(20,0).
- Potential Memory Leak in appendRune Function
- Multiple joins not deserializing correctly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg.