Merge pull request #3 from hailocab/upstream-merge

Upstream merge
Add Session wrapper

With this patch we can now use gocqlx like:

```
session.Query(`SELECT * FROM struct_table`, nil).Get(&v)
```

instead of (old format):

```
gocqlx.Query(session.Query(`SELECT * FROM struct_table`), nil).Get(&v)
```

Signed-off-by: Michał Matczuk <michal@scylladb.com>
This commit is contained in:
Michał Matczuk
2020-04-20 17:39:17 +02:00
committed by Michal Jan Matczuk
parent ab279e68ed
commit 95d96fa939
13 changed files with 208 additions and 149 deletions

View File

@@ -90,6 +90,8 @@ type Queryx struct {
}
// Query creates a new Queryx from gocql.Query using a default mapper.
//
// Deprecated: Use Session API instead.
func Query(q *gocql.Query, names []string) *Queryx {
return &Queryx{
Query: q,
@@ -266,7 +268,9 @@ func (q *Queryx) SelectRelease(dest interface{}) error {
// big to be loaded with Select in order to do row by row iteration.
// See Iterx StructScan function.
func (q *Queryx) Iter() *Iterx {
i := Iter(q.Query)
i.Mapper = q.Mapper
return i
return &Iterx{
Iter: q.Query.Iter(),
Mapper: q.Mapper,
unsafe: DefaultUnsafe,
}
}